documentation.d.ts 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * 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 get 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 set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /** Defines the cross module used constants to avoid circular dependncies */
  583. export class Constants {
  584. /** Defines that alpha blending is disabled */
  585. static readonly ALPHA_DISABLE: number;
  586. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  587. static readonly ALPHA_ADD: number;
  588. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  589. static readonly ALPHA_COMBINE: number;
  590. /** Defines that alpha blending is DEST - SRC * DEST */
  591. static readonly ALPHA_SUBTRACT: number;
  592. /** Defines that alpha blending is SRC * DEST */
  593. static readonly ALPHA_MULTIPLY: number;
  594. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  595. static readonly ALPHA_MAXIMIZED: number;
  596. /** Defines that alpha blending is SRC + DEST */
  597. static readonly ALPHA_ONEONE: number;
  598. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  599. static readonly ALPHA_PREMULTIPLIED: number;
  600. /**
  601. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  603. */
  604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  605. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  606. static readonly ALPHA_INTERPOLATE: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_SCREENMODE: number;
  612. /**
  613. * Defines that alpha blending is SRC + DST
  614. * Alpha will be set to SRC ALPHA + DST ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEONE: number;
  617. /**
  618. * Defines that alpha blending is SRC * DST ALPHA + DST
  619. * Alpha will be set to 0
  620. */
  621. static readonly ALPHA_ALPHATOCOLOR: number;
  622. /**
  623. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  624. */
  625. static readonly ALPHA_REVERSEONEMINUS: number;
  626. /**
  627. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  628. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  629. */
  630. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  631. /**
  632. * Defines that alpha blending is SRC + DST
  633. * Alpha will be set to SRC ALPHA
  634. */
  635. static readonly ALPHA_ONEONE_ONEZERO: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. * Alpha will be set to DST ALPHA
  639. */
  640. static readonly ALPHA_EXCLUSION: number;
  641. /** Defines that alpha blending equation a SUM */
  642. static readonly ALPHA_EQUATION_ADD: number;
  643. /** Defines that alpha blending equation a SUBSTRACTION */
  644. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  645. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  646. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  647. /** Defines that alpha blending equation a MAX operation */
  648. static readonly ALPHA_EQUATION_MAX: number;
  649. /** Defines that alpha blending equation a MIN operation */
  650. static readonly ALPHA_EQUATION_MIN: number;
  651. /**
  652. * Defines that alpha blending equation a DARKEN operation:
  653. * It takes the min of the src and sums the alpha channels.
  654. */
  655. static readonly ALPHA_EQUATION_DARKEN: number;
  656. /** Defines that the ressource is not delayed*/
  657. static readonly DELAYLOADSTATE_NONE: number;
  658. /** Defines that the ressource was successfully delay loaded */
  659. static readonly DELAYLOADSTATE_LOADED: number;
  660. /** Defines that the ressource is currently delay loading */
  661. static readonly DELAYLOADSTATE_LOADING: number;
  662. /** Defines that the ressource is delayed and has not started loading */
  663. static readonly DELAYLOADSTATE_NOTLOADED: number;
  664. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  665. static readonly NEVER: number;
  666. /** 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 */
  667. static readonly ALWAYS: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  669. static readonly LESS: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  671. static readonly EQUAL: number;
  672. /** 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 */
  673. static readonly LEQUAL: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  675. static readonly GREATER: number;
  676. /** 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 */
  677. static readonly GEQUAL: number;
  678. /** 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 */
  679. static readonly NOTEQUAL: number;
  680. /** Passed to stencilOperation to specify that stencil value must be kept */
  681. static readonly KEEP: number;
  682. /** Passed to stencilOperation to specify that stencil value must be replaced */
  683. static readonly REPLACE: number;
  684. /** Passed to stencilOperation to specify that stencil value must be incremented */
  685. static readonly INCR: number;
  686. /** Passed to stencilOperation to specify that stencil value must be decremented */
  687. static readonly DECR: number;
  688. /** Passed to stencilOperation to specify that stencil value must be inverted */
  689. static readonly INVERT: number;
  690. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  691. static readonly INCR_WRAP: number;
  692. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  693. static readonly DECR_WRAP: number;
  694. /** Texture is not repeating outside of 0..1 UVs */
  695. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  696. /** Texture is repeating outside of 0..1 UVs */
  697. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  698. /** Texture is repeating and mirrored */
  699. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  700. /** ALPHA */
  701. static readonly TEXTUREFORMAT_ALPHA: number;
  702. /** LUMINANCE */
  703. static readonly TEXTUREFORMAT_LUMINANCE: number;
  704. /** LUMINANCE_ALPHA */
  705. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  706. /** RGB */
  707. static readonly TEXTUREFORMAT_RGB: number;
  708. /** RGBA */
  709. static readonly TEXTUREFORMAT_RGBA: number;
  710. /** RED */
  711. static readonly TEXTUREFORMAT_RED: number;
  712. /** RED (2nd reference) */
  713. static readonly TEXTUREFORMAT_R: number;
  714. /** RG */
  715. static readonly TEXTUREFORMAT_RG: number;
  716. /** RED_INTEGER */
  717. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  718. /** RED_INTEGER (2nd reference) */
  719. static readonly TEXTUREFORMAT_R_INTEGER: number;
  720. /** RG_INTEGER */
  721. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  722. /** RGB_INTEGER */
  723. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  724. /** RGBA_INTEGER */
  725. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  726. /** UNSIGNED_BYTE */
  727. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  728. /** UNSIGNED_BYTE (2nd reference) */
  729. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  730. /** FLOAT */
  731. static readonly TEXTURETYPE_FLOAT: number;
  732. /** HALF_FLOAT */
  733. static readonly TEXTURETYPE_HALF_FLOAT: number;
  734. /** BYTE */
  735. static readonly TEXTURETYPE_BYTE: number;
  736. /** SHORT */
  737. static readonly TEXTURETYPE_SHORT: number;
  738. /** UNSIGNED_SHORT */
  739. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  740. /** INT */
  741. static readonly TEXTURETYPE_INT: number;
  742. /** UNSIGNED_INT */
  743. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  744. /** UNSIGNED_SHORT_4_4_4_4 */
  745. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  746. /** UNSIGNED_SHORT_5_5_5_1 */
  747. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  748. /** UNSIGNED_SHORT_5_6_5 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  750. /** UNSIGNED_INT_2_10_10_10_REV */
  751. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  752. /** UNSIGNED_INT_24_8 */
  753. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  754. /** UNSIGNED_INT_10F_11F_11F_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  756. /** UNSIGNED_INT_5_9_9_9_REV */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  758. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  759. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  760. /** nearest is mag = nearest and min = nearest and no mip */
  761. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  762. /** mag = nearest and min = nearest and mip = none */
  763. static readonly TEXTURE_NEAREST_NEAREST: number;
  764. /** Bilinear is mag = linear and min = linear and no mip */
  765. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  766. /** mag = linear and min = linear and mip = none */
  767. static readonly TEXTURE_LINEAR_LINEAR: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** Trilinear is mag = linear and min = linear and mip = linear */
  771. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  772. /** mag = nearest and min = nearest and mip = nearest */
  773. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  774. /** mag = nearest and min = linear and mip = nearest */
  775. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  776. /** mag = nearest and min = linear and mip = linear */
  777. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  778. /** mag = nearest and min = linear and mip = none */
  779. static readonly TEXTURE_NEAREST_LINEAR: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** mag = linear and min = nearest and mip = nearest */
  783. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  784. /** mag = linear and min = nearest and mip = linear */
  785. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = none */
  789. static readonly TEXTURE_LINEAR_NEAREST: number;
  790. /** Explicit coordinates mode */
  791. static readonly TEXTURE_EXPLICIT_MODE: number;
  792. /** Spherical coordinates mode */
  793. static readonly TEXTURE_SPHERICAL_MODE: number;
  794. /** Planar coordinates mode */
  795. static readonly TEXTURE_PLANAR_MODE: number;
  796. /** Cubic coordinates mode */
  797. static readonly TEXTURE_CUBIC_MODE: number;
  798. /** Projection coordinates mode */
  799. static readonly TEXTURE_PROJECTION_MODE: number;
  800. /** Skybox coordinates mode */
  801. static readonly TEXTURE_SKYBOX_MODE: number;
  802. /** Inverse Cubic coordinates mode */
  803. static readonly TEXTURE_INVCUBIC_MODE: number;
  804. /** Equirectangular coordinates mode */
  805. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  806. /** Equirectangular Fixed coordinates mode */
  807. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  808. /** Equirectangular Fixed Mirrored coordinates mode */
  809. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  810. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  811. static readonly SCALEMODE_FLOOR: number;
  812. /** Defines that texture rescaling will look for the nearest power of 2 size */
  813. static readonly SCALEMODE_NEAREST: number;
  814. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  815. static readonly SCALEMODE_CEILING: number;
  816. /**
  817. * The dirty texture flag value
  818. */
  819. static readonly MATERIAL_TextureDirtyFlag: number;
  820. /**
  821. * The dirty light flag value
  822. */
  823. static readonly MATERIAL_LightDirtyFlag: number;
  824. /**
  825. * The dirty fresnel flag value
  826. */
  827. static readonly MATERIAL_FresnelDirtyFlag: number;
  828. /**
  829. * The dirty attribute flag value
  830. */
  831. static readonly MATERIAL_AttributesDirtyFlag: number;
  832. /**
  833. * The dirty misc flag value
  834. */
  835. static readonly MATERIAL_MiscDirtyFlag: number;
  836. /**
  837. * The all dirty flag value
  838. */
  839. static readonly MATERIAL_AllDirtyFlag: number;
  840. /**
  841. * Returns the triangle fill mode
  842. */
  843. static readonly MATERIAL_TriangleFillMode: number;
  844. /**
  845. * Returns the wireframe mode
  846. */
  847. static readonly MATERIAL_WireFrameFillMode: number;
  848. /**
  849. * Returns the point fill mode
  850. */
  851. static readonly MATERIAL_PointFillMode: number;
  852. /**
  853. * Returns the point list draw mode
  854. */
  855. static readonly MATERIAL_PointListDrawMode: number;
  856. /**
  857. * Returns the line list draw mode
  858. */
  859. static readonly MATERIAL_LineListDrawMode: number;
  860. /**
  861. * Returns the line loop draw mode
  862. */
  863. static readonly MATERIAL_LineLoopDrawMode: number;
  864. /**
  865. * Returns the line strip draw mode
  866. */
  867. static readonly MATERIAL_LineStripDrawMode: number;
  868. /**
  869. * Returns the triangle strip draw mode
  870. */
  871. static readonly MATERIAL_TriangleStripDrawMode: number;
  872. /**
  873. * Returns the triangle fan draw mode
  874. */
  875. static readonly MATERIAL_TriangleFanDrawMode: number;
  876. /**
  877. * Stores the clock-wise side orientation
  878. */
  879. static readonly MATERIAL_ClockWiseSideOrientation: number;
  880. /**
  881. * Stores the counter clock-wise side orientation
  882. */
  883. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  884. /**
  885. * Nothing
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_NothingTrigger: number;
  889. /**
  890. * On pick
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnPickTrigger: number;
  894. /**
  895. * On left pick
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnLeftPickTrigger: number;
  899. /**
  900. * On right pick
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnRightPickTrigger: number;
  904. /**
  905. * On center pick
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnCenterPickTrigger: number;
  909. /**
  910. * On pick down
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickDownTrigger: number;
  914. /**
  915. * On double pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnDoublePickTrigger: number;
  919. /**
  920. * On pick up
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickUpTrigger: number;
  924. /**
  925. * On pick out.
  926. * This trigger will only be raised if you also declared a OnPickDown
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickOutTrigger: number;
  930. /**
  931. * On long press
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnLongPressTrigger: number;
  935. /**
  936. * On pointer over
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPointerOverTrigger: number;
  940. /**
  941. * On pointer out
  942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  943. */
  944. static readonly ACTION_OnPointerOutTrigger: number;
  945. /**
  946. * On every frame
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnEveryFrameTrigger: number;
  950. /**
  951. * On intersection enter
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnIntersectionEnterTrigger: number;
  955. /**
  956. * On intersection exit
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnIntersectionExitTrigger: number;
  960. /**
  961. * On key down
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnKeyDownTrigger: number;
  965. /**
  966. * On key up
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnKeyUpTrigger: number;
  970. /**
  971. * Billboard mode will only apply to Y axis
  972. */
  973. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  974. /**
  975. * Billboard mode will apply to all axes
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  978. /**
  979. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  982. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  983. * Test order :
  984. * Is the bounding sphere outside the frustum ?
  985. * If not, are the bounding box vertices outside the frustum ?
  986. * It not, then the cullable object is in the frustum.
  987. */
  988. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  989. /** Culling strategy : Bounding Sphere Only.
  990. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  991. * It's also less accurate than the standard because some not visible objects can still be selected.
  992. * Test : is the bounding sphere outside the frustum ?
  993. * If not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  996. /** Culling strategy : Optimistic Inclusion.
  997. * This in an inclusion test first, then the standard exclusion test.
  998. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  999. * 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.
  1000. * Anyway, it's as accurate as the standard strategy.
  1001. * Test :
  1002. * Is the cullable object bounding sphere center in the frustum ?
  1003. * If not, apply the default culling strategy.
  1004. */
  1005. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1006. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1007. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1008. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1009. * 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.
  1010. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1011. * Test :
  1012. * Is the cullable object bounding sphere center in the frustum ?
  1013. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1016. /**
  1017. * No logging while loading
  1018. */
  1019. static readonly SCENELOADER_NO_LOGGING: number;
  1020. /**
  1021. * Minimal logging while loading
  1022. */
  1023. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1024. /**
  1025. * Summary logging while loading
  1026. */
  1027. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1028. /**
  1029. * Detailled logging while loading
  1030. */
  1031. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * This represents the required contract to create a new type of texture loader.
  1037. */
  1038. export interface IInternalTextureLoader {
  1039. /**
  1040. * Defines wether the loader supports cascade loading the different faces.
  1041. */
  1042. supportCascades: boolean;
  1043. /**
  1044. * This returns if the loader support the current file information.
  1045. * @param extension defines the file extension of the file being loaded
  1046. * @returns true if the loader can load the specified file
  1047. */
  1048. canLoad(extension: string): boolean;
  1049. /**
  1050. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1051. * @param data contains the texture data
  1052. * @param texture defines the BabylonJS internal texture
  1053. * @param createPolynomials will be true if polynomials have been requested
  1054. * @param onLoad defines the callback to trigger once the texture is ready
  1055. * @param onError defines the callback to trigger in case of error
  1056. */
  1057. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1058. /**
  1059. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1060. * @param data contains the texture data
  1061. * @param texture defines the BabylonJS internal texture
  1062. * @param callback defines the method to call once ready to upload
  1063. */
  1064. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1065. }
  1066. }
  1067. declare module BABYLON {
  1068. /**
  1069. * Class used to store and describe the pipeline context associated with an effect
  1070. */
  1071. export interface IPipelineContext {
  1072. /**
  1073. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1074. */
  1075. isAsync: boolean;
  1076. /**
  1077. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1078. */
  1079. isReady: boolean;
  1080. /** @hidden */
  1081. _getVertexShaderCode(): string | null;
  1082. /** @hidden */
  1083. _getFragmentShaderCode(): string | null;
  1084. /** @hidden */
  1085. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1086. }
  1087. }
  1088. declare module BABYLON {
  1089. /**
  1090. * Class used to store gfx data (like WebGLBuffer)
  1091. */
  1092. export class DataBuffer {
  1093. /**
  1094. * Gets or sets the number of objects referencing this buffer
  1095. */
  1096. references: number;
  1097. /** Gets or sets the size of the underlying buffer */
  1098. capacity: number;
  1099. /**
  1100. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1101. */
  1102. is32Bits: boolean;
  1103. /**
  1104. * Gets the underlying buffer
  1105. */
  1106. get underlyingResource(): any;
  1107. }
  1108. }
  1109. declare module BABYLON {
  1110. /** @hidden */
  1111. export interface IShaderProcessor {
  1112. attributeProcessor?: (attribute: string) => string;
  1113. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1114. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1115. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1116. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1117. lineProcessor?: (line: string, isFragment: boolean) => string;
  1118. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1119. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1120. }
  1121. }
  1122. declare module BABYLON {
  1123. /** @hidden */
  1124. export interface ProcessingOptions {
  1125. defines: string[];
  1126. indexParameters: any;
  1127. isFragment: boolean;
  1128. shouldUseHighPrecisionShader: boolean;
  1129. supportsUniformBuffers: boolean;
  1130. shadersRepository: string;
  1131. includesShadersStore: {
  1132. [key: string]: string;
  1133. };
  1134. processor?: IShaderProcessor;
  1135. version: string;
  1136. platformName: string;
  1137. lookForClosingBracketForUniformBuffer?: boolean;
  1138. }
  1139. }
  1140. declare module BABYLON {
  1141. /** @hidden */
  1142. export class ShaderCodeNode {
  1143. line: string;
  1144. children: ShaderCodeNode[];
  1145. additionalDefineKey?: string;
  1146. additionalDefineValue?: string;
  1147. isValid(preprocessors: {
  1148. [key: string]: string;
  1149. }): boolean;
  1150. process(preprocessors: {
  1151. [key: string]: string;
  1152. }, options: ProcessingOptions): string;
  1153. }
  1154. }
  1155. declare module BABYLON {
  1156. /** @hidden */
  1157. export class ShaderCodeCursor {
  1158. private _lines;
  1159. lineIndex: number;
  1160. get currentLine(): string;
  1161. get canRead(): boolean;
  1162. set lines(value: string[]);
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1168. process(preprocessors: {
  1169. [key: string]: string;
  1170. }, options: ProcessingOptions): string;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderDefineExpression {
  1176. isTrue(preprocessors: {
  1177. [key: string]: string;
  1178. }): boolean;
  1179. }
  1180. }
  1181. declare module BABYLON {
  1182. /** @hidden */
  1183. export class ShaderCodeTestNode extends ShaderCodeNode {
  1184. testExpression: ShaderDefineExpression;
  1185. isValid(preprocessors: {
  1186. [key: string]: string;
  1187. }): boolean;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1193. define: string;
  1194. not: boolean;
  1195. constructor(define: string, not?: boolean);
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. }
  1200. }
  1201. declare module BABYLON {
  1202. /** @hidden */
  1203. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1204. leftOperand: ShaderDefineExpression;
  1205. rightOperand: ShaderDefineExpression;
  1206. isTrue(preprocessors: {
  1207. [key: string]: string;
  1208. }): boolean;
  1209. }
  1210. }
  1211. declare module BABYLON {
  1212. /** @hidden */
  1213. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1214. leftOperand: ShaderDefineExpression;
  1215. rightOperand: ShaderDefineExpression;
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /** @hidden */
  1223. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1224. define: string;
  1225. operand: string;
  1226. testValue: string;
  1227. constructor(define: string, operand: string, testValue: string);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /**
  1235. * Class used to enable access to offline support
  1236. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1237. */
  1238. export interface IOfflineProvider {
  1239. /**
  1240. * Gets a boolean indicating if scene must be saved in the database
  1241. */
  1242. enableSceneOffline: boolean;
  1243. /**
  1244. * Gets a boolean indicating if textures must be saved in the database
  1245. */
  1246. enableTexturesOffline: boolean;
  1247. /**
  1248. * Open the offline support and make it available
  1249. * @param successCallback defines the callback to call on success
  1250. * @param errorCallback defines the callback to call on error
  1251. */
  1252. open(successCallback: () => void, errorCallback: () => void): void;
  1253. /**
  1254. * Loads an image from the offline support
  1255. * @param url defines the url to load from
  1256. * @param image defines the target DOM image
  1257. */
  1258. loadImage(url: string, image: HTMLImageElement): void;
  1259. /**
  1260. * Loads a file from offline support
  1261. * @param url defines the URL to load from
  1262. * @param sceneLoaded defines a callback to call on success
  1263. * @param progressCallBack defines a callback to call when progress changed
  1264. * @param errorCallback defines a callback to call on error
  1265. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1266. */
  1267. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1268. }
  1269. }
  1270. declare module BABYLON {
  1271. /**
  1272. * Class used to help managing file picking and drag'n'drop
  1273. * File Storage
  1274. */
  1275. export class FilesInputStore {
  1276. /**
  1277. * List of files ready to be loaded
  1278. */
  1279. static FilesToLoad: {
  1280. [key: string]: File;
  1281. };
  1282. }
  1283. }
  1284. declare module BABYLON {
  1285. /**
  1286. * Class used to define a retry strategy when error happens while loading assets
  1287. */
  1288. export class RetryStrategy {
  1289. /**
  1290. * Function used to defines an exponential back off strategy
  1291. * @param maxRetries defines the maximum number of retries (3 by default)
  1292. * @param baseInterval defines the interval between retries
  1293. * @returns the strategy function to use
  1294. */
  1295. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1296. }
  1297. }
  1298. declare module BABYLON {
  1299. /**
  1300. * @ignore
  1301. * Application error to support additional information when loading a file
  1302. */
  1303. export abstract class BaseError extends Error {
  1304. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1305. }
  1306. }
  1307. declare module BABYLON {
  1308. /** @ignore */
  1309. export class LoadFileError extends BaseError {
  1310. request?: WebRequest;
  1311. file?: File;
  1312. /**
  1313. * Creates a new LoadFileError
  1314. * @param message defines the message of the error
  1315. * @param request defines the optional web request
  1316. * @param file defines the optional file
  1317. */
  1318. constructor(message: string, object?: WebRequest | File);
  1319. }
  1320. /** @ignore */
  1321. export class RequestFileError extends BaseError {
  1322. request: WebRequest;
  1323. /**
  1324. * Creates a new LoadFileError
  1325. * @param message defines the message of the error
  1326. * @param request defines the optional web request
  1327. */
  1328. constructor(message: string, request: WebRequest);
  1329. }
  1330. /** @ignore */
  1331. export class ReadFileError extends BaseError {
  1332. file: File;
  1333. /**
  1334. * Creates a new ReadFileError
  1335. * @param message defines the message of the error
  1336. * @param file defines the optional file
  1337. */
  1338. constructor(message: string, file: File);
  1339. }
  1340. /**
  1341. * @hidden
  1342. */
  1343. export class FileTools {
  1344. /**
  1345. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1346. */
  1347. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1348. /**
  1349. * Gets or sets the base URL to use to load assets
  1350. */
  1351. static BaseUrl: string;
  1352. /**
  1353. * Default behaviour for cors in the application.
  1354. * It can be a string if the expected behavior is identical in the entire app.
  1355. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1356. */
  1357. static CorsBehavior: string | ((url: string | string[]) => string);
  1358. /**
  1359. * Gets or sets a function used to pre-process url before using them to load assets
  1360. */
  1361. static PreprocessUrl: (url: string) => string;
  1362. /**
  1363. * Removes unwanted characters from an url
  1364. * @param url defines the url to clean
  1365. * @returns the cleaned url
  1366. */
  1367. private static _CleanUrl;
  1368. /**
  1369. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1370. * @param url define the url we are trying
  1371. * @param element define the dom element where to configure the cors policy
  1372. */
  1373. static SetCorsBehavior(url: string | string[], element: {
  1374. crossOrigin: string | null;
  1375. }): void;
  1376. /**
  1377. * Loads an image as an HTMLImageElement.
  1378. * @param input url string, ArrayBuffer, or Blob to load
  1379. * @param onLoad callback called when the image successfully loads
  1380. * @param onError callback called when the image fails to load
  1381. * @param offlineProvider offline provider for caching
  1382. * @param mimeType optional mime type
  1383. * @returns the HTMLImageElement of the loaded image
  1384. */
  1385. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1386. /**
  1387. * Reads a file from a File object
  1388. * @param file defines the file to load
  1389. * @param onSuccess defines the callback to call when data is loaded
  1390. * @param onProgress defines the callback to call during loading process
  1391. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1392. * @param onError defines the callback to call when an error occurs
  1393. * @returns a file request object
  1394. */
  1395. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1396. /**
  1397. * Loads a file from a url
  1398. * @param url url to load
  1399. * @param onSuccess callback called when the file successfully loads
  1400. * @param onProgress callback called while file is loading (if the server supports this mode)
  1401. * @param offlineProvider defines the offline provider for caching
  1402. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1403. * @param onError callback called when the file fails to load
  1404. * @returns a file request object
  1405. */
  1406. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1407. /**
  1408. * Loads a file
  1409. * @param url url to load
  1410. * @param onSuccess callback called when the file successfully loads
  1411. * @param onProgress callback called while file is loading (if the server supports this mode)
  1412. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1413. * @param onError callback called when the file fails to load
  1414. * @param onOpened callback called when the web request is opened
  1415. * @returns a file request object
  1416. */
  1417. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1418. /**
  1419. * Checks if the loaded document was accessed via `file:`-Protocol.
  1420. * @returns boolean
  1421. */
  1422. static IsFileURL(): boolean;
  1423. }
  1424. }
  1425. declare module BABYLON {
  1426. /** @hidden */
  1427. export class ShaderProcessor {
  1428. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1429. private static _ProcessPrecision;
  1430. private static _ExtractOperation;
  1431. private static _BuildSubExpression;
  1432. private static _BuildExpression;
  1433. private static _MoveCursorWithinIf;
  1434. private static _MoveCursor;
  1435. private static _EvaluatePreProcessors;
  1436. private static _PreparePreProcessors;
  1437. private static _ProcessShaderConversion;
  1438. private static _ProcessIncludes;
  1439. /**
  1440. * Loads a file from a url
  1441. * @param url url to load
  1442. * @param onSuccess callback called when the file successfully loads
  1443. * @param onProgress callback called while file is loading (if the server supports this mode)
  1444. * @param offlineProvider defines the offline provider for caching
  1445. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1446. * @param onError callback called when the file fails to load
  1447. * @returns a file request object
  1448. * @hidden
  1449. */
  1450. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1451. }
  1452. }
  1453. declare module BABYLON {
  1454. /**
  1455. * @hidden
  1456. */
  1457. export interface IColor4Like {
  1458. r: float;
  1459. g: float;
  1460. b: float;
  1461. a: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IColor3Like {
  1467. r: float;
  1468. g: float;
  1469. b: float;
  1470. }
  1471. /**
  1472. * @hidden
  1473. */
  1474. export interface IVector4Like {
  1475. x: float;
  1476. y: float;
  1477. z: float;
  1478. w: float;
  1479. }
  1480. /**
  1481. * @hidden
  1482. */
  1483. export interface IVector3Like {
  1484. x: float;
  1485. y: float;
  1486. z: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IVector2Like {
  1492. x: float;
  1493. y: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IMatrixLike {
  1499. toArray(): DeepImmutable<Float32Array>;
  1500. updateFlag: int;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IViewportLike {
  1506. x: float;
  1507. y: float;
  1508. width: float;
  1509. height: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IPlaneLike {
  1515. normal: IVector3Like;
  1516. d: float;
  1517. normalize(): void;
  1518. }
  1519. }
  1520. declare module BABYLON {
  1521. /**
  1522. * Interface used to define common properties for effect fallbacks
  1523. */
  1524. export interface IEffectFallbacks {
  1525. /**
  1526. * Removes the defines that should be removed when falling back.
  1527. * @param currentDefines defines the current define statements for the shader.
  1528. * @param effect defines the current effect we try to compile
  1529. * @returns The resulting defines with defines of the current rank removed.
  1530. */
  1531. reduce(currentDefines: string, effect: Effect): string;
  1532. /**
  1533. * Removes the fallback from the bound mesh.
  1534. */
  1535. unBindMesh(): void;
  1536. /**
  1537. * Checks to see if more fallbacks are still availible.
  1538. */
  1539. hasMoreFallbacks: boolean;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /**
  1544. * Class used to evalaute queries containing `and` and `or` operators
  1545. */
  1546. export class AndOrNotEvaluator {
  1547. /**
  1548. * Evaluate a query
  1549. * @param query defines the query to evaluate
  1550. * @param evaluateCallback defines the callback used to filter result
  1551. * @returns true if the query matches
  1552. */
  1553. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1554. private static _HandleParenthesisContent;
  1555. private static _SimplifyNegation;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to store custom tags
  1561. */
  1562. export class Tags {
  1563. /**
  1564. * Adds support for tags on the given object
  1565. * @param obj defines the object to use
  1566. */
  1567. static EnableFor(obj: any): void;
  1568. /**
  1569. * Removes tags support
  1570. * @param obj defines the object to use
  1571. */
  1572. static DisableFor(obj: any): void;
  1573. /**
  1574. * Gets a boolean indicating if the given object has tags
  1575. * @param obj defines the object to use
  1576. * @returns a boolean
  1577. */
  1578. static HasTags(obj: any): boolean;
  1579. /**
  1580. * Gets the tags available on a given object
  1581. * @param obj defines the object to use
  1582. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1583. * @returns the tags
  1584. */
  1585. static GetTags(obj: any, asString?: boolean): any;
  1586. /**
  1587. * Adds tags to an object
  1588. * @param obj defines the object to use
  1589. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1590. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1591. */
  1592. static AddTagsTo(obj: any, tagsString: string): void;
  1593. /**
  1594. * @hidden
  1595. */
  1596. static _AddTagTo(obj: any, tag: string): void;
  1597. /**
  1598. * Removes specific tags from a specific object
  1599. * @param obj defines the object to use
  1600. * @param tagsString defines the tags to remove
  1601. */
  1602. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1603. /**
  1604. * @hidden
  1605. */
  1606. static _RemoveTagFrom(obj: any, tag: string): void;
  1607. /**
  1608. * Defines if tags hosted on an object match a given query
  1609. * @param obj defines the object to use
  1610. * @param tagsQuery defines the tag query
  1611. * @returns a boolean
  1612. */
  1613. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1614. }
  1615. }
  1616. declare module BABYLON {
  1617. /**
  1618. * Scalar computation library
  1619. */
  1620. export class Scalar {
  1621. /**
  1622. * Two pi constants convenient for computation.
  1623. */
  1624. static TwoPi: number;
  1625. /**
  1626. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1627. * @param a number
  1628. * @param b number
  1629. * @param epsilon (default = 1.401298E-45)
  1630. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1631. */
  1632. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1633. /**
  1634. * Returns a string : the upper case translation of the number i to hexadecimal.
  1635. * @param i number
  1636. * @returns the upper case translation of the number i to hexadecimal.
  1637. */
  1638. static ToHex(i: number): string;
  1639. /**
  1640. * Returns -1 if value is negative and +1 is value is positive.
  1641. * @param value the value
  1642. * @returns the value itself if it's equal to zero.
  1643. */
  1644. static Sign(value: number): number;
  1645. /**
  1646. * Returns the value itself if it's between min and max.
  1647. * Returns min if the value is lower than min.
  1648. * Returns max if the value is greater than max.
  1649. * @param value the value to clmap
  1650. * @param min the min value to clamp to (default: 0)
  1651. * @param max the max value to clamp to (default: 1)
  1652. * @returns the clamped value
  1653. */
  1654. static Clamp(value: number, min?: number, max?: number): number;
  1655. /**
  1656. * the log2 of value.
  1657. * @param value the value to compute log2 of
  1658. * @returns the log2 of value.
  1659. */
  1660. static Log2(value: number): number;
  1661. /**
  1662. * Loops the value, so that it is never larger than length and never smaller than 0.
  1663. *
  1664. * This is similar to the modulo operator but it works with floating point numbers.
  1665. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1666. * With t = 5 and length = 2.5, the result would be 0.0.
  1667. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1668. * @param value the value
  1669. * @param length the length
  1670. * @returns the looped value
  1671. */
  1672. static Repeat(value: number, length: number): number;
  1673. /**
  1674. * Normalize the value between 0.0 and 1.0 using min and max values
  1675. * @param value value to normalize
  1676. * @param min max to normalize between
  1677. * @param max min to normalize between
  1678. * @returns the normalized value
  1679. */
  1680. static Normalize(value: number, min: number, max: number): number;
  1681. /**
  1682. * Denormalize the value from 0.0 and 1.0 using min and max values
  1683. * @param normalized value to denormalize
  1684. * @param min max to denormalize between
  1685. * @param max min to denormalize between
  1686. * @returns the denormalized value
  1687. */
  1688. static Denormalize(normalized: number, min: number, max: number): number;
  1689. /**
  1690. * Calculates the shortest difference between two given angles given in degrees.
  1691. * @param current current angle in degrees
  1692. * @param target target angle in degrees
  1693. * @returns the delta
  1694. */
  1695. static DeltaAngle(current: number, target: number): number;
  1696. /**
  1697. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1698. * @param tx value
  1699. * @param length length
  1700. * @returns The returned value will move back and forth between 0 and length
  1701. */
  1702. static PingPong(tx: number, length: number): number;
  1703. /**
  1704. * Interpolates between min and max with smoothing at the limits.
  1705. *
  1706. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1707. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1708. * @param from from
  1709. * @param to to
  1710. * @param tx value
  1711. * @returns the smooth stepped value
  1712. */
  1713. static SmoothStep(from: number, to: number, tx: number): number;
  1714. /**
  1715. * Moves a value current towards target.
  1716. *
  1717. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1718. * Negative values of maxDelta pushes the value away from target.
  1719. * @param current current value
  1720. * @param target target value
  1721. * @param maxDelta max distance to move
  1722. * @returns resulting value
  1723. */
  1724. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1725. /**
  1726. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1727. *
  1728. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1729. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1730. * @param current current value
  1731. * @param target target value
  1732. * @param maxDelta max distance to move
  1733. * @returns resulting angle
  1734. */
  1735. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1736. /**
  1737. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1738. * @param start start value
  1739. * @param end target value
  1740. * @param amount amount to lerp between
  1741. * @returns the lerped value
  1742. */
  1743. static Lerp(start: number, end: number, amount: number): number;
  1744. /**
  1745. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1746. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1747. * @param start start value
  1748. * @param end target value
  1749. * @param amount amount to lerp between
  1750. * @returns the lerped value
  1751. */
  1752. static LerpAngle(start: number, end: number, amount: number): number;
  1753. /**
  1754. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1755. * @param a start value
  1756. * @param b target value
  1757. * @param value value between a and b
  1758. * @returns the inverseLerp value
  1759. */
  1760. static InverseLerp(a: number, b: number, value: number): number;
  1761. /**
  1762. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1763. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1764. * @param value1 spline value
  1765. * @param tangent1 spline value
  1766. * @param value2 spline value
  1767. * @param tangent2 spline value
  1768. * @param amount input value
  1769. * @returns hermite result
  1770. */
  1771. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1772. /**
  1773. * Returns a random float number between and min and max values
  1774. * @param min min value of random
  1775. * @param max max value of random
  1776. * @returns random value
  1777. */
  1778. static RandomRange(min: number, max: number): number;
  1779. /**
  1780. * This function returns percentage of a number in a given range.
  1781. *
  1782. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1783. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1784. * @param number to convert to percentage
  1785. * @param min min range
  1786. * @param max max range
  1787. * @returns the percentage
  1788. */
  1789. static RangeToPercent(number: number, min: number, max: number): number;
  1790. /**
  1791. * This function returns number that corresponds to the percentage in a given range.
  1792. *
  1793. * PercentToRange(0.34,0,100) will return 34.
  1794. * @param percent to convert to number
  1795. * @param min min range
  1796. * @param max max range
  1797. * @returns the number
  1798. */
  1799. static PercentToRange(percent: number, min: number, max: number): number;
  1800. /**
  1801. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1802. * @param angle The angle to normalize in radian.
  1803. * @return The converted angle.
  1804. */
  1805. static NormalizeRadians(angle: number): number;
  1806. }
  1807. }
  1808. declare module BABYLON {
  1809. /**
  1810. * Constant used to convert a value to gamma space
  1811. * @ignorenaming
  1812. */
  1813. export const ToGammaSpace: number;
  1814. /**
  1815. * Constant used to convert a value to linear space
  1816. * @ignorenaming
  1817. */
  1818. export const ToLinearSpace = 2.2;
  1819. /**
  1820. * Constant used to define the minimal number value in Babylon.js
  1821. * @ignorenaming
  1822. */
  1823. let Epsilon: number;
  1824. }
  1825. declare module BABYLON {
  1826. /**
  1827. * Class used to represent a viewport on screen
  1828. */
  1829. export class Viewport {
  1830. /** viewport left coordinate */
  1831. x: number;
  1832. /** viewport top coordinate */
  1833. y: number;
  1834. /**viewport width */
  1835. width: number;
  1836. /** viewport height */
  1837. height: number;
  1838. /**
  1839. * Creates a Viewport object located at (x, y) and sized (width, height)
  1840. * @param x defines viewport left coordinate
  1841. * @param y defines viewport top coordinate
  1842. * @param width defines the viewport width
  1843. * @param height defines the viewport height
  1844. */
  1845. constructor(
  1846. /** viewport left coordinate */
  1847. x: number,
  1848. /** viewport top coordinate */
  1849. y: number,
  1850. /**viewport width */
  1851. width: number,
  1852. /** viewport height */
  1853. height: number);
  1854. /**
  1855. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1856. * @param renderWidth defines the rendering width
  1857. * @param renderHeight defines the rendering height
  1858. * @returns a new Viewport
  1859. */
  1860. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1861. /**
  1862. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @param ref defines the target viewport
  1866. * @returns the current viewport
  1867. */
  1868. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1869. /**
  1870. * Returns a new Viewport copied from the current one
  1871. * @returns a new Viewport
  1872. */
  1873. clone(): Viewport;
  1874. }
  1875. }
  1876. declare module BABYLON {
  1877. /**
  1878. * Class containing a set of static utilities functions for arrays.
  1879. */
  1880. export class ArrayTools {
  1881. /**
  1882. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1883. * @param size the number of element to construct and put in the array
  1884. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1885. * @returns a new array filled with new objects
  1886. */
  1887. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1888. }
  1889. }
  1890. declare module BABYLON {
  1891. /**
  1892. * Class representing a vector containing 2 coordinates
  1893. */
  1894. export class Vector2 {
  1895. /** defines the first coordinate */
  1896. x: number;
  1897. /** defines the second coordinate */
  1898. y: number;
  1899. /**
  1900. * Creates a new Vector2 from the given x and y coordinates
  1901. * @param x defines the first coordinate
  1902. * @param y defines the second coordinate
  1903. */
  1904. constructor(
  1905. /** defines the first coordinate */
  1906. x?: number,
  1907. /** defines the second coordinate */
  1908. y?: number);
  1909. /**
  1910. * Gets a string with the Vector2 coordinates
  1911. * @returns a string with the Vector2 coordinates
  1912. */
  1913. toString(): string;
  1914. /**
  1915. * Gets class name
  1916. * @returns the string "Vector2"
  1917. */
  1918. getClassName(): string;
  1919. /**
  1920. * Gets current vector hash code
  1921. * @returns the Vector2 hash code as a number
  1922. */
  1923. getHashCode(): number;
  1924. /**
  1925. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1926. * @param array defines the source array
  1927. * @param index defines the offset in source array
  1928. * @returns the current Vector2
  1929. */
  1930. toArray(array: FloatArray, index?: number): Vector2;
  1931. /**
  1932. * Copy the current vector to an array
  1933. * @returns a new array with 2 elements: the Vector2 coordinates.
  1934. */
  1935. asArray(): number[];
  1936. /**
  1937. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1938. * @param source defines the source Vector2
  1939. * @returns the current updated Vector2
  1940. */
  1941. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1942. /**
  1943. * Sets the Vector2 coordinates with the given floats
  1944. * @param x defines the first coordinate
  1945. * @param y defines the second coordinate
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFromFloats(x: number, y: number): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. set(x: number, y: number): Vector2;
  1956. /**
  1957. * Add another vector with the current one
  1958. * @param otherVector defines the other vector
  1959. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1960. */
  1961. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1962. /**
  1963. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1964. * @param otherVector defines the other vector
  1965. * @param result defines the target vector
  1966. * @returns the unmodified current Vector2
  1967. */
  1968. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1969. /**
  1970. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1971. * @param otherVector defines the other vector
  1972. * @returns the current updated Vector2
  1973. */
  1974. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1975. /**
  1976. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns a new Vector2
  1979. */
  1980. addVector3(otherVector: Vector3): Vector2;
  1981. /**
  1982. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2
  1985. */
  1986. subtract(otherVector: Vector2): Vector2;
  1987. /**
  1988. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1989. * @param otherVector defines the other vector
  1990. * @param result defines the target vector
  1991. * @returns the unmodified current Vector2
  1992. */
  1993. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1994. /**
  1995. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1996. * @param otherVector defines the other vector
  1997. * @returns the current updated Vector2
  1998. */
  1999. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2000. /**
  2001. * Multiplies in place the current Vector2 coordinates by the given ones
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2012. /**
  2013. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2021. * @param x defines the first coordinate
  2022. * @param y defines the second coordinate
  2023. * @returns a new Vector2
  2024. */
  2025. multiplyByFloats(x: number, y: number): Vector2;
  2026. /**
  2027. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2028. * @param otherVector defines the other vector
  2029. * @returns a new Vector2
  2030. */
  2031. divide(otherVector: Vector2): Vector2;
  2032. /**
  2033. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2034. * @param otherVector defines the other vector
  2035. * @param result defines the target vector
  2036. * @returns the unmodified current Vector2
  2037. */
  2038. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2039. /**
  2040. * Divides the current Vector2 coordinates by the given ones
  2041. * @param otherVector defines the other vector
  2042. * @returns the current updated Vector2
  2043. */
  2044. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2045. /**
  2046. * Gets a new Vector2 with current Vector2 negated coordinates
  2047. * @returns a new Vector2
  2048. */
  2049. negate(): Vector2;
  2050. /**
  2051. * Negate this vector in place
  2052. * @returns this
  2053. */
  2054. negateInPlace(): Vector2;
  2055. /**
  2056. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2057. * @param result defines the Vector3 object where to store the result
  2058. * @returns the current Vector2
  2059. */
  2060. negateToRef(result: Vector2): Vector2;
  2061. /**
  2062. * Multiply the Vector2 coordinates by scale
  2063. * @param scale defines the scaling factor
  2064. * @returns the current updated Vector2
  2065. */
  2066. scaleInPlace(scale: number): Vector2;
  2067. /**
  2068. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2069. * @param scale defines the scaling factor
  2070. * @returns a new Vector2
  2071. */
  2072. scale(scale: number): Vector2;
  2073. /**
  2074. * Scale the current Vector2 values by a factor to a given Vector2
  2075. * @param scale defines the scale factor
  2076. * @param result defines the Vector2 object where to store the result
  2077. * @returns the unmodified current Vector2
  2078. */
  2079. scaleToRef(scale: number, result: Vector2): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Gets a boolean if two vectors are equals
  2089. * @param otherVector defines the other vector
  2090. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2091. */
  2092. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2093. /**
  2094. * Gets a boolean if two vectors are equals (using an epsilon value)
  2095. * @param otherVector defines the other vector
  2096. * @param epsilon defines the minimal distance to consider equality
  2097. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2098. */
  2099. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. floor(): Vector2;
  2105. /**
  2106. * Gets a new Vector2 from current Vector2 floored values
  2107. * @returns a new Vector2
  2108. */
  2109. fract(): Vector2;
  2110. /**
  2111. * Gets the length of the vector
  2112. * @returns the vector length (float)
  2113. */
  2114. length(): number;
  2115. /**
  2116. * Gets the vector squared length
  2117. * @returns the vector squared length (float)
  2118. */
  2119. lengthSquared(): number;
  2120. /**
  2121. * Normalize the vector
  2122. * @returns the current updated Vector2
  2123. */
  2124. normalize(): Vector2;
  2125. /**
  2126. * Gets a new Vector2 copied from the Vector2
  2127. * @returns a new Vector2
  2128. */
  2129. clone(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(0, 0)
  2132. * @returns a new Vector2
  2133. */
  2134. static Zero(): Vector2;
  2135. /**
  2136. * Gets a new Vector2(1, 1)
  2137. * @returns a new Vector2
  2138. */
  2139. static One(): Vector2;
  2140. /**
  2141. * Gets a new Vector2 set from the given index element of the given array
  2142. * @param array defines the data source
  2143. * @param offset defines the offset in the data source
  2144. * @returns a new Vector2
  2145. */
  2146. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2147. /**
  2148. * Sets "result" from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @param result defines the target vector
  2152. */
  2153. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2154. /**
  2155. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2156. * @param value1 defines 1st point of control
  2157. * @param value2 defines 2nd point of control
  2158. * @param value3 defines 3rd point of control
  2159. * @param value4 defines 4th point of control
  2160. * @param amount defines the interpolation factor
  2161. * @returns a new Vector2
  2162. */
  2163. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2164. /**
  2165. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2166. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2167. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2168. * @param value defines the value to clamp
  2169. * @param min defines the lower limit
  2170. * @param max defines the upper limit
  2171. * @returns a new Vector2
  2172. */
  2173. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2176. * @param value1 defines the 1st control point
  2177. * @param tangent1 defines the outgoing tangent
  2178. * @param value2 defines the 2nd control point
  2179. * @param tangent2 defines the incoming tangent
  2180. * @param amount defines the interpolation factor
  2181. * @returns a new Vector2
  2182. */
  2183. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2184. /**
  2185. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2186. * @param start defines the start vector
  2187. * @param end defines the end vector
  2188. * @param amount defines the interpolation factor
  2189. * @returns a new Vector2
  2190. */
  2191. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2192. /**
  2193. * Gets the dot product of the vector "left" and the vector "right"
  2194. * @param left defines first vector
  2195. * @param right defines second vector
  2196. * @returns the dot product (float)
  2197. */
  2198. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2199. /**
  2200. * Returns a new Vector2 equal to the normalized given vector
  2201. * @param vector defines the vector to normalize
  2202. * @returns a new Vector2
  2203. */
  2204. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2207. * @param left defines 1st vector
  2208. * @param right defines 2nd vector
  2209. * @returns a new Vector2
  2210. */
  2211. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2221. * @param vector defines the vector to transform
  2222. * @param transformation defines the matrix to apply
  2223. * @returns a new Vector2
  2224. */
  2225. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2226. /**
  2227. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @param result defines the target vector
  2231. */
  2232. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2233. /**
  2234. * Determines if a given vector is included in a triangle
  2235. * @param p defines the vector to test
  2236. * @param p0 defines 1st triangle point
  2237. * @param p1 defines 2nd triangle point
  2238. * @param p2 defines 3rd triangle point
  2239. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2240. */
  2241. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2242. /**
  2243. * Gets the distance between the vectors "value1" and "value2"
  2244. * @param value1 defines first vector
  2245. * @param value2 defines second vector
  2246. * @returns the distance between vectors
  2247. */
  2248. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2249. /**
  2250. * Returns the squared distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the squared distance between vectors
  2254. */
  2255. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns a new Vector2
  2261. */
  2262. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2263. /**
  2264. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2265. * @param p defines the middle point
  2266. * @param segA defines one point of the segment
  2267. * @param segB defines the other point of the segment
  2268. * @returns the shortest distance
  2269. */
  2270. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2271. }
  2272. /**
  2273. * Class used to store (x,y,z) vector representation
  2274. * A Vector3 is the main object used in 3D geometry
  2275. * It can represent etiher the coordinates of a point the space, either a direction
  2276. * Reminder: js uses a left handed forward facing system
  2277. */
  2278. export class Vector3 {
  2279. /**
  2280. * Defines the first coordinates (on X axis)
  2281. */
  2282. x: number;
  2283. /**
  2284. * Defines the second coordinates (on Y axis)
  2285. */
  2286. y: number;
  2287. /**
  2288. * Defines the third coordinates (on Z axis)
  2289. */
  2290. z: number;
  2291. private static _UpReadOnly;
  2292. private static _ZeroReadOnly;
  2293. /**
  2294. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2295. * @param x defines the first coordinates (on X axis)
  2296. * @param y defines the second coordinates (on Y axis)
  2297. * @param z defines the third coordinates (on Z axis)
  2298. */
  2299. constructor(
  2300. /**
  2301. * Defines the first coordinates (on X axis)
  2302. */
  2303. x?: number,
  2304. /**
  2305. * Defines the second coordinates (on Y axis)
  2306. */
  2307. y?: number,
  2308. /**
  2309. * Defines the third coordinates (on Z axis)
  2310. */
  2311. z?: number);
  2312. /**
  2313. * Creates a string representation of the Vector3
  2314. * @returns a string with the Vector3 coordinates.
  2315. */
  2316. toString(): string;
  2317. /**
  2318. * Gets the class name
  2319. * @returns the string "Vector3"
  2320. */
  2321. getClassName(): string;
  2322. /**
  2323. * Creates the Vector3 hash code
  2324. * @returns a number which tends to be unique between Vector3 instances
  2325. */
  2326. getHashCode(): number;
  2327. /**
  2328. * Creates an array containing three elements : the coordinates of the Vector3
  2329. * @returns a new array of numbers
  2330. */
  2331. asArray(): number[];
  2332. /**
  2333. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2334. * @param array defines the destination array
  2335. * @param index defines the offset in the destination array
  2336. * @returns the current Vector3
  2337. */
  2338. toArray(array: FloatArray, index?: number): Vector3;
  2339. /**
  2340. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2341. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2342. */
  2343. toQuaternion(): Quaternion;
  2344. /**
  2345. * Adds the given vector to the current Vector3
  2346. * @param otherVector defines the second operand
  2347. * @returns the current updated Vector3
  2348. */
  2349. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2350. /**
  2351. * Adds the given coordinates to the current Vector3
  2352. * @param x defines the x coordinate of the operand
  2353. * @param y defines the y coordinate of the operand
  2354. * @param z defines the z coordinate of the operand
  2355. * @returns the current updated Vector3
  2356. */
  2357. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2358. /**
  2359. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2360. * @param otherVector defines the second operand
  2361. * @returns the resulting Vector3
  2362. */
  2363. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2366. * @param otherVector defines the second operand
  2367. * @param result defines the Vector3 object where to store the result
  2368. * @returns the current Vector3
  2369. */
  2370. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2371. /**
  2372. * Subtract the given vector from the current Vector3
  2373. * @param otherVector defines the second operand
  2374. * @returns the current updated Vector3
  2375. */
  2376. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2377. /**
  2378. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2379. * @param otherVector defines the second operand
  2380. * @returns the resulting Vector3
  2381. */
  2382. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2383. /**
  2384. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2385. * @param otherVector defines the second operand
  2386. * @param result defines the Vector3 object where to store the result
  2387. * @returns the current Vector3
  2388. */
  2389. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2390. /**
  2391. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the resulting Vector3
  2396. */
  2397. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the current Vector3
  2405. */
  2406. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2407. /**
  2408. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2409. * @returns a new Vector3
  2410. */
  2411. negate(): Vector3;
  2412. /**
  2413. * Negate this vector in place
  2414. * @returns this
  2415. */
  2416. negateInPlace(): Vector3;
  2417. /**
  2418. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. negateToRef(result: Vector3): Vector3;
  2423. /**
  2424. * Multiplies the Vector3 coordinates by the float "scale"
  2425. * @param scale defines the multiplier factor
  2426. * @returns the current updated Vector3
  2427. */
  2428. scaleInPlace(scale: number): Vector3;
  2429. /**
  2430. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2431. * @param scale defines the multiplier factor
  2432. * @returns a new Vector3
  2433. */
  2434. scale(scale: number): Vector3;
  2435. /**
  2436. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2437. * @param scale defines the multiplier factor
  2438. * @param result defines the Vector3 object where to store the result
  2439. * @returns the current Vector3
  2440. */
  2441. scaleToRef(scale: number, result: Vector3): Vector3;
  2442. /**
  2443. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2444. * @param scale defines the scale factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the unmodified current Vector3
  2447. */
  2448. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2451. * @param otherVector defines the second operand
  2452. * @returns true if both vectors are equals
  2453. */
  2454. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2455. /**
  2456. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2457. * @param otherVector defines the second operand
  2458. * @param epsilon defines the minimal distance to define values as equals
  2459. * @returns true if both vectors are distant less than epsilon
  2460. */
  2461. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 coordinates equals the given floats
  2464. * @param x defines the x coordinate of the operand
  2465. * @param y defines the y coordinate of the operand
  2466. * @param z defines the z coordinate of the operand
  2467. * @returns true if both vectors are equals
  2468. */
  2469. equalsToFloats(x: number, y: number, z: number): boolean;
  2470. /**
  2471. * Multiplies the current Vector3 coordinates by the given ones
  2472. * @param otherVector defines the second operand
  2473. * @returns the current updated Vector3
  2474. */
  2475. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2476. /**
  2477. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2478. * @param otherVector defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2484. * @param otherVector defines the second operand
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the current Vector3
  2487. */
  2488. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2489. /**
  2490. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2491. * @param x defines the x coordinate of the operand
  2492. * @param y defines the y coordinate of the operand
  2493. * @param z defines the z coordinate of the operand
  2494. * @returns the new Vector3
  2495. */
  2496. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2497. /**
  2498. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2499. * @param otherVector defines the second operand
  2500. * @returns the new Vector3
  2501. */
  2502. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2503. /**
  2504. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2505. * @param otherVector defines the second operand
  2506. * @param result defines the Vector3 object where to store the result
  2507. * @returns the current Vector3
  2508. */
  2509. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones.
  2512. * @param otherVector defines the second operand
  2513. * @returns the current updated Vector3
  2514. */
  2515. divideInPlace(otherVector: Vector3): Vector3;
  2516. /**
  2517. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2518. * @param other defines the second operand
  2519. * @returns the current updated Vector3
  2520. */
  2521. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2524. * @param other defines the second operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2528. /**
  2529. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2530. * @param x defines the x coordinate of the operand
  2531. * @param y defines the y coordinate of the operand
  2532. * @param z defines the z coordinate of the operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2546. * Check if is non uniform within a certain amount of decimal places to account for this
  2547. * @param epsilon the amount the values can differ
  2548. * @returns if the the vector is non uniform to a certain number of decimal places
  2549. */
  2550. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2551. /**
  2552. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2553. */
  2554. get isNonUniform(): boolean;
  2555. /**
  2556. * Gets a new Vector3 from current Vector3 floored values
  2557. * @returns a new Vector3
  2558. */
  2559. floor(): Vector3;
  2560. /**
  2561. * Gets a new Vector3 from current Vector3 floored values
  2562. * @returns a new Vector3
  2563. */
  2564. fract(): Vector3;
  2565. /**
  2566. * Gets the length of the Vector3
  2567. * @returns the length of the Vector3
  2568. */
  2569. length(): number;
  2570. /**
  2571. * Gets the squared length of the Vector3
  2572. * @returns squared length of the Vector3
  2573. */
  2574. lengthSquared(): number;
  2575. /**
  2576. * Normalize the current Vector3.
  2577. * Please note that this is an in place operation.
  2578. * @returns the current updated Vector3
  2579. */
  2580. normalize(): Vector3;
  2581. /**
  2582. * Reorders the x y z properties of the vector in place
  2583. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2584. * @returns the current updated vector
  2585. */
  2586. reorderInPlace(order: string): this;
  2587. /**
  2588. * Rotates the vector around 0,0,0 by a quaternion
  2589. * @param quaternion the rotation quaternion
  2590. * @param result vector to store the result
  2591. * @returns the resulting vector
  2592. */
  2593. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2594. /**
  2595. * Rotates a vector around a given point
  2596. * @param quaternion the rotation quaternion
  2597. * @param point the point to rotate around
  2598. * @param result vector to store the result
  2599. * @returns the resulting vector
  2600. */
  2601. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2602. /**
  2603. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2604. * The cross product is then orthogonal to both current and "other"
  2605. * @param other defines the right operand
  2606. * @returns the cross product
  2607. */
  2608. cross(other: Vector3): Vector3;
  2609. /**
  2610. * Normalize the current Vector3 with the given input length.
  2611. * Please note that this is an in place operation.
  2612. * @param len the length of the vector
  2613. * @returns the current updated Vector3
  2614. */
  2615. normalizeFromLength(len: number): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 to a new vector
  2618. * @returns the new Vector3
  2619. */
  2620. normalizeToNew(): Vector3;
  2621. /**
  2622. * Normalize the current Vector3 to the reference
  2623. * @param reference define the Vector3 to update
  2624. * @returns the updated Vector3
  2625. */
  2626. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2627. /**
  2628. * Creates a new Vector3 copied from the current Vector3
  2629. * @returns the new Vector3
  2630. */
  2631. clone(): Vector3;
  2632. /**
  2633. * Copies the given vector coordinates to the current Vector3 ones
  2634. * @param source defines the source Vector3
  2635. * @returns the current updated Vector3
  2636. */
  2637. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2638. /**
  2639. * Copies the given floats to the current Vector3 coordinates
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @returns the current updated Vector3
  2644. */
  2645. copyFromFloats(x: number, y: number, z: number): Vector3;
  2646. /**
  2647. * Copies the given floats to the current Vector3 coordinates
  2648. * @param x defines the x coordinate of the operand
  2649. * @param y defines the y coordinate of the operand
  2650. * @param z defines the z coordinate of the operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. set(x: number, y: number, z: number): Vector3;
  2654. /**
  2655. * Copies the given float to the current Vector3 coordinates
  2656. * @param v defines the x, y and z coordinates of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. setAll(v: number): Vector3;
  2660. /**
  2661. * Get the clip factor between two vectors
  2662. * @param vector0 defines the first operand
  2663. * @param vector1 defines the second operand
  2664. * @param axis defines the axis to use
  2665. * @param size defines the size along the axis
  2666. * @returns the clip factor
  2667. */
  2668. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2669. /**
  2670. * Get angle between two vectors
  2671. * @param vector0 angle between vector0 and vector1
  2672. * @param vector1 angle between vector0 and vector1
  2673. * @param normal direction of the normal
  2674. * @return the angle between vector0 and vector1
  2675. */
  2676. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2677. /**
  2678. * Returns a new Vector3 set from the index "offset" of the given array
  2679. * @param array defines the source array
  2680. * @param offset defines the offset in the source array
  2681. * @returns the new Vector3
  2682. */
  2683. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. * @deprecated Please use FromArray instead.
  2690. */
  2691. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2692. /**
  2693. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2694. * @param array defines the source array
  2695. * @param offset defines the offset in the source array
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. * @deprecated Please use FromArrayToRef instead.
  2705. */
  2706. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2707. /**
  2708. * Sets the given vector "result" with the given floats.
  2709. * @param x defines the x coordinate of the source
  2710. * @param y defines the y coordinate of the source
  2711. * @param z defines the z coordinate of the source
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2715. /**
  2716. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2717. * @returns a new empty Vector3
  2718. */
  2719. static Zero(): Vector3;
  2720. /**
  2721. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2722. * @returns a new unit Vector3
  2723. */
  2724. static One(): Vector3;
  2725. /**
  2726. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2727. * @returns a new up Vector3
  2728. */
  2729. static Up(): Vector3;
  2730. /**
  2731. * Gets a up Vector3 that must not be updated
  2732. */
  2733. static get UpReadOnly(): DeepImmutable<Vector3>;
  2734. /**
  2735. * Gets a zero Vector3 that must not be updated
  2736. */
  2737. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2738. /**
  2739. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2740. * @returns a new down Vector3
  2741. */
  2742. static Down(): Vector3;
  2743. /**
  2744. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2745. * @returns a new forward Vector3
  2746. */
  2747. static Forward(): Vector3;
  2748. /**
  2749. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2750. * @returns a new forward Vector3
  2751. */
  2752. static Backward(): Vector3;
  2753. /**
  2754. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2755. * @returns a new right Vector3
  2756. */
  2757. static Right(): Vector3;
  2758. /**
  2759. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2760. * @returns a new left Vector3
  2761. */
  2762. static Left(): Vector3;
  2763. /**
  2764. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2765. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2766. * @param vector defines the Vector3 to transform
  2767. * @param transformation defines the transformation matrix
  2768. * @returns the transformed Vector3
  2769. */
  2770. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2771. /**
  2772. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2773. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2774. * @param vector defines the Vector3 to transform
  2775. * @param transformation defines the transformation matrix
  2776. * @param result defines the Vector3 where to store the result
  2777. */
  2778. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2779. /**
  2780. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2781. * This method computes tranformed coordinates only, not transformed direction vectors
  2782. * @param x define the x coordinate of the source vector
  2783. * @param y define the y coordinate of the source vector
  2784. * @param z define the z coordinate of the source vector
  2785. * @param transformation defines the transformation matrix
  2786. * @param result defines the Vector3 where to store the result
  2787. */
  2788. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2789. /**
  2790. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2792. * @param vector defines the Vector3 to transform
  2793. * @param transformation defines the transformation matrix
  2794. * @returns the new Vector3
  2795. */
  2796. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2797. /**
  2798. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2799. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2800. * @param vector defines the Vector3 to transform
  2801. * @param transformation defines the transformation matrix
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2805. /**
  2806. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param x define the x coordinate of the source vector
  2809. * @param y define the y coordinate of the source vector
  2810. * @param z define the z coordinate of the source vector
  2811. * @param transformation defines the transformation matrix
  2812. * @param result defines the Vector3 where to store the result
  2813. */
  2814. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2815. /**
  2816. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2817. * @param value1 defines the first control point
  2818. * @param value2 defines the second control point
  2819. * @param value3 defines the third control point
  2820. * @param value4 defines the fourth control point
  2821. * @param amount defines the amount on the spline to use
  2822. * @returns the new Vector3
  2823. */
  2824. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2825. /**
  2826. * 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"
  2827. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2828. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2829. * @param value defines the current value
  2830. * @param min defines the lower range value
  2831. * @param max defines the upper range value
  2832. * @returns the new Vector3
  2833. */
  2834. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2835. /**
  2836. * 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"
  2837. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2838. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2839. * @param value defines the current value
  2840. * @param min defines the lower range value
  2841. * @param max defines the upper range value
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2845. /**
  2846. * Checks if a given vector is inside a specific range
  2847. * @param v defines the vector to test
  2848. * @param min defines the minimum range
  2849. * @param max defines the maximum range
  2850. */
  2851. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2852. /**
  2853. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2854. * @param value1 defines the first control point
  2855. * @param tangent1 defines the first tangent vector
  2856. * @param value2 defines the second control point
  2857. * @param tangent2 defines the second tangent vector
  2858. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2859. * @returns the new Vector3
  2860. */
  2861. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2862. /**
  2863. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2864. * @param start defines the start value
  2865. * @param end defines the end value
  2866. * @param amount max defines amount between both (between 0 and 1)
  2867. * @returns the new Vector3
  2868. */
  2869. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2870. /**
  2871. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2872. * @param start defines the start value
  2873. * @param end defines the end value
  2874. * @param amount max defines amount between both (between 0 and 1)
  2875. * @param result defines the Vector3 where to store the result
  2876. */
  2877. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2878. /**
  2879. * Returns the dot product (float) between the vectors "left" and "right"
  2880. * @param left defines the left operand
  2881. * @param right defines the right operand
  2882. * @returns the dot product
  2883. */
  2884. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2885. /**
  2886. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2887. * The cross product is then orthogonal to both "left" and "right"
  2888. * @param left defines the left operand
  2889. * @param right defines the right operand
  2890. * @returns the cross product
  2891. */
  2892. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2893. /**
  2894. * Sets the given vector "result" with the cross product of "left" and "right"
  2895. * The cross product is then orthogonal to both "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @param result defines the Vector3 where to store the result
  2899. */
  2900. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2901. /**
  2902. * Returns a new Vector3 as the normalization of the given vector
  2903. * @param vector defines the Vector3 to normalize
  2904. * @returns the new Vector3
  2905. */
  2906. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the normalization of the given first vector
  2909. * @param vector defines the Vector3 to normalize
  2910. * @param result defines the Vector3 where to store the result
  2911. */
  2912. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2913. /**
  2914. * Project a Vector3 onto screen space
  2915. * @param vector defines the Vector3 to project
  2916. * @param world defines the world matrix to use
  2917. * @param transform defines the transform (view x projection) matrix to use
  2918. * @param viewport defines the screen viewport to use
  2919. * @returns the new Vector3
  2920. */
  2921. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2922. /** @hidden */
  2923. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2924. /**
  2925. * Unproject from screen space to object space
  2926. * @param source defines the screen space Vector3 to use
  2927. * @param viewportWidth defines the current width of the viewport
  2928. * @param viewportHeight defines the current height of the viewport
  2929. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2930. * @param transform defines the transform (view x projection) matrix to use
  2931. * @returns the new Vector3
  2932. */
  2933. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2934. /**
  2935. * Unproject from screen space to object space
  2936. * @param source defines the screen space Vector3 to use
  2937. * @param viewportWidth defines the current width of the viewport
  2938. * @param viewportHeight defines the current height of the viewport
  2939. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2940. * @param view defines the view matrix to use
  2941. * @param projection defines the projection matrix to use
  2942. * @returns the new Vector3
  2943. */
  2944. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param source defines the screen space Vector3 to use
  2948. * @param viewportWidth defines the current width of the viewport
  2949. * @param viewportHeight defines the current height of the viewport
  2950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2951. * @param view defines the view matrix to use
  2952. * @param projection defines the projection matrix to use
  2953. * @param result defines the Vector3 where to store the result
  2954. */
  2955. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2956. /**
  2957. * Unproject from screen space to object space
  2958. * @param sourceX defines the screen space x coordinate to use
  2959. * @param sourceY defines the screen space y coordinate to use
  2960. * @param sourceZ defines the screen space z coordinate to use
  2961. * @param viewportWidth defines the current width of the viewport
  2962. * @param viewportHeight defines the current height of the viewport
  2963. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2964. * @param view defines the view matrix to use
  2965. * @param projection defines the projection matrix to use
  2966. * @param result defines the Vector3 where to store the result
  2967. */
  2968. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2969. /**
  2970. * Gets the minimal coordinate values between two Vector3
  2971. * @param left defines the first operand
  2972. * @param right defines the second operand
  2973. * @returns the new Vector3
  2974. */
  2975. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2976. /**
  2977. * Gets the maximal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Returns the distance between the vectors "value1" and "value2"
  2985. * @param value1 defines the first operand
  2986. * @param value2 defines the second operand
  2987. * @returns the distance
  2988. */
  2989. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2990. /**
  2991. * Returns the squared distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the squared distance
  2995. */
  2996. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns a new Vector3 located at the center between "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the new Vector3
  3002. */
  3003. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3004. /**
  3005. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3006. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3007. * to something in order to rotate it from its local system to the given target system
  3008. * Note: axis1, axis2 and axis3 are normalized during this operation
  3009. * @param axis1 defines the first axis
  3010. * @param axis2 defines the second axis
  3011. * @param axis3 defines the third axis
  3012. * @returns a new Vector3
  3013. */
  3014. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3015. /**
  3016. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3017. * @param axis1 defines the first axis
  3018. * @param axis2 defines the second axis
  3019. * @param axis3 defines the third axis
  3020. * @param ref defines the Vector3 where to store the result
  3021. */
  3022. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3023. }
  3024. /**
  3025. * Vector4 class created for EulerAngle class conversion to Quaternion
  3026. */
  3027. export class Vector4 {
  3028. /** x value of the vector */
  3029. x: number;
  3030. /** y value of the vector */
  3031. y: number;
  3032. /** z value of the vector */
  3033. z: number;
  3034. /** w value of the vector */
  3035. w: number;
  3036. /**
  3037. * Creates a Vector4 object from the given floats.
  3038. * @param x x value of the vector
  3039. * @param y y value of the vector
  3040. * @param z z value of the vector
  3041. * @param w w value of the vector
  3042. */
  3043. constructor(
  3044. /** x value of the vector */
  3045. x: number,
  3046. /** y value of the vector */
  3047. y: number,
  3048. /** z value of the vector */
  3049. z: number,
  3050. /** w value of the vector */
  3051. w: number);
  3052. /**
  3053. * Returns the string with the Vector4 coordinates.
  3054. * @returns a string containing all the vector values
  3055. */
  3056. toString(): string;
  3057. /**
  3058. * Returns the string "Vector4".
  3059. * @returns "Vector4"
  3060. */
  3061. getClassName(): string;
  3062. /**
  3063. * Returns the Vector4 hash code.
  3064. * @returns a unique hash code
  3065. */
  3066. getHashCode(): number;
  3067. /**
  3068. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3069. * @returns the resulting array
  3070. */
  3071. asArray(): number[];
  3072. /**
  3073. * Populates the given array from the given index with the Vector4 coordinates.
  3074. * @param array array to populate
  3075. * @param index index of the array to start at (default: 0)
  3076. * @returns the Vector4.
  3077. */
  3078. toArray(array: FloatArray, index?: number): Vector4;
  3079. /**
  3080. * Adds the given vector to the current Vector4.
  3081. * @param otherVector the vector to add
  3082. * @returns the updated Vector4.
  3083. */
  3084. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3085. /**
  3086. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3087. * @param otherVector the vector to add
  3088. * @returns the resulting vector
  3089. */
  3090. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3091. /**
  3092. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3093. * @param otherVector the vector to add
  3094. * @param result the vector to store the result
  3095. * @returns the current Vector4.
  3096. */
  3097. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3098. /**
  3099. * Subtract in place the given vector from the current Vector4.
  3100. * @param otherVector the vector to subtract
  3101. * @returns the updated Vector4.
  3102. */
  3103. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3104. /**
  3105. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3106. * @param otherVector the vector to add
  3107. * @returns the new vector with the result
  3108. */
  3109. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3110. /**
  3111. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3112. * @param otherVector the vector to subtract
  3113. * @param result the vector to store the result
  3114. * @returns the current Vector4.
  3115. */
  3116. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3117. /**
  3118. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3119. */
  3120. /**
  3121. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3122. * @param x value to subtract
  3123. * @param y value to subtract
  3124. * @param z value to subtract
  3125. * @param w value to subtract
  3126. * @returns new vector containing the result
  3127. */
  3128. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3129. /**
  3130. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3131. * @param x value to subtract
  3132. * @param y value to subtract
  3133. * @param z value to subtract
  3134. * @param w value to subtract
  3135. * @param result the vector to store the result in
  3136. * @returns the current Vector4.
  3137. */
  3138. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3139. /**
  3140. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3141. * @returns a new vector with the negated values
  3142. */
  3143. negate(): Vector4;
  3144. /**
  3145. * Negate this vector in place
  3146. * @returns this
  3147. */
  3148. negateInPlace(): Vector4;
  3149. /**
  3150. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3151. * @param result defines the Vector3 object where to store the result
  3152. * @returns the current Vector4
  3153. */
  3154. negateToRef(result: Vector4): Vector4;
  3155. /**
  3156. * Multiplies the current Vector4 coordinates by scale (float).
  3157. * @param scale the number to scale with
  3158. * @returns the updated Vector4.
  3159. */
  3160. scaleInPlace(scale: number): Vector4;
  3161. /**
  3162. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3163. * @param scale the number to scale with
  3164. * @returns a new vector with the result
  3165. */
  3166. scale(scale: number): Vector4;
  3167. /**
  3168. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3169. * @param scale the number to scale with
  3170. * @param result a vector to store the result in
  3171. * @returns the current Vector4.
  3172. */
  3173. scaleToRef(scale: number, result: Vector4): Vector4;
  3174. /**
  3175. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3176. * @param scale defines the scale factor
  3177. * @param result defines the Vector4 object where to store the result
  3178. * @returns the unmodified current Vector4
  3179. */
  3180. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3183. * @param otherVector the vector to compare against
  3184. * @returns true if they are equal
  3185. */
  3186. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3187. /**
  3188. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3189. * @param otherVector vector to compare against
  3190. * @param epsilon (Default: very small number)
  3191. * @returns true if they are equal
  3192. */
  3193. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3194. /**
  3195. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3196. * @param x x value to compare against
  3197. * @param y y value to compare against
  3198. * @param z z value to compare against
  3199. * @param w w value to compare against
  3200. * @returns true if equal
  3201. */
  3202. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3203. /**
  3204. * Multiplies in place the current Vector4 by the given one.
  3205. * @param otherVector vector to multiple with
  3206. * @returns the updated Vector4.
  3207. */
  3208. multiplyInPlace(otherVector: Vector4): Vector4;
  3209. /**
  3210. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3211. * @param otherVector vector to multiple with
  3212. * @returns resulting new vector
  3213. */
  3214. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3215. /**
  3216. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3217. * @param otherVector vector to multiple with
  3218. * @param result vector to store the result
  3219. * @returns the current Vector4.
  3220. */
  3221. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3222. /**
  3223. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3224. * @param x x value multiply with
  3225. * @param y y value multiply with
  3226. * @param z z value multiply with
  3227. * @param w w value multiply with
  3228. * @returns resulting new vector
  3229. */
  3230. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3231. /**
  3232. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3233. * @param otherVector vector to devide with
  3234. * @returns resulting new vector
  3235. */
  3236. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3237. /**
  3238. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3239. * @param otherVector vector to devide with
  3240. * @param result vector to store the result
  3241. * @returns the current Vector4.
  3242. */
  3243. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3244. /**
  3245. * Divides the current Vector3 coordinates by the given ones.
  3246. * @param otherVector vector to devide with
  3247. * @returns the updated Vector3.
  3248. */
  3249. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3252. * @param other defines the second operand
  3253. * @returns the current updated Vector4
  3254. */
  3255. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3256. /**
  3257. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3258. * @param other defines the second operand
  3259. * @returns the current updated Vector4
  3260. */
  3261. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Gets a new Vector4 from current Vector4 floored values
  3264. * @returns a new Vector4
  3265. */
  3266. floor(): Vector4;
  3267. /**
  3268. * Gets a new Vector4 from current Vector3 floored values
  3269. * @returns a new Vector4
  3270. */
  3271. fract(): Vector4;
  3272. /**
  3273. * Returns the Vector4 length (float).
  3274. * @returns the length
  3275. */
  3276. length(): number;
  3277. /**
  3278. * Returns the Vector4 squared length (float).
  3279. * @returns the length squared
  3280. */
  3281. lengthSquared(): number;
  3282. /**
  3283. * Normalizes in place the Vector4.
  3284. * @returns the updated Vector4.
  3285. */
  3286. normalize(): Vector4;
  3287. /**
  3288. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3289. * @returns this converted to a new vector3
  3290. */
  3291. toVector3(): Vector3;
  3292. /**
  3293. * Returns a new Vector4 copied from the current one.
  3294. * @returns the new cloned vector
  3295. */
  3296. clone(): Vector4;
  3297. /**
  3298. * Updates the current Vector4 with the given one coordinates.
  3299. * @param source the source vector to copy from
  3300. * @returns the updated Vector4.
  3301. */
  3302. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3303. /**
  3304. * Updates the current Vector4 coordinates with the given floats.
  3305. * @param x float to copy from
  3306. * @param y float to copy from
  3307. * @param z float to copy from
  3308. * @param w float to copy from
  3309. * @returns the updated Vector4.
  3310. */
  3311. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3312. /**
  3313. * Updates the current Vector4 coordinates with the given floats.
  3314. * @param x float to set from
  3315. * @param y float to set from
  3316. * @param z float to set from
  3317. * @param w float to set from
  3318. * @returns the updated Vector4.
  3319. */
  3320. set(x: number, y: number, z: number, w: number): Vector4;
  3321. /**
  3322. * Copies the given float to the current Vector3 coordinates
  3323. * @param v defines the x, y, z and w coordinates of the operand
  3324. * @returns the current updated Vector3
  3325. */
  3326. setAll(v: number): Vector4;
  3327. /**
  3328. * Returns a new Vector4 set from the starting index of the given array.
  3329. * @param array the array to pull values from
  3330. * @param offset the offset into the array to start at
  3331. * @returns the new vector
  3332. */
  3333. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3334. /**
  3335. * Updates the given vector "result" from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @param result the vector to store the result in
  3339. */
  3340. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given Float32Array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" coordinates from the given floats.
  3350. * @param x float to set from
  3351. * @param y float to set from
  3352. * @param z float to set from
  3353. * @param w float to set from
  3354. * @param result the vector to the floats in
  3355. */
  3356. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3357. /**
  3358. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3359. * @returns the new vector
  3360. */
  3361. static Zero(): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3364. * @returns the new vector
  3365. */
  3366. static One(): Vector4;
  3367. /**
  3368. * Returns a new normalized Vector4 from the given one.
  3369. * @param vector the vector to normalize
  3370. * @returns the vector
  3371. */
  3372. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3373. /**
  3374. * Updates the given vector "result" from the normalization of the given one.
  3375. * @param vector the vector to normalize
  3376. * @param result the vector to store the result in
  3377. */
  3378. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3379. /**
  3380. * Returns a vector with the minimum values from the left and right vectors
  3381. * @param left left vector to minimize
  3382. * @param right right vector to minimize
  3383. * @returns a new vector with the minimum of the left and right vector values
  3384. */
  3385. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3386. /**
  3387. * Returns a vector with the maximum values from the left and right vectors
  3388. * @param left left vector to maximize
  3389. * @param right right vector to maximize
  3390. * @returns a new vector with the maximum of the left and right vector values
  3391. */
  3392. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns the distance (float) between the vectors "value1" and "value2".
  3395. * @param value1 value to calulate the distance between
  3396. * @param value2 value to calulate the distance between
  3397. * @return the distance between the two vectors
  3398. */
  3399. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3400. /**
  3401. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors squared
  3405. */
  3406. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the center between
  3410. * @param value2 value to calulate the center between
  3411. * @return the center between the two vectors
  3412. */
  3413. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3414. /**
  3415. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3416. * This methods computes transformed normalized direction vectors only.
  3417. * @param vector the vector to transform
  3418. * @param transformation the transformation matrix to apply
  3419. * @returns the new vector
  3420. */
  3421. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3422. /**
  3423. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3424. * This methods computes transformed normalized direction vectors only.
  3425. * @param vector the vector to transform
  3426. * @param transformation the transformation matrix to apply
  3427. * @param result the vector to store the result in
  3428. */
  3429. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param x value to transform
  3434. * @param y value to transform
  3435. * @param z value to transform
  3436. * @param w value to transform
  3437. * @param transformation the transformation matrix to apply
  3438. * @param result the vector to store the results in
  3439. */
  3440. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3441. /**
  3442. * Creates a new Vector4 from a Vector3
  3443. * @param source defines the source data
  3444. * @param w defines the 4th component (default is 0)
  3445. * @returns a new Vector4
  3446. */
  3447. static FromVector3(source: Vector3, w?: number): Vector4;
  3448. }
  3449. /**
  3450. * Class used to store quaternion data
  3451. * @see https://en.wikipedia.org/wiki/Quaternion
  3452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3453. */
  3454. export class Quaternion {
  3455. /** defines the first component (0 by default) */
  3456. x: number;
  3457. /** defines the second component (0 by default) */
  3458. y: number;
  3459. /** defines the third component (0 by default) */
  3460. z: number;
  3461. /** defines the fourth component (1.0 by default) */
  3462. w: number;
  3463. /**
  3464. * Creates a new Quaternion from the given floats
  3465. * @param x defines the first component (0 by default)
  3466. * @param y defines the second component (0 by default)
  3467. * @param z defines the third component (0 by default)
  3468. * @param w defines the fourth component (1.0 by default)
  3469. */
  3470. constructor(
  3471. /** defines the first component (0 by default) */
  3472. x?: number,
  3473. /** defines the second component (0 by default) */
  3474. y?: number,
  3475. /** defines the third component (0 by default) */
  3476. z?: number,
  3477. /** defines the fourth component (1.0 by default) */
  3478. w?: number);
  3479. /**
  3480. * Gets a string representation for the current quaternion
  3481. * @returns a string with the Quaternion coordinates
  3482. */
  3483. toString(): string;
  3484. /**
  3485. * Gets the class name of the quaternion
  3486. * @returns the string "Quaternion"
  3487. */
  3488. getClassName(): string;
  3489. /**
  3490. * Gets a hash code for this quaternion
  3491. * @returns the quaternion hash code
  3492. */
  3493. getHashCode(): number;
  3494. /**
  3495. * Copy the quaternion to an array
  3496. * @returns a new array populated with 4 elements from the quaternion coordinates
  3497. */
  3498. asArray(): number[];
  3499. /**
  3500. * Check if two quaternions are equals
  3501. * @param otherQuaternion defines the second operand
  3502. * @return true if the current quaternion and the given one coordinates are strictly equals
  3503. */
  3504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3505. /**
  3506. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3507. * @param otherQuaternion defines the other quaternion
  3508. * @param epsilon defines the minimal distance to consider equality
  3509. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3510. */
  3511. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3512. /**
  3513. * Clone the current quaternion
  3514. * @returns a new quaternion copied from the current one
  3515. */
  3516. clone(): Quaternion;
  3517. /**
  3518. * Copy a quaternion to the current one
  3519. * @param other defines the other quaternion
  3520. * @returns the updated current quaternion
  3521. */
  3522. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3523. /**
  3524. * Updates the current quaternion with the given float coordinates
  3525. * @param x defines the x coordinate
  3526. * @param y defines the y coordinate
  3527. * @param z defines the z coordinate
  3528. * @param w defines the w coordinate
  3529. * @returns the updated current quaternion
  3530. */
  3531. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3532. /**
  3533. * Updates the current quaternion from the given float coordinates
  3534. * @param x defines the x coordinate
  3535. * @param y defines the y coordinate
  3536. * @param z defines the z coordinate
  3537. * @param w defines the w coordinate
  3538. * @returns the updated current quaternion
  3539. */
  3540. set(x: number, y: number, z: number, w: number): Quaternion;
  3541. /**
  3542. * Adds two quaternions
  3543. * @param other defines the second operand
  3544. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3545. */
  3546. add(other: DeepImmutable<Quaternion>): Quaternion;
  3547. /**
  3548. * Add a quaternion to the current one
  3549. * @param other defines the quaternion to add
  3550. * @returns the current quaternion
  3551. */
  3552. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3553. /**
  3554. * Subtract two quaternions
  3555. * @param other defines the second operand
  3556. * @returns a new quaternion as the subtraction result of the given one from the current one
  3557. */
  3558. subtract(other: Quaternion): Quaternion;
  3559. /**
  3560. * Multiplies the current quaternion by a scale factor
  3561. * @param value defines the scale factor
  3562. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3563. */
  3564. scale(value: number): Quaternion;
  3565. /**
  3566. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3567. * @param scale defines the scale factor
  3568. * @param result defines the Quaternion object where to store the result
  3569. * @returns the unmodified current quaternion
  3570. */
  3571. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3572. /**
  3573. * Multiplies in place the current quaternion by a scale factor
  3574. * @param value defines the scale factor
  3575. * @returns the current modified quaternion
  3576. */
  3577. scaleInPlace(value: number): Quaternion;
  3578. /**
  3579. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3580. * @param scale defines the scale factor
  3581. * @param result defines the Quaternion object where to store the result
  3582. * @returns the unmodified current quaternion
  3583. */
  3584. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3585. /**
  3586. * Multiplies two quaternions
  3587. * @param q1 defines the second operand
  3588. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3589. */
  3590. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3591. /**
  3592. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3593. * @param q1 defines the second operand
  3594. * @param result defines the target quaternion
  3595. * @returns the current quaternion
  3596. */
  3597. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3598. /**
  3599. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @returns the currentupdated quaternion
  3602. */
  3603. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3604. /**
  3605. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3606. * @param ref defines the target quaternion
  3607. * @returns the current quaternion
  3608. */
  3609. conjugateToRef(ref: Quaternion): Quaternion;
  3610. /**
  3611. * Conjugates in place (1-q) the current quaternion
  3612. * @returns the current updated quaternion
  3613. */
  3614. conjugateInPlace(): Quaternion;
  3615. /**
  3616. * Conjugates in place (1-q) the current quaternion
  3617. * @returns a new quaternion
  3618. */
  3619. conjugate(): Quaternion;
  3620. /**
  3621. * Gets length of current quaternion
  3622. * @returns the quaternion length (float)
  3623. */
  3624. length(): number;
  3625. /**
  3626. * Normalize in place the current quaternion
  3627. * @returns the current updated quaternion
  3628. */
  3629. normalize(): Quaternion;
  3630. /**
  3631. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3632. * @param order is a reserved parameter and is ignore for now
  3633. * @returns a new Vector3 containing the Euler angles
  3634. */
  3635. toEulerAngles(order?: string): Vector3;
  3636. /**
  3637. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3638. * @param result defines the vector which will be filled with the Euler angles
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns the current unchanged quaternion
  3641. */
  3642. toEulerAnglesToRef(result: Vector3): Quaternion;
  3643. /**
  3644. * Updates the given rotation matrix with the current quaternion values
  3645. * @param result defines the target matrix
  3646. * @returns the current unchanged quaternion
  3647. */
  3648. toRotationMatrix(result: Matrix): Quaternion;
  3649. /**
  3650. * Updates the current quaternion from the given rotation matrix values
  3651. * @param matrix defines the source matrix
  3652. * @returns the current updated quaternion
  3653. */
  3654. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3655. /**
  3656. * Creates a new quaternion from a rotation matrix
  3657. * @param matrix defines the source matrix
  3658. * @returns a new quaternion created from the given rotation matrix values
  3659. */
  3660. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3661. /**
  3662. * Updates the given quaternion with the given rotation matrix values
  3663. * @param matrix defines the source matrix
  3664. * @param result defines the target quaternion
  3665. */
  3666. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3667. /**
  3668. * Returns the dot product (float) between the quaternions "left" and "right"
  3669. * @param left defines the left operand
  3670. * @param right defines the right operand
  3671. * @returns the dot product
  3672. */
  3673. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3674. /**
  3675. * Checks if the two quaternions are close to each other
  3676. * @param quat0 defines the first quaternion to check
  3677. * @param quat1 defines the second quaternion to check
  3678. * @returns true if the two quaternions are close to each other
  3679. */
  3680. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Creates an empty quaternion
  3683. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3684. */
  3685. static Zero(): Quaternion;
  3686. /**
  3687. * Inverse a given quaternion
  3688. * @param q defines the source quaternion
  3689. * @returns a new quaternion as the inverted current quaternion
  3690. */
  3691. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3692. /**
  3693. * Inverse a given quaternion
  3694. * @param q defines the source quaternion
  3695. * @param result the quaternion the result will be stored in
  3696. * @returns the result quaternion
  3697. */
  3698. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3699. /**
  3700. * Creates an identity quaternion
  3701. * @returns the identity quaternion
  3702. */
  3703. static Identity(): Quaternion;
  3704. /**
  3705. * Gets a boolean indicating if the given quaternion is identity
  3706. * @param quaternion defines the quaternion to check
  3707. * @returns true if the quaternion is identity
  3708. */
  3709. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3710. /**
  3711. * Creates a quaternion from a rotation around an axis
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle to use
  3714. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3715. */
  3716. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3717. /**
  3718. * Creates a rotation around an axis and stores it into the given quaternion
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @param result defines the target quaternion
  3722. * @returns the target quaternion
  3723. */
  3724. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3725. /**
  3726. * Creates a new quaternion from data stored into an array
  3727. * @param array defines the data source
  3728. * @param offset defines the offset in the source array where the data starts
  3729. * @returns a new quaternion
  3730. */
  3731. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3732. /**
  3733. * Create a quaternion from Euler rotation angles
  3734. * @param x Pitch
  3735. * @param y Yaw
  3736. * @param z Roll
  3737. * @returns the new Quaternion
  3738. */
  3739. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3740. /**
  3741. * Updates a quaternion from Euler rotation angles
  3742. * @param x Pitch
  3743. * @param y Yaw
  3744. * @param z Roll
  3745. * @param result the quaternion to store the result
  3746. * @returns the updated quaternion
  3747. */
  3748. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3749. /**
  3750. * Create a quaternion from Euler rotation vector
  3751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3752. * @returns the new Quaternion
  3753. */
  3754. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3755. /**
  3756. * Updates a quaternion from Euler rotation vector
  3757. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3758. * @param result the quaternion to store the result
  3759. * @returns the updated quaternion
  3760. */
  3761. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3762. /**
  3763. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3764. * @param yaw defines the rotation around Y axis
  3765. * @param pitch defines the rotation around X axis
  3766. * @param roll defines the rotation around Z axis
  3767. * @returns the new quaternion
  3768. */
  3769. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3770. /**
  3771. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3772. * @param yaw defines the rotation around Y axis
  3773. * @param pitch defines the rotation around X axis
  3774. * @param roll defines the rotation around Z axis
  3775. * @param result defines the target quaternion
  3776. */
  3777. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3778. /**
  3779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3780. * @param alpha defines the rotation around first axis
  3781. * @param beta defines the rotation around second axis
  3782. * @param gamma defines the rotation around third axis
  3783. * @returns the new quaternion
  3784. */
  3785. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3786. /**
  3787. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3788. * @param alpha defines the rotation around first axis
  3789. * @param beta defines the rotation around second axis
  3790. * @param gamma defines the rotation around third axis
  3791. * @param result defines the target quaternion
  3792. */
  3793. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3794. /**
  3795. * 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)
  3796. * @param axis1 defines the first axis
  3797. * @param axis2 defines the second axis
  3798. * @param axis3 defines the third axis
  3799. * @returns the new quaternion
  3800. */
  3801. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * 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
  3804. * @param axis1 defines the first axis
  3805. * @param axis2 defines the second axis
  3806. * @param axis3 defines the third axis
  3807. * @param ref defines the target quaternion
  3808. */
  3809. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3810. /**
  3811. * Interpolates between two quaternions
  3812. * @param left defines first quaternion
  3813. * @param right defines second quaternion
  3814. * @param amount defines the gradient to use
  3815. * @returns the new interpolated quaternion
  3816. */
  3817. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3818. /**
  3819. * Interpolates between two quaternions and stores it into a target quaternion
  3820. * @param left defines first quaternion
  3821. * @param right defines second quaternion
  3822. * @param amount defines the gradient to use
  3823. * @param result defines the target quaternion
  3824. */
  3825. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3826. /**
  3827. * Interpolate between two quaternions using Hermite interpolation
  3828. * @param value1 defines first quaternion
  3829. * @param tangent1 defines the incoming tangent
  3830. * @param value2 defines second quaternion
  3831. * @param tangent2 defines the outgoing tangent
  3832. * @param amount defines the target quaternion
  3833. * @returns the new interpolated quaternion
  3834. */
  3835. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3836. }
  3837. /**
  3838. * Class used to store matrix data (4x4)
  3839. */
  3840. export class Matrix {
  3841. private static _updateFlagSeed;
  3842. private static _identityReadOnly;
  3843. private _isIdentity;
  3844. private _isIdentityDirty;
  3845. private _isIdentity3x2;
  3846. private _isIdentity3x2Dirty;
  3847. /**
  3848. * Gets the update flag of the matrix which is an unique number for the matrix.
  3849. * It will be incremented every time the matrix data change.
  3850. * You can use it to speed the comparison between two versions of the same matrix.
  3851. */
  3852. updateFlag: number;
  3853. private readonly _m;
  3854. /**
  3855. * Gets the internal data of the matrix
  3856. */
  3857. get m(): DeepImmutable<Float32Array>;
  3858. /** @hidden */
  3859. _markAsUpdated(): void;
  3860. /** @hidden */
  3861. private _updateIdentityStatus;
  3862. /**
  3863. * Creates an empty matrix (filled with zeros)
  3864. */
  3865. constructor();
  3866. /**
  3867. * Check if the current matrix is identity
  3868. * @returns true is the matrix is the identity matrix
  3869. */
  3870. isIdentity(): boolean;
  3871. /**
  3872. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3873. * @returns true is the matrix is the identity matrix
  3874. */
  3875. isIdentityAs3x2(): boolean;
  3876. /**
  3877. * Gets the determinant of the matrix
  3878. * @returns the matrix determinant
  3879. */
  3880. determinant(): number;
  3881. /**
  3882. * Returns the matrix as a Float32Array
  3883. * @returns the matrix underlying array
  3884. */
  3885. toArray(): DeepImmutable<Float32Array>;
  3886. /**
  3887. * Returns the matrix as a Float32Array
  3888. * @returns the matrix underlying array.
  3889. */
  3890. asArray(): DeepImmutable<Float32Array>;
  3891. /**
  3892. * Inverts the current matrix in place
  3893. * @returns the current inverted matrix
  3894. */
  3895. invert(): Matrix;
  3896. /**
  3897. * Sets all the matrix elements to zero
  3898. * @returns the current matrix
  3899. */
  3900. reset(): Matrix;
  3901. /**
  3902. * Adds the current matrix with a second one
  3903. * @param other defines the matrix to add
  3904. * @returns a new matrix as the addition of the current matrix and the given one
  3905. */
  3906. add(other: DeepImmutable<Matrix>): Matrix;
  3907. /**
  3908. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3909. * @param other defines the matrix to add
  3910. * @param result defines the target matrix
  3911. * @returns the current matrix
  3912. */
  3913. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3914. /**
  3915. * Adds in place the given matrix to the current matrix
  3916. * @param other defines the second operand
  3917. * @returns the current updated matrix
  3918. */
  3919. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3920. /**
  3921. * Sets the given matrix to the current inverted Matrix
  3922. * @param other defines the target matrix
  3923. * @returns the unmodified current matrix
  3924. */
  3925. invertToRef(other: Matrix): Matrix;
  3926. /**
  3927. * add a value at the specified position in the current Matrix
  3928. * @param index the index of the value within the matrix. between 0 and 15.
  3929. * @param value the value to be added
  3930. * @returns the current updated matrix
  3931. */
  3932. addAtIndex(index: number, value: number): Matrix;
  3933. /**
  3934. * mutiply the specified position in the current Matrix by a value
  3935. * @param index the index of the value within the matrix. between 0 and 15.
  3936. * @param value the value to be added
  3937. * @returns the current updated matrix
  3938. */
  3939. multiplyAtIndex(index: number, value: number): Matrix;
  3940. /**
  3941. * Inserts the translation vector (using 3 floats) in the current matrix
  3942. * @param x defines the 1st component of the translation
  3943. * @param y defines the 2nd component of the translation
  3944. * @param z defines the 3rd component of the translation
  3945. * @returns the current updated matrix
  3946. */
  3947. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3948. /**
  3949. * Adds the translation vector (using 3 floats) in the current matrix
  3950. * @param x defines the 1st component of the translation
  3951. * @param y defines the 2nd component of the translation
  3952. * @param z defines the 3rd component of the translation
  3953. * @returns the current updated matrix
  3954. */
  3955. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3956. /**
  3957. * Inserts the translation vector in the current matrix
  3958. * @param vector3 defines the translation to insert
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3962. /**
  3963. * Gets the translation value of the current matrix
  3964. * @returns a new Vector3 as the extracted translation from the matrix
  3965. */
  3966. getTranslation(): Vector3;
  3967. /**
  3968. * Fill a Vector3 with the extracted translation from the matrix
  3969. * @param result defines the Vector3 where to store the translation
  3970. * @returns the current matrix
  3971. */
  3972. getTranslationToRef(result: Vector3): Matrix;
  3973. /**
  3974. * Remove rotation and scaling part from the matrix
  3975. * @returns the updated matrix
  3976. */
  3977. removeRotationAndScaling(): Matrix;
  3978. /**
  3979. * Multiply two matrices
  3980. * @param other defines the second operand
  3981. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3982. */
  3983. multiply(other: DeepImmutable<Matrix>): Matrix;
  3984. /**
  3985. * Copy the current matrix from the given one
  3986. * @param other defines the source matrix
  3987. * @returns the current updated matrix
  3988. */
  3989. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3990. /**
  3991. * Populates the given array from the starting index with the current matrix values
  3992. * @param array defines the target array
  3993. * @param offset defines the offset in the target array where to start storing values
  3994. * @returns the current matrix
  3995. */
  3996. copyToArray(array: Float32Array, offset?: number): Matrix;
  3997. /**
  3998. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3999. * @param other defines the second operand
  4000. * @param result defines the matrix where to store the multiplication
  4001. * @returns the current matrix
  4002. */
  4003. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4004. /**
  4005. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4006. * @param other defines the second operand
  4007. * @param result defines the array where to store the multiplication
  4008. * @param offset defines the offset in the target array where to start storing values
  4009. * @returns the current matrix
  4010. */
  4011. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4012. /**
  4013. * Check equality between this matrix and a second one
  4014. * @param value defines the second matrix to compare
  4015. * @returns true is the current matrix and the given one values are strictly equal
  4016. */
  4017. equals(value: DeepImmutable<Matrix>): boolean;
  4018. /**
  4019. * Clone the current matrix
  4020. * @returns a new matrix from the current matrix
  4021. */
  4022. clone(): Matrix;
  4023. /**
  4024. * Returns the name of the current matrix class
  4025. * @returns the string "Matrix"
  4026. */
  4027. getClassName(): string;
  4028. /**
  4029. * Gets the hash code of the current matrix
  4030. * @returns the hash code
  4031. */
  4032. getHashCode(): number;
  4033. /**
  4034. * Decomposes the current Matrix into a translation, rotation and scaling components
  4035. * @param scale defines the scale vector3 given as a reference to update
  4036. * @param rotation defines the rotation quaternion given as a reference to update
  4037. * @param translation defines the translation vector3 given as a reference to update
  4038. * @returns true if operation was successful
  4039. */
  4040. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4041. /**
  4042. * Gets specific row of the matrix
  4043. * @param index defines the number of the row to get
  4044. * @returns the index-th row of the current matrix as a new Vector4
  4045. */
  4046. getRow(index: number): Nullable<Vector4>;
  4047. /**
  4048. * Sets the index-th row of the current matrix to the vector4 values
  4049. * @param index defines the number of the row to set
  4050. * @param row defines the target vector4
  4051. * @returns the updated current matrix
  4052. */
  4053. setRow(index: number, row: Vector4): Matrix;
  4054. /**
  4055. * Compute the transpose of the matrix
  4056. * @returns the new transposed matrix
  4057. */
  4058. transpose(): Matrix;
  4059. /**
  4060. * Compute the transpose of the matrix and store it in a given matrix
  4061. * @param result defines the target matrix
  4062. * @returns the current matrix
  4063. */
  4064. transposeToRef(result: Matrix): Matrix;
  4065. /**
  4066. * Sets the index-th row of the current matrix with the given 4 x float values
  4067. * @param index defines the row index
  4068. * @param x defines the x component to set
  4069. * @param y defines the y component to set
  4070. * @param z defines the z component to set
  4071. * @param w defines the w component to set
  4072. * @returns the updated current matrix
  4073. */
  4074. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4075. /**
  4076. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4077. * @param scale defines the scale factor
  4078. * @returns a new matrix
  4079. */
  4080. scale(scale: number): Matrix;
  4081. /**
  4082. * Scale the current matrix values by a factor to a given result matrix
  4083. * @param scale defines the scale factor
  4084. * @param result defines the matrix to store the result
  4085. * @returns the current matrix
  4086. */
  4087. scaleToRef(scale: number, result: Matrix): Matrix;
  4088. /**
  4089. * Scale the current matrix values by a factor and add the result to a given matrix
  4090. * @param scale defines the scale factor
  4091. * @param result defines the Matrix to store the result
  4092. * @returns the current matrix
  4093. */
  4094. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4095. /**
  4096. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4097. * @param ref matrix to store the result
  4098. */
  4099. toNormalMatrix(ref: Matrix): void;
  4100. /**
  4101. * Gets only rotation part of the current matrix
  4102. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4103. */
  4104. getRotationMatrix(): Matrix;
  4105. /**
  4106. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4107. * @param result defines the target matrix to store data to
  4108. * @returns the current matrix
  4109. */
  4110. getRotationMatrixToRef(result: Matrix): Matrix;
  4111. /**
  4112. * Toggles model matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleModelMatrixHandInPlace(): void;
  4115. /**
  4116. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4117. */
  4118. toggleProjectionMatrixHandInPlace(): void;
  4119. /**
  4120. * Creates a matrix from an array
  4121. * @param array defines the source array
  4122. * @param offset defines an offset in the source array
  4123. * @returns a new Matrix set from the starting index of the given array
  4124. */
  4125. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4126. /**
  4127. * Copy the content of an array into a given matrix
  4128. * @param array defines the source array
  4129. * @param offset defines an offset in the source array
  4130. * @param result defines the target matrix
  4131. */
  4132. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4133. /**
  4134. * Stores an array into a matrix after having multiplied each component by a given factor
  4135. * @param array defines the source array
  4136. * @param offset defines the offset in the source array
  4137. * @param scale defines the scaling factor
  4138. * @param result defines the target matrix
  4139. */
  4140. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4141. /**
  4142. * Gets an identity matrix that must not be updated
  4143. */
  4144. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4145. /**
  4146. * Stores a list of values (16) inside a given matrix
  4147. * @param initialM11 defines 1st value of 1st row
  4148. * @param initialM12 defines 2nd value of 1st row
  4149. * @param initialM13 defines 3rd value of 1st row
  4150. * @param initialM14 defines 4th value of 1st row
  4151. * @param initialM21 defines 1st value of 2nd row
  4152. * @param initialM22 defines 2nd value of 2nd row
  4153. * @param initialM23 defines 3rd value of 2nd row
  4154. * @param initialM24 defines 4th value of 2nd row
  4155. * @param initialM31 defines 1st value of 3rd row
  4156. * @param initialM32 defines 2nd value of 3rd row
  4157. * @param initialM33 defines 3rd value of 3rd row
  4158. * @param initialM34 defines 4th value of 3rd row
  4159. * @param initialM41 defines 1st value of 4th row
  4160. * @param initialM42 defines 2nd value of 4th row
  4161. * @param initialM43 defines 3rd value of 4th row
  4162. * @param initialM44 defines 4th value of 4th row
  4163. * @param result defines the target matrix
  4164. */
  4165. 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;
  4166. /**
  4167. * Creates new matrix from a list of values (16)
  4168. * @param initialM11 defines 1st value of 1st row
  4169. * @param initialM12 defines 2nd value of 1st row
  4170. * @param initialM13 defines 3rd value of 1st row
  4171. * @param initialM14 defines 4th value of 1st row
  4172. * @param initialM21 defines 1st value of 2nd row
  4173. * @param initialM22 defines 2nd value of 2nd row
  4174. * @param initialM23 defines 3rd value of 2nd row
  4175. * @param initialM24 defines 4th value of 2nd row
  4176. * @param initialM31 defines 1st value of 3rd row
  4177. * @param initialM32 defines 2nd value of 3rd row
  4178. * @param initialM33 defines 3rd value of 3rd row
  4179. * @param initialM34 defines 4th value of 3rd row
  4180. * @param initialM41 defines 1st value of 4th row
  4181. * @param initialM42 defines 2nd value of 4th row
  4182. * @param initialM43 defines 3rd value of 4th row
  4183. * @param initialM44 defines 4th value of 4th row
  4184. * @returns the new matrix
  4185. */
  4186. 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;
  4187. /**
  4188. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4189. * @param scale defines the scale vector3
  4190. * @param rotation defines the rotation quaternion
  4191. * @param translation defines the translation vector3
  4192. * @returns a new matrix
  4193. */
  4194. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4195. /**
  4196. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4197. * @param scale defines the scale vector3
  4198. * @param rotation defines the rotation quaternion
  4199. * @param translation defines the translation vector3
  4200. * @param result defines the target matrix
  4201. */
  4202. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4203. /**
  4204. * Creates a new identity matrix
  4205. * @returns a new identity matrix
  4206. */
  4207. static Identity(): Matrix;
  4208. /**
  4209. * Creates a new identity matrix and stores the result in a given matrix
  4210. * @param result defines the target matrix
  4211. */
  4212. static IdentityToRef(result: Matrix): void;
  4213. /**
  4214. * Creates a new zero matrix
  4215. * @returns a new zero matrix
  4216. */
  4217. static Zero(): Matrix;
  4218. /**
  4219. * Creates a new rotation matrix for "angle" radians around the X axis
  4220. * @param angle defines the angle (in radians) to use
  4221. * @return the new matrix
  4222. */
  4223. static RotationX(angle: number): Matrix;
  4224. /**
  4225. * Creates a new matrix as the invert of a given matrix
  4226. * @param source defines the source matrix
  4227. * @returns the new matrix
  4228. */
  4229. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4230. /**
  4231. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4232. * @param angle defines the angle (in radians) to use
  4233. * @param result defines the target matrix
  4234. */
  4235. static RotationXToRef(angle: number, result: Matrix): void;
  4236. /**
  4237. * Creates a new rotation matrix for "angle" radians around the Y axis
  4238. * @param angle defines the angle (in radians) to use
  4239. * @return the new matrix
  4240. */
  4241. static RotationY(angle: number): Matrix;
  4242. /**
  4243. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4244. * @param angle defines the angle (in radians) to use
  4245. * @param result defines the target matrix
  4246. */
  4247. static RotationYToRef(angle: number, result: Matrix): void;
  4248. /**
  4249. * Creates a new rotation matrix for "angle" radians around the Z axis
  4250. * @param angle defines the angle (in radians) to use
  4251. * @return the new matrix
  4252. */
  4253. static RotationZ(angle: number): Matrix;
  4254. /**
  4255. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4256. * @param angle defines the angle (in radians) to use
  4257. * @param result defines the target matrix
  4258. */
  4259. static RotationZToRef(angle: number, result: Matrix): void;
  4260. /**
  4261. * Creates a new rotation matrix for "angle" radians around the given axis
  4262. * @param axis defines the axis to use
  4263. * @param angle defines the angle (in radians) to use
  4264. * @return the new matrix
  4265. */
  4266. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4269. * @param axis defines the axis to use
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4274. /**
  4275. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4276. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4277. * @param from defines the vector to align
  4278. * @param to defines the vector to align to
  4279. * @param result defines the target matrix
  4280. */
  4281. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4282. /**
  4283. * Creates a rotation matrix
  4284. * @param yaw defines the yaw angle in radians (Y axis)
  4285. * @param pitch defines the pitch angle in radians (X axis)
  4286. * @param roll defines the roll angle in radians (X axis)
  4287. * @returns the new rotation matrix
  4288. */
  4289. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4290. /**
  4291. * Creates a rotation matrix and stores it in a given matrix
  4292. * @param yaw defines the yaw angle in radians (Y axis)
  4293. * @param pitch defines the pitch angle in radians (X axis)
  4294. * @param roll defines the roll angle in radians (X axis)
  4295. * @param result defines the target matrix
  4296. */
  4297. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4298. /**
  4299. * Creates a scaling matrix
  4300. * @param x defines the scale factor on X axis
  4301. * @param y defines the scale factor on Y axis
  4302. * @param z defines the scale factor on Z axis
  4303. * @returns the new matrix
  4304. */
  4305. static Scaling(x: number, y: number, z: number): Matrix;
  4306. /**
  4307. * Creates a scaling matrix and stores it in a given matrix
  4308. * @param x defines the scale factor on X axis
  4309. * @param y defines the scale factor on Y axis
  4310. * @param z defines the scale factor on Z axis
  4311. * @param result defines the target matrix
  4312. */
  4313. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4314. /**
  4315. * Creates a translation matrix
  4316. * @param x defines the translation on X axis
  4317. * @param y defines the translation on Y axis
  4318. * @param z defines the translationon Z axis
  4319. * @returns the new matrix
  4320. */
  4321. static Translation(x: number, y: number, z: number): Matrix;
  4322. /**
  4323. * Creates a translation matrix and stores it in a given matrix
  4324. * @param x defines the translation on X axis
  4325. * @param y defines the translation on Y axis
  4326. * @param z defines the translationon Z axis
  4327. * @param result defines the target matrix
  4328. */
  4329. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4330. /**
  4331. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4332. * @param startValue defines the start value
  4333. * @param endValue defines the end value
  4334. * @param gradient defines the gradient factor
  4335. * @returns the new matrix
  4336. */
  4337. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4338. /**
  4339. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4340. * @param startValue defines the start value
  4341. * @param endValue defines the end value
  4342. * @param gradient defines the gradient factor
  4343. * @param result defines the Matrix object where to store data
  4344. */
  4345. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4346. /**
  4347. * Builds a new matrix whose values are computed by:
  4348. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4349. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4350. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4351. * @param startValue defines the first matrix
  4352. * @param endValue defines the second matrix
  4353. * @param gradient defines the gradient between the two matrices
  4354. * @returns the new matrix
  4355. */
  4356. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4357. /**
  4358. * Update a matrix to values which are computed by:
  4359. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4360. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4361. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4362. * @param startValue defines the first matrix
  4363. * @param endValue defines the second matrix
  4364. * @param gradient defines the gradient between the two matrices
  4365. * @param result defines the target matrix
  4366. */
  4367. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4368. /**
  4369. * 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"
  4370. * This function works in left handed mode
  4371. * @param eye defines the final position of the entity
  4372. * @param target defines where the entity should look at
  4373. * @param up defines the up vector for the entity
  4374. * @returns the new matrix
  4375. */
  4376. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4377. /**
  4378. * 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".
  4379. * This function works in left handed mode
  4380. * @param eye defines the final position of the entity
  4381. * @param target defines where the entity should look at
  4382. * @param up defines the up vector for the entity
  4383. * @param result defines the target matrix
  4384. */
  4385. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4386. /**
  4387. * 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"
  4388. * This function works in right handed mode
  4389. * @param eye defines the final position of the entity
  4390. * @param target defines where the entity should look at
  4391. * @param up defines the up vector for the entity
  4392. * @returns the new matrix
  4393. */
  4394. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4395. /**
  4396. * 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".
  4397. * This function works in right handed mode
  4398. * @param eye defines the final position of the entity
  4399. * @param target defines where the entity should look at
  4400. * @param up defines the up vector for the entity
  4401. * @param result defines the target matrix
  4402. */
  4403. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4404. /**
  4405. * Create a left-handed orthographic projection matrix
  4406. * @param width defines the viewport width
  4407. * @param height defines the viewport height
  4408. * @param znear defines the near clip plane
  4409. * @param zfar defines the far clip plane
  4410. * @returns a new matrix as a left-handed orthographic projection matrix
  4411. */
  4412. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4413. /**
  4414. * Store a left-handed orthographic projection to a given matrix
  4415. * @param width defines the viewport width
  4416. * @param height defines the viewport height
  4417. * @param znear defines the near clip plane
  4418. * @param zfar defines the far clip plane
  4419. * @param result defines the target matrix
  4420. */
  4421. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4422. /**
  4423. * Create a left-handed orthographic projection matrix
  4424. * @param left defines the viewport left coordinate
  4425. * @param right defines the viewport right coordinate
  4426. * @param bottom defines the viewport bottom coordinate
  4427. * @param top defines the viewport top coordinate
  4428. * @param znear defines the near clip plane
  4429. * @param zfar defines the far clip plane
  4430. * @returns a new matrix as a left-handed orthographic projection matrix
  4431. */
  4432. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4433. /**
  4434. * Stores a left-handed orthographic projection into a given matrix
  4435. * @param left defines the viewport left coordinate
  4436. * @param right defines the viewport right coordinate
  4437. * @param bottom defines the viewport bottom coordinate
  4438. * @param top defines the viewport top coordinate
  4439. * @param znear defines the near clip plane
  4440. * @param zfar defines the far clip plane
  4441. * @param result defines the target matrix
  4442. */
  4443. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4444. /**
  4445. * Creates a right-handed orthographic projection matrix
  4446. * @param left defines the viewport left coordinate
  4447. * @param right defines the viewport right coordinate
  4448. * @param bottom defines the viewport bottom coordinate
  4449. * @param top defines the viewport top coordinate
  4450. * @param znear defines the near clip plane
  4451. * @param zfar defines the far clip plane
  4452. * @returns a new matrix as a right-handed orthographic projection matrix
  4453. */
  4454. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4455. /**
  4456. * Stores a right-handed orthographic projection into a given matrix
  4457. * @param left defines the viewport left coordinate
  4458. * @param right defines the viewport right coordinate
  4459. * @param bottom defines the viewport bottom coordinate
  4460. * @param top defines the viewport top coordinate
  4461. * @param znear defines the near clip plane
  4462. * @param zfar defines the far clip plane
  4463. * @param result defines the target matrix
  4464. */
  4465. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4466. /**
  4467. * Creates a left-handed perspective projection matrix
  4468. * @param width defines the viewport width
  4469. * @param height defines the viewport height
  4470. * @param znear defines the near clip plane
  4471. * @param zfar defines the far clip plane
  4472. * @returns a new matrix as a left-handed perspective projection matrix
  4473. */
  4474. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4475. /**
  4476. * Creates a left-handed perspective projection matrix
  4477. * @param fov defines the horizontal field of view
  4478. * @param aspect defines the aspect ratio
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a left-handed perspective projection matrix
  4482. */
  4483. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a left-handed perspective projection into a given matrix
  4486. * @param fov defines the horizontal field of view
  4487. * @param aspect defines the aspect ratio
  4488. * @param znear defines the near clip plane
  4489. * @param zfar defines the far clip plane
  4490. * @param result defines the target matrix
  4491. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4492. */
  4493. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4494. /**
  4495. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4496. * @param fov defines the horizontal field of view
  4497. * @param aspect defines the aspect ratio
  4498. * @param znear defines the near clip plane
  4499. * @param zfar not used as infinity is used as far clip
  4500. * @param result defines the target matrix
  4501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4502. */
  4503. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4504. /**
  4505. * Creates a right-handed perspective projection matrix
  4506. * @param fov defines the horizontal field of view
  4507. * @param aspect defines the aspect ratio
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a right-handed perspective projection matrix
  4511. */
  4512. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a right-handed perspective projection into a given matrix
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Stores a right-handed perspective projection into a given matrix
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar not used as infinity is used as far clip
  4529. * @param result defines the target matrix
  4530. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4531. */
  4532. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4533. /**
  4534. * Stores a perspective projection for WebVR info a given matrix
  4535. * @param fov defines the field of view
  4536. * @param znear defines the near clip plane
  4537. * @param zfar defines the far clip plane
  4538. * @param result defines the target matrix
  4539. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4540. */
  4541. static PerspectiveFovWebVRToRef(fov: {
  4542. upDegrees: number;
  4543. downDegrees: number;
  4544. leftDegrees: number;
  4545. rightDegrees: number;
  4546. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4547. /**
  4548. * Computes a complete transformation matrix
  4549. * @param viewport defines the viewport to use
  4550. * @param world defines the world matrix
  4551. * @param view defines the view matrix
  4552. * @param projection defines the projection matrix
  4553. * @param zmin defines the near clip plane
  4554. * @param zmax defines the far clip plane
  4555. * @returns the transformation matrix
  4556. */
  4557. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4558. /**
  4559. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4560. * @param matrix defines the matrix to use
  4561. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4562. */
  4563. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4564. /**
  4565. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4566. * @param matrix defines the matrix to use
  4567. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4568. */
  4569. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4570. /**
  4571. * Compute the transpose of a given matrix
  4572. * @param matrix defines the matrix to transpose
  4573. * @returns the new matrix
  4574. */
  4575. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4576. /**
  4577. * Compute the transpose of a matrix and store it in a target matrix
  4578. * @param matrix defines the matrix to transpose
  4579. * @param result defines the target matrix
  4580. */
  4581. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4582. /**
  4583. * Computes a reflection matrix from a plane
  4584. * @param plane defines the reflection plane
  4585. * @returns a new matrix
  4586. */
  4587. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4588. /**
  4589. * Computes a reflection matrix from a plane
  4590. * @param plane defines the reflection plane
  4591. * @param result defines the target matrix
  4592. */
  4593. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4594. /**
  4595. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4596. * @param xaxis defines the value of the 1st axis
  4597. * @param yaxis defines the value of the 2nd axis
  4598. * @param zaxis defines the value of the 3rd axis
  4599. * @param result defines the target matrix
  4600. */
  4601. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4602. /**
  4603. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4604. * @param quat defines the quaternion to use
  4605. * @param result defines the target matrix
  4606. */
  4607. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4608. }
  4609. /**
  4610. * @hidden
  4611. */
  4612. export class TmpVectors {
  4613. static Vector2: Vector2[];
  4614. static Vector3: Vector3[];
  4615. static Vector4: Vector4[];
  4616. static Quaternion: Quaternion[];
  4617. static Matrix: Matrix[];
  4618. }
  4619. }
  4620. declare module BABYLON {
  4621. /**
  4622. * Defines potential orientation for back face culling
  4623. */
  4624. export enum Orientation {
  4625. /**
  4626. * Clockwise
  4627. */
  4628. CW = 0,
  4629. /** Counter clockwise */
  4630. CCW = 1
  4631. }
  4632. /** Class used to represent a Bezier curve */
  4633. export class BezierCurve {
  4634. /**
  4635. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4636. * @param t defines the time
  4637. * @param x1 defines the left coordinate on X axis
  4638. * @param y1 defines the left coordinate on Y axis
  4639. * @param x2 defines the right coordinate on X axis
  4640. * @param y2 defines the right coordinate on Y axis
  4641. * @returns the interpolated value
  4642. */
  4643. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4644. }
  4645. /**
  4646. * Defines angle representation
  4647. */
  4648. export class Angle {
  4649. private _radians;
  4650. /**
  4651. * Creates an Angle object of "radians" radians (float).
  4652. * @param radians the angle in radians
  4653. */
  4654. constructor(radians: number);
  4655. /**
  4656. * Get value in degrees
  4657. * @returns the Angle value in degrees (float)
  4658. */
  4659. degrees(): number;
  4660. /**
  4661. * Get value in radians
  4662. * @returns the Angle value in radians (float)
  4663. */
  4664. radians(): number;
  4665. /**
  4666. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4667. * @param a defines first vector
  4668. * @param b defines second vector
  4669. * @returns a new Angle
  4670. */
  4671. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4672. /**
  4673. * Gets a new Angle object from the given float in radians
  4674. * @param radians defines the angle value in radians
  4675. * @returns a new Angle
  4676. */
  4677. static FromRadians(radians: number): Angle;
  4678. /**
  4679. * Gets a new Angle object from the given float in degrees
  4680. * @param degrees defines the angle value in degrees
  4681. * @returns a new Angle
  4682. */
  4683. static FromDegrees(degrees: number): Angle;
  4684. }
  4685. /**
  4686. * This represents an arc in a 2d space.
  4687. */
  4688. export class Arc2 {
  4689. /** Defines the start point of the arc */
  4690. startPoint: Vector2;
  4691. /** Defines the mid point of the arc */
  4692. midPoint: Vector2;
  4693. /** Defines the end point of the arc */
  4694. endPoint: Vector2;
  4695. /**
  4696. * Defines the center point of the arc.
  4697. */
  4698. centerPoint: Vector2;
  4699. /**
  4700. * Defines the radius of the arc.
  4701. */
  4702. radius: number;
  4703. /**
  4704. * Defines the angle of the arc (from mid point to end point).
  4705. */
  4706. angle: Angle;
  4707. /**
  4708. * Defines the start angle of the arc (from start point to middle point).
  4709. */
  4710. startAngle: Angle;
  4711. /**
  4712. * Defines the orientation of the arc (clock wise/counter clock wise).
  4713. */
  4714. orientation: Orientation;
  4715. /**
  4716. * Creates an Arc object from the three given points : start, middle and end.
  4717. * @param startPoint Defines the start point of the arc
  4718. * @param midPoint Defines the midlle point of the arc
  4719. * @param endPoint Defines the end point of the arc
  4720. */
  4721. constructor(
  4722. /** Defines the start point of the arc */
  4723. startPoint: Vector2,
  4724. /** Defines the mid point of the arc */
  4725. midPoint: Vector2,
  4726. /** Defines the end point of the arc */
  4727. endPoint: Vector2);
  4728. }
  4729. /**
  4730. * Represents a 2D path made up of multiple 2D points
  4731. */
  4732. export class Path2 {
  4733. private _points;
  4734. private _length;
  4735. /**
  4736. * If the path start and end point are the same
  4737. */
  4738. closed: boolean;
  4739. /**
  4740. * Creates a Path2 object from the starting 2D coordinates x and y.
  4741. * @param x the starting points x value
  4742. * @param y the starting points y value
  4743. */
  4744. constructor(x: number, y: number);
  4745. /**
  4746. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4747. * @param x the added points x value
  4748. * @param y the added points y value
  4749. * @returns the updated Path2.
  4750. */
  4751. addLineTo(x: number, y: number): Path2;
  4752. /**
  4753. * 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.
  4754. * @param midX middle point x value
  4755. * @param midY middle point y value
  4756. * @param endX end point x value
  4757. * @param endY end point y value
  4758. * @param numberOfSegments (default: 36)
  4759. * @returns the updated Path2.
  4760. */
  4761. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4762. /**
  4763. * Closes the Path2.
  4764. * @returns the Path2.
  4765. */
  4766. close(): Path2;
  4767. /**
  4768. * Gets the sum of the distance between each sequential point in the path
  4769. * @returns the Path2 total length (float).
  4770. */
  4771. length(): number;
  4772. /**
  4773. * Gets the points which construct the path
  4774. * @returns the Path2 internal array of points.
  4775. */
  4776. getPoints(): Vector2[];
  4777. /**
  4778. * Retreives the point at the distance aways from the starting point
  4779. * @param normalizedLengthPosition the length along the path to retreive the point from
  4780. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4781. */
  4782. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4783. /**
  4784. * Creates a new path starting from an x and y position
  4785. * @param x starting x value
  4786. * @param y starting y value
  4787. * @returns a new Path2 starting at the coordinates (x, y).
  4788. */
  4789. static StartingAt(x: number, y: number): Path2;
  4790. }
  4791. /**
  4792. * Represents a 3D path made up of multiple 3D points
  4793. */
  4794. export class Path3D {
  4795. /**
  4796. * an array of Vector3, the curve axis of the Path3D
  4797. */
  4798. path: Vector3[];
  4799. private _curve;
  4800. private _distances;
  4801. private _tangents;
  4802. private _normals;
  4803. private _binormals;
  4804. private _raw;
  4805. private _alignTangentsWithPath;
  4806. private readonly _pointAtData;
  4807. /**
  4808. * new Path3D(path, normal, raw)
  4809. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4810. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4811. * @param path an array of Vector3, the curve axis of the Path3D
  4812. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4813. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4814. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4815. */
  4816. constructor(
  4817. /**
  4818. * an array of Vector3, the curve axis of the Path3D
  4819. */
  4820. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4821. /**
  4822. * Returns the Path3D array of successive Vector3 designing its curve.
  4823. * @returns the Path3D array of successive Vector3 designing its curve.
  4824. */
  4825. getCurve(): Vector3[];
  4826. /**
  4827. * Returns the Path3D array of successive Vector3 designing its curve.
  4828. * @returns the Path3D array of successive Vector3 designing its curve.
  4829. */
  4830. getPoints(): Vector3[];
  4831. /**
  4832. * @returns the computed length (float) of the path.
  4833. */
  4834. length(): number;
  4835. /**
  4836. * Returns an array populated with tangent vectors on each Path3D curve point.
  4837. * @returns an array populated with tangent vectors on each Path3D curve point.
  4838. */
  4839. getTangents(): Vector3[];
  4840. /**
  4841. * Returns an array populated with normal vectors on each Path3D curve point.
  4842. * @returns an array populated with normal vectors on each Path3D curve point.
  4843. */
  4844. getNormals(): Vector3[];
  4845. /**
  4846. * Returns an array populated with binormal vectors on each Path3D curve point.
  4847. * @returns an array populated with binormal vectors on each Path3D curve point.
  4848. */
  4849. getBinormals(): Vector3[];
  4850. /**
  4851. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4852. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4853. */
  4854. getDistances(): number[];
  4855. /**
  4856. * Returns an interpolated point along this path
  4857. * @param position the position of the point along this path, from 0.0 to 1.0
  4858. * @returns a new Vector3 as the point
  4859. */
  4860. getPointAt(position: number): Vector3;
  4861. /**
  4862. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4863. * @param position the position of the point along this path, from 0.0 to 1.0
  4864. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4865. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4866. */
  4867. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4868. /**
  4869. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4870. * @param position the position of the point along this path, from 0.0 to 1.0
  4871. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4872. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4873. */
  4874. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4875. /**
  4876. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4879. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4880. */
  4881. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4886. */
  4887. getDistanceAt(position: number): number;
  4888. /**
  4889. * Returns the array index of the previous point of an interpolated point along this path
  4890. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4891. * @returns the array index
  4892. */
  4893. getPreviousPointIndexAt(position: number): number;
  4894. /**
  4895. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4896. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4897. * @returns the sub position
  4898. */
  4899. getSubPositionAt(position: number): number;
  4900. /**
  4901. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4902. * @param target the vector of which to get the closest position to
  4903. * @returns the position of the closest virtual point on this path to the target vector
  4904. */
  4905. getClosestPositionTo(target: Vector3): number;
  4906. /**
  4907. * Returns a sub path (slice) of this path
  4908. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4909. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4910. * @returns a sub path (slice) of this path
  4911. */
  4912. slice(start?: number, end?: number): Path3D;
  4913. /**
  4914. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4915. * @param path path which all values are copied into the curves points
  4916. * @param firstNormal which should be projected onto the curve
  4917. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4918. * @returns the same object updated.
  4919. */
  4920. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4921. private _compute;
  4922. private _getFirstNonNullVector;
  4923. private _getLastNonNullVector;
  4924. private _normalVector;
  4925. /**
  4926. * Updates the point at data for an interpolated point along this curve
  4927. * @param position the position of the point along this curve, from 0.0 to 1.0
  4928. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4929. * @returns the (updated) point at data
  4930. */
  4931. private _updatePointAtData;
  4932. /**
  4933. * Updates the point at data from the specified parameters
  4934. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4935. * @param point the interpolated point
  4936. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4937. */
  4938. private _setPointAtData;
  4939. /**
  4940. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4941. */
  4942. private _updateInterpolationMatrix;
  4943. }
  4944. /**
  4945. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4946. * A Curve3 is designed from a series of successive Vector3.
  4947. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4948. */
  4949. export class Curve3 {
  4950. private _points;
  4951. private _length;
  4952. /**
  4953. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4954. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4955. * @param v1 (Vector3) the control point
  4956. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4957. * @param nbPoints (integer) the wanted number of points in the curve
  4958. * @returns the created Curve3
  4959. */
  4960. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4961. /**
  4962. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4963. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4964. * @param v1 (Vector3) the first control point
  4965. * @param v2 (Vector3) the second control point
  4966. * @param v3 (Vector3) the end point of the Cubic Bezier
  4967. * @param nbPoints (integer) the wanted number of points in the curve
  4968. * @returns the created Curve3
  4969. */
  4970. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4971. /**
  4972. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4973. * @param p1 (Vector3) the origin point of the Hermite Spline
  4974. * @param t1 (Vector3) the tangent vector at the origin point
  4975. * @param p2 (Vector3) the end point of the Hermite Spline
  4976. * @param t2 (Vector3) the tangent vector at the end point
  4977. * @param nbPoints (integer) the wanted number of points in the curve
  4978. * @returns the created Curve3
  4979. */
  4980. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4981. /**
  4982. * Returns a Curve3 object along a CatmullRom Spline curve :
  4983. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4984. * @param nbPoints (integer) the wanted number of points between each curve control points
  4985. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4986. * @returns the created Curve3
  4987. */
  4988. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4989. /**
  4990. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4991. * A Curve3 is designed from a series of successive Vector3.
  4992. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4993. * @param points points which make up the curve
  4994. */
  4995. constructor(points: Vector3[]);
  4996. /**
  4997. * @returns the Curve3 stored array of successive Vector3
  4998. */
  4999. getPoints(): Vector3[];
  5000. /**
  5001. * @returns the computed length (float) of the curve.
  5002. */
  5003. length(): number;
  5004. /**
  5005. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5006. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5007. * curveA and curveB keep unchanged.
  5008. * @param curve the curve to continue from this curve
  5009. * @returns the newly constructed curve
  5010. */
  5011. continue(curve: DeepImmutable<Curve3>): Curve3;
  5012. private _computeLength;
  5013. }
  5014. }
  5015. declare module BABYLON {
  5016. /**
  5017. * This represents the main contract an easing function should follow.
  5018. * Easing functions are used throughout the animation system.
  5019. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5020. */
  5021. export interface IEasingFunction {
  5022. /**
  5023. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5024. * of the easing function.
  5025. * The link below provides some of the most common examples of easing functions.
  5026. * @see https://easings.net/
  5027. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5028. * @returns the corresponding value on the curve defined by the easing function
  5029. */
  5030. ease(gradient: number): number;
  5031. }
  5032. /**
  5033. * Base class used for every default easing function.
  5034. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5035. */
  5036. export class EasingFunction implements IEasingFunction {
  5037. /**
  5038. * Interpolation follows the mathematical formula associated with the easing function.
  5039. */
  5040. static readonly EASINGMODE_EASEIN: number;
  5041. /**
  5042. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5043. */
  5044. static readonly EASINGMODE_EASEOUT: number;
  5045. /**
  5046. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5047. */
  5048. static readonly EASINGMODE_EASEINOUT: number;
  5049. private _easingMode;
  5050. /**
  5051. * Sets the easing mode of the current function.
  5052. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5053. */
  5054. setEasingMode(easingMode: number): void;
  5055. /**
  5056. * Gets the current easing mode.
  5057. * @returns the easing mode
  5058. */
  5059. getEasingMode(): number;
  5060. /**
  5061. * @hidden
  5062. */
  5063. easeInCore(gradient: number): number;
  5064. /**
  5065. * Given an input gradient between 0 and 1, this returns the corresponding value
  5066. * of the easing function.
  5067. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5068. * @returns the corresponding value on the curve defined by the easing function
  5069. */
  5070. ease(gradient: number): number;
  5071. }
  5072. /**
  5073. * Easing function with a circle shape (see link below).
  5074. * @see https://easings.net/#easeInCirc
  5075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5076. */
  5077. export class CircleEase extends EasingFunction implements IEasingFunction {
  5078. /** @hidden */
  5079. easeInCore(gradient: number): number;
  5080. }
  5081. /**
  5082. * Easing function with a ease back shape (see link below).
  5083. * @see https://easings.net/#easeInBack
  5084. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5085. */
  5086. export class BackEase extends EasingFunction implements IEasingFunction {
  5087. /** Defines the amplitude of the function */
  5088. amplitude: number;
  5089. /**
  5090. * Instantiates a back ease easing
  5091. * @see https://easings.net/#easeInBack
  5092. * @param amplitude Defines the amplitude of the function
  5093. */
  5094. constructor(
  5095. /** Defines the amplitude of the function */
  5096. amplitude?: number);
  5097. /** @hidden */
  5098. easeInCore(gradient: number): number;
  5099. }
  5100. /**
  5101. * Easing function with a bouncing shape (see link below).
  5102. * @see https://easings.net/#easeInBounce
  5103. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5104. */
  5105. export class BounceEase extends EasingFunction implements IEasingFunction {
  5106. /** Defines the number of bounces */
  5107. bounces: number;
  5108. /** Defines the amplitude of the bounce */
  5109. bounciness: number;
  5110. /**
  5111. * Instantiates a bounce easing
  5112. * @see https://easings.net/#easeInBounce
  5113. * @param bounces Defines the number of bounces
  5114. * @param bounciness Defines the amplitude of the bounce
  5115. */
  5116. constructor(
  5117. /** Defines the number of bounces */
  5118. bounces?: number,
  5119. /** Defines the amplitude of the bounce */
  5120. bounciness?: number);
  5121. /** @hidden */
  5122. easeInCore(gradient: number): number;
  5123. }
  5124. /**
  5125. * Easing function with a power of 3 shape (see link below).
  5126. * @see https://easings.net/#easeInCubic
  5127. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5128. */
  5129. export class CubicEase extends EasingFunction implements IEasingFunction {
  5130. /** @hidden */
  5131. easeInCore(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with an elastic shape (see link below).
  5135. * @see https://easings.net/#easeInElastic
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5139. /** Defines the number of oscillations*/
  5140. oscillations: number;
  5141. /** Defines the amplitude of the oscillations*/
  5142. springiness: number;
  5143. /**
  5144. * Instantiates an elastic easing function
  5145. * @see https://easings.net/#easeInElastic
  5146. * @param oscillations Defines the number of oscillations
  5147. * @param springiness Defines the amplitude of the oscillations
  5148. */
  5149. constructor(
  5150. /** Defines the number of oscillations*/
  5151. oscillations?: number,
  5152. /** Defines the amplitude of the oscillations*/
  5153. springiness?: number);
  5154. /** @hidden */
  5155. easeInCore(gradient: number): number;
  5156. }
  5157. /**
  5158. * Easing function with an exponential shape (see link below).
  5159. * @see https://easings.net/#easeInExpo
  5160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5161. */
  5162. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5163. /** Defines the exponent of the function */
  5164. exponent: number;
  5165. /**
  5166. * Instantiates an exponential easing function
  5167. * @see https://easings.net/#easeInExpo
  5168. * @param exponent Defines the exponent of the function
  5169. */
  5170. constructor(
  5171. /** Defines the exponent of the function */
  5172. exponent?: number);
  5173. /** @hidden */
  5174. easeInCore(gradient: number): number;
  5175. }
  5176. /**
  5177. * Easing function with a power shape (see link below).
  5178. * @see https://easings.net/#easeInQuad
  5179. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5180. */
  5181. export class PowerEase extends EasingFunction implements IEasingFunction {
  5182. /** Defines the power of the function */
  5183. power: number;
  5184. /**
  5185. * Instantiates an power base easing function
  5186. * @see https://easings.net/#easeInQuad
  5187. * @param power Defines the power of the function
  5188. */
  5189. constructor(
  5190. /** Defines the power of the function */
  5191. power?: number);
  5192. /** @hidden */
  5193. easeInCore(gradient: number): number;
  5194. }
  5195. /**
  5196. * Easing function with a power of 2 shape (see link below).
  5197. * @see https://easings.net/#easeInQuad
  5198. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5199. */
  5200. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5201. /** @hidden */
  5202. easeInCore(gradient: number): number;
  5203. }
  5204. /**
  5205. * Easing function with a power of 4 shape (see link below).
  5206. * @see https://easings.net/#easeInQuart
  5207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5208. */
  5209. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5210. /** @hidden */
  5211. easeInCore(gradient: number): number;
  5212. }
  5213. /**
  5214. * Easing function with a power of 5 shape (see link below).
  5215. * @see https://easings.net/#easeInQuint
  5216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5217. */
  5218. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5219. /** @hidden */
  5220. easeInCore(gradient: number): number;
  5221. }
  5222. /**
  5223. * Easing function with a sin shape (see link below).
  5224. * @see https://easings.net/#easeInSine
  5225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5226. */
  5227. export class SineEase extends EasingFunction implements IEasingFunction {
  5228. /** @hidden */
  5229. easeInCore(gradient: number): number;
  5230. }
  5231. /**
  5232. * Easing function with a bezier shape (see link below).
  5233. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5235. */
  5236. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5237. /** Defines the x component of the start tangent in the bezier curve */
  5238. x1: number;
  5239. /** Defines the y component of the start tangent in the bezier curve */
  5240. y1: number;
  5241. /** Defines the x component of the end tangent in the bezier curve */
  5242. x2: number;
  5243. /** Defines the y component of the end tangent in the bezier curve */
  5244. y2: number;
  5245. /**
  5246. * Instantiates a bezier function
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @param x1 Defines the x component of the start tangent in the bezier curve
  5249. * @param y1 Defines the y component of the start tangent in the bezier curve
  5250. * @param x2 Defines the x component of the end tangent in the bezier curve
  5251. * @param y2 Defines the y component of the end tangent in the bezier curve
  5252. */
  5253. constructor(
  5254. /** Defines the x component of the start tangent in the bezier curve */
  5255. x1?: number,
  5256. /** Defines the y component of the start tangent in the bezier curve */
  5257. y1?: number,
  5258. /** Defines the x component of the end tangent in the bezier curve */
  5259. x2?: number,
  5260. /** Defines the y component of the end tangent in the bezier curve */
  5261. y2?: number);
  5262. /** @hidden */
  5263. easeInCore(gradient: number): number;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * Class used to hold a RBG color
  5269. */
  5270. export class Color3 {
  5271. /**
  5272. * Defines the red component (between 0 and 1, default is 0)
  5273. */
  5274. r: number;
  5275. /**
  5276. * Defines the green component (between 0 and 1, default is 0)
  5277. */
  5278. g: number;
  5279. /**
  5280. * Defines the blue component (between 0 and 1, default is 0)
  5281. */
  5282. b: number;
  5283. /**
  5284. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5285. * @param r defines the red component (between 0 and 1, default is 0)
  5286. * @param g defines the green component (between 0 and 1, default is 0)
  5287. * @param b defines the blue component (between 0 and 1, default is 0)
  5288. */
  5289. constructor(
  5290. /**
  5291. * Defines the red component (between 0 and 1, default is 0)
  5292. */
  5293. r?: number,
  5294. /**
  5295. * Defines the green component (between 0 and 1, default is 0)
  5296. */
  5297. g?: number,
  5298. /**
  5299. * Defines the blue component (between 0 and 1, default is 0)
  5300. */
  5301. b?: number);
  5302. /**
  5303. * Creates a string with the Color3 current values
  5304. * @returns the string representation of the Color3 object
  5305. */
  5306. toString(): string;
  5307. /**
  5308. * Returns the string "Color3"
  5309. * @returns "Color3"
  5310. */
  5311. getClassName(): string;
  5312. /**
  5313. * Compute the Color3 hash code
  5314. * @returns an unique number that can be used to hash Color3 objects
  5315. */
  5316. getHashCode(): number;
  5317. /**
  5318. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5319. * @param array defines the array where to store the r,g,b components
  5320. * @param index defines an optional index in the target array to define where to start storing values
  5321. * @returns the current Color3 object
  5322. */
  5323. toArray(array: FloatArray, index?: number): Color3;
  5324. /**
  5325. * Returns a new Color4 object from the current Color3 and the given alpha
  5326. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5327. * @returns a new Color4 object
  5328. */
  5329. toColor4(alpha?: number): Color4;
  5330. /**
  5331. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5332. * @returns the new array
  5333. */
  5334. asArray(): number[];
  5335. /**
  5336. * Returns the luminance value
  5337. * @returns a float value
  5338. */
  5339. toLuminance(): number;
  5340. /**
  5341. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5342. * @param otherColor defines the second operand
  5343. * @returns the new Color3 object
  5344. */
  5345. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5346. /**
  5347. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5348. * @param otherColor defines the second operand
  5349. * @param result defines the Color3 object where to store the result
  5350. * @returns the current Color3
  5351. */
  5352. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5353. /**
  5354. * Determines equality between Color3 objects
  5355. * @param otherColor defines the second operand
  5356. * @returns true if the rgb values are equal to the given ones
  5357. */
  5358. equals(otherColor: DeepImmutable<Color3>): boolean;
  5359. /**
  5360. * Determines equality between the current Color3 object and a set of r,b,g values
  5361. * @param r defines the red component to check
  5362. * @param g defines the green component to check
  5363. * @param b defines the blue component to check
  5364. * @returns true if the rgb values are equal to the given ones
  5365. */
  5366. equalsFloats(r: number, g: number, b: number): boolean;
  5367. /**
  5368. * Multiplies in place each rgb value by scale
  5369. * @param scale defines the scaling factor
  5370. * @returns the updated Color3
  5371. */
  5372. scale(scale: number): Color3;
  5373. /**
  5374. * Multiplies the rgb values by scale and stores the result into "result"
  5375. * @param scale defines the scaling factor
  5376. * @param result defines the Color3 object where to store the result
  5377. * @returns the unmodified current Color3
  5378. */
  5379. scaleToRef(scale: number, result: Color3): Color3;
  5380. /**
  5381. * Scale the current Color3 values by a factor and add the result to a given Color3
  5382. * @param scale defines the scale factor
  5383. * @param result defines color to store the result into
  5384. * @returns the unmodified current Color3
  5385. */
  5386. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5387. /**
  5388. * Clamps the rgb values by the min and max values and stores the result into "result"
  5389. * @param min defines minimum clamping value (default is 0)
  5390. * @param max defines maximum clamping value (default is 1)
  5391. * @param result defines color to store the result into
  5392. * @returns the original Color3
  5393. */
  5394. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5395. /**
  5396. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5397. * @param otherColor defines the second operand
  5398. * @returns the new Color3
  5399. */
  5400. add(otherColor: DeepImmutable<Color3>): Color3;
  5401. /**
  5402. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5403. * @param otherColor defines the second operand
  5404. * @param result defines Color3 object to store the result into
  5405. * @returns the unmodified current Color3
  5406. */
  5407. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5408. /**
  5409. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5410. * @param otherColor defines the second operand
  5411. * @returns the new Color3
  5412. */
  5413. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5414. /**
  5415. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5416. * @param otherColor defines the second operand
  5417. * @param result defines Color3 object to store the result into
  5418. * @returns the unmodified current Color3
  5419. */
  5420. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5421. /**
  5422. * Copy the current object
  5423. * @returns a new Color3 copied the current one
  5424. */
  5425. clone(): Color3;
  5426. /**
  5427. * Copies the rgb values from the source in the current Color3
  5428. * @param source defines the source Color3 object
  5429. * @returns the updated Color3 object
  5430. */
  5431. copyFrom(source: DeepImmutable<Color3>): Color3;
  5432. /**
  5433. * Updates the Color3 rgb values from the given floats
  5434. * @param r defines the red component to read from
  5435. * @param g defines the green component to read from
  5436. * @param b defines the blue component to read from
  5437. * @returns the current Color3 object
  5438. */
  5439. copyFromFloats(r: number, g: number, b: number): Color3;
  5440. /**
  5441. * Updates the Color3 rgb values from the given floats
  5442. * @param r defines the red component to read from
  5443. * @param g defines the green component to read from
  5444. * @param b defines the blue component to read from
  5445. * @returns the current Color3 object
  5446. */
  5447. set(r: number, g: number, b: number): Color3;
  5448. /**
  5449. * Compute the Color3 hexadecimal code as a string
  5450. * @returns a string containing the hexadecimal representation of the Color3 object
  5451. */
  5452. toHexString(): string;
  5453. /**
  5454. * Computes a new Color3 converted from the current one to linear space
  5455. * @returns a new Color3 object
  5456. */
  5457. toLinearSpace(): Color3;
  5458. /**
  5459. * Converts current color in rgb space to HSV values
  5460. * @returns a new color3 representing the HSV values
  5461. */
  5462. toHSV(): Color3;
  5463. /**
  5464. * Converts current color in rgb space to HSV values
  5465. * @param result defines the Color3 where to store the HSV values
  5466. */
  5467. toHSVToRef(result: Color3): void;
  5468. /**
  5469. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5470. * @param convertedColor defines the Color3 object where to store the linear space version
  5471. * @returns the unmodified Color3
  5472. */
  5473. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5474. /**
  5475. * Computes a new Color3 converted from the current one to gamma space
  5476. * @returns a new Color3 object
  5477. */
  5478. toGammaSpace(): Color3;
  5479. /**
  5480. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5481. * @param convertedColor defines the Color3 object where to store the gamma space version
  5482. * @returns the unmodified Color3
  5483. */
  5484. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5485. private static _BlackReadOnly;
  5486. /**
  5487. * Convert Hue, saturation and value to a Color3 (RGB)
  5488. * @param hue defines the hue
  5489. * @param saturation defines the saturation
  5490. * @param value defines the value
  5491. * @param result defines the Color3 where to store the RGB values
  5492. */
  5493. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5494. /**
  5495. * Creates a new Color3 from the string containing valid hexadecimal values
  5496. * @param hex defines a string containing valid hexadecimal values
  5497. * @returns a new Color3 object
  5498. */
  5499. static FromHexString(hex: string): Color3;
  5500. /**
  5501. * Creates a new Color3 from the starting index of the given array
  5502. * @param array defines the source array
  5503. * @param offset defines an offset in the source array
  5504. * @returns a new Color3 object
  5505. */
  5506. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5507. /**
  5508. * Creates a new Color3 from integer values (< 256)
  5509. * @param r defines the red component to read from (value between 0 and 255)
  5510. * @param g defines the green component to read from (value between 0 and 255)
  5511. * @param b defines the blue component to read from (value between 0 and 255)
  5512. * @returns a new Color3 object
  5513. */
  5514. static FromInts(r: number, g: number, b: number): Color3;
  5515. /**
  5516. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5517. * @param start defines the start Color3 value
  5518. * @param end defines the end Color3 value
  5519. * @param amount defines the gradient value between start and end
  5520. * @returns a new Color3 object
  5521. */
  5522. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5523. /**
  5524. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5525. * @param left defines the start value
  5526. * @param right defines the end value
  5527. * @param amount defines the gradient factor
  5528. * @param result defines the Color3 object where to store the result
  5529. */
  5530. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5531. /**
  5532. * Returns a Color3 value containing a red color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Red(): Color3;
  5536. /**
  5537. * Returns a Color3 value containing a green color
  5538. * @returns a new Color3 object
  5539. */
  5540. static Green(): Color3;
  5541. /**
  5542. * Returns a Color3 value containing a blue color
  5543. * @returns a new Color3 object
  5544. */
  5545. static Blue(): Color3;
  5546. /**
  5547. * Returns a Color3 value containing a black color
  5548. * @returns a new Color3 object
  5549. */
  5550. static Black(): Color3;
  5551. /**
  5552. * Gets a Color3 value containing a black color that must not be updated
  5553. */
  5554. static get BlackReadOnly(): DeepImmutable<Color3>;
  5555. /**
  5556. * Returns a Color3 value containing a white color
  5557. * @returns a new Color3 object
  5558. */
  5559. static White(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a purple color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Purple(): Color3;
  5565. /**
  5566. * Returns a Color3 value containing a magenta color
  5567. * @returns a new Color3 object
  5568. */
  5569. static Magenta(): Color3;
  5570. /**
  5571. * Returns a Color3 value containing a yellow color
  5572. * @returns a new Color3 object
  5573. */
  5574. static Yellow(): Color3;
  5575. /**
  5576. * Returns a Color3 value containing a gray color
  5577. * @returns a new Color3 object
  5578. */
  5579. static Gray(): Color3;
  5580. /**
  5581. * Returns a Color3 value containing a teal color
  5582. * @returns a new Color3 object
  5583. */
  5584. static Teal(): Color3;
  5585. /**
  5586. * Returns a Color3 value containing a random color
  5587. * @returns a new Color3 object
  5588. */
  5589. static Random(): Color3;
  5590. }
  5591. /**
  5592. * Class used to hold a RBGA color
  5593. */
  5594. export class Color4 {
  5595. /**
  5596. * Defines the red component (between 0 and 1, default is 0)
  5597. */
  5598. r: number;
  5599. /**
  5600. * Defines the green component (between 0 and 1, default is 0)
  5601. */
  5602. g: number;
  5603. /**
  5604. * Defines the blue component (between 0 and 1, default is 0)
  5605. */
  5606. b: number;
  5607. /**
  5608. * Defines the alpha component (between 0 and 1, default is 1)
  5609. */
  5610. a: number;
  5611. /**
  5612. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5613. * @param r defines the red component (between 0 and 1, default is 0)
  5614. * @param g defines the green component (between 0 and 1, default is 0)
  5615. * @param b defines the blue component (between 0 and 1, default is 0)
  5616. * @param a defines the alpha component (between 0 and 1, default is 1)
  5617. */
  5618. constructor(
  5619. /**
  5620. * Defines the red component (between 0 and 1, default is 0)
  5621. */
  5622. r?: number,
  5623. /**
  5624. * Defines the green component (between 0 and 1, default is 0)
  5625. */
  5626. g?: number,
  5627. /**
  5628. * Defines the blue component (between 0 and 1, default is 0)
  5629. */
  5630. b?: number,
  5631. /**
  5632. * Defines the alpha component (between 0 and 1, default is 1)
  5633. */
  5634. a?: number);
  5635. /**
  5636. * Adds in place the given Color4 values to the current Color4 object
  5637. * @param right defines the second operand
  5638. * @returns the current updated Color4 object
  5639. */
  5640. addInPlace(right: DeepImmutable<Color4>): Color4;
  5641. /**
  5642. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5643. * @returns the new array
  5644. */
  5645. asArray(): number[];
  5646. /**
  5647. * Stores from the starting index in the given array the Color4 successive values
  5648. * @param array defines the array where to store the r,g,b components
  5649. * @param index defines an optional index in the target array to define where to start storing values
  5650. * @returns the current Color4 object
  5651. */
  5652. toArray(array: number[], index?: number): Color4;
  5653. /**
  5654. * Determines equality between Color4 objects
  5655. * @param otherColor defines the second operand
  5656. * @returns true if the rgba values are equal to the given ones
  5657. */
  5658. equals(otherColor: DeepImmutable<Color4>): boolean;
  5659. /**
  5660. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5661. * @param right defines the second operand
  5662. * @returns a new Color4 object
  5663. */
  5664. add(right: DeepImmutable<Color4>): Color4;
  5665. /**
  5666. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5667. * @param right defines the second operand
  5668. * @returns a new Color4 object
  5669. */
  5670. subtract(right: DeepImmutable<Color4>): Color4;
  5671. /**
  5672. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5673. * @param right defines the second operand
  5674. * @param result defines the Color4 object where to store the result
  5675. * @returns the current Color4 object
  5676. */
  5677. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5678. /**
  5679. * Creates a new Color4 with the current Color4 values multiplied by scale
  5680. * @param scale defines the scaling factor to apply
  5681. * @returns a new Color4 object
  5682. */
  5683. scale(scale: number): Color4;
  5684. /**
  5685. * Multiplies the current Color4 values by scale and stores the result in "result"
  5686. * @param scale defines the scaling factor to apply
  5687. * @param result defines the Color4 object where to store the result
  5688. * @returns the current unmodified Color4
  5689. */
  5690. scaleToRef(scale: number, result: Color4): Color4;
  5691. /**
  5692. * Scale the current Color4 values by a factor and add the result to a given Color4
  5693. * @param scale defines the scale factor
  5694. * @param result defines the Color4 object where to store the result
  5695. * @returns the unmodified current Color4
  5696. */
  5697. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5698. /**
  5699. * Clamps the rgb values by the min and max values and stores the result into "result"
  5700. * @param min defines minimum clamping value (default is 0)
  5701. * @param max defines maximum clamping value (default is 1)
  5702. * @param result defines color to store the result into.
  5703. * @returns the cuurent Color4
  5704. */
  5705. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5706. /**
  5707. * Multipy an Color4 value by another and return a new Color4 object
  5708. * @param color defines the Color4 value to multiply by
  5709. * @returns a new Color4 object
  5710. */
  5711. multiply(color: Color4): Color4;
  5712. /**
  5713. * Multipy a Color4 value by another and push the result in a reference value
  5714. * @param color defines the Color4 value to multiply by
  5715. * @param result defines the Color4 to fill the result in
  5716. * @returns the result Color4
  5717. */
  5718. multiplyToRef(color: Color4, result: Color4): Color4;
  5719. /**
  5720. * Creates a string with the Color4 current values
  5721. * @returns the string representation of the Color4 object
  5722. */
  5723. toString(): string;
  5724. /**
  5725. * Returns the string "Color4"
  5726. * @returns "Color4"
  5727. */
  5728. getClassName(): string;
  5729. /**
  5730. * Compute the Color4 hash code
  5731. * @returns an unique number that can be used to hash Color4 objects
  5732. */
  5733. getHashCode(): number;
  5734. /**
  5735. * Creates a new Color4 copied from the current one
  5736. * @returns a new Color4 object
  5737. */
  5738. clone(): Color4;
  5739. /**
  5740. * Copies the given Color4 values into the current one
  5741. * @param source defines the source Color4 object
  5742. * @returns the current updated Color4 object
  5743. */
  5744. copyFrom(source: Color4): Color4;
  5745. /**
  5746. * Copies the given float values into the current one
  5747. * @param r defines the red component to read from
  5748. * @param g defines the green component to read from
  5749. * @param b defines the blue component to read from
  5750. * @param a defines the alpha component to read from
  5751. * @returns the current updated Color4 object
  5752. */
  5753. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5754. /**
  5755. * Copies the given float values into the current one
  5756. * @param r defines the red component to read from
  5757. * @param g defines the green component to read from
  5758. * @param b defines the blue component to read from
  5759. * @param a defines the alpha component to read from
  5760. * @returns the current updated Color4 object
  5761. */
  5762. set(r: number, g: number, b: number, a: number): Color4;
  5763. /**
  5764. * Compute the Color4 hexadecimal code as a string
  5765. * @returns a string containing the hexadecimal representation of the Color4 object
  5766. */
  5767. toHexString(): string;
  5768. /**
  5769. * Computes a new Color4 converted from the current one to linear space
  5770. * @returns a new Color4 object
  5771. */
  5772. toLinearSpace(): Color4;
  5773. /**
  5774. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5775. * @param convertedColor defines the Color4 object where to store the linear space version
  5776. * @returns the unmodified Color4
  5777. */
  5778. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5779. /**
  5780. * Computes a new Color4 converted from the current one to gamma space
  5781. * @returns a new Color4 object
  5782. */
  5783. toGammaSpace(): Color4;
  5784. /**
  5785. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5786. * @param convertedColor defines the Color4 object where to store the gamma space version
  5787. * @returns the unmodified Color4
  5788. */
  5789. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5790. /**
  5791. * Creates a new Color4 from the string containing valid hexadecimal values
  5792. * @param hex defines a string containing valid hexadecimal values
  5793. * @returns a new Color4 object
  5794. */
  5795. static FromHexString(hex: string): Color4;
  5796. /**
  5797. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5798. * @param left defines the start value
  5799. * @param right defines the end value
  5800. * @param amount defines the gradient factor
  5801. * @returns a new Color4 object
  5802. */
  5803. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5804. /**
  5805. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5806. * @param left defines the start value
  5807. * @param right defines the end value
  5808. * @param amount defines the gradient factor
  5809. * @param result defines the Color4 object where to store data
  5810. */
  5811. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5812. /**
  5813. * Creates a new Color4 from a Color3 and an alpha value
  5814. * @param color3 defines the source Color3 to read from
  5815. * @param alpha defines the alpha component (1.0 by default)
  5816. * @returns a new Color4 object
  5817. */
  5818. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5819. /**
  5820. * Creates a new Color4 from the starting index element of the given array
  5821. * @param array defines the source array to read from
  5822. * @param offset defines the offset in the source array
  5823. * @returns a new Color4 object
  5824. */
  5825. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5826. /**
  5827. * Creates a new Color3 from integer values (< 256)
  5828. * @param r defines the red component to read from (value between 0 and 255)
  5829. * @param g defines the green component to read from (value between 0 and 255)
  5830. * @param b defines the blue component to read from (value between 0 and 255)
  5831. * @param a defines the alpha component to read from (value between 0 and 255)
  5832. * @returns a new Color3 object
  5833. */
  5834. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5835. /**
  5836. * Check the content of a given array and convert it to an array containing RGBA data
  5837. * If the original array was already containing count * 4 values then it is returned directly
  5838. * @param colors defines the array to check
  5839. * @param count defines the number of RGBA data to expect
  5840. * @returns an array containing count * 4 values (RGBA)
  5841. */
  5842. static CheckColors4(colors: number[], count: number): number[];
  5843. }
  5844. /**
  5845. * @hidden
  5846. */
  5847. export class TmpColors {
  5848. static Color3: Color3[];
  5849. static Color4: Color4[];
  5850. }
  5851. }
  5852. declare module BABYLON {
  5853. /**
  5854. * Defines an interface which represents an animation key frame
  5855. */
  5856. export interface IAnimationKey {
  5857. /**
  5858. * Frame of the key frame
  5859. */
  5860. frame: number;
  5861. /**
  5862. * Value at the specifies key frame
  5863. */
  5864. value: any;
  5865. /**
  5866. * The input tangent for the cubic hermite spline
  5867. */
  5868. inTangent?: any;
  5869. /**
  5870. * The output tangent for the cubic hermite spline
  5871. */
  5872. outTangent?: any;
  5873. /**
  5874. * The animation interpolation type
  5875. */
  5876. interpolation?: AnimationKeyInterpolation;
  5877. }
  5878. /**
  5879. * Enum for the animation key frame interpolation type
  5880. */
  5881. export enum AnimationKeyInterpolation {
  5882. /**
  5883. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5884. */
  5885. STEP = 1
  5886. }
  5887. }
  5888. declare module BABYLON {
  5889. /**
  5890. * Represents the range of an animation
  5891. */
  5892. export class AnimationRange {
  5893. /**The name of the animation range**/
  5894. name: string;
  5895. /**The starting frame of the animation */
  5896. from: number;
  5897. /**The ending frame of the animation*/
  5898. to: number;
  5899. /**
  5900. * Initializes the range of an animation
  5901. * @param name The name of the animation range
  5902. * @param from The starting frame of the animation
  5903. * @param to The ending frame of the animation
  5904. */
  5905. constructor(
  5906. /**The name of the animation range**/
  5907. name: string,
  5908. /**The starting frame of the animation */
  5909. from: number,
  5910. /**The ending frame of the animation*/
  5911. to: number);
  5912. /**
  5913. * Makes a copy of the animation range
  5914. * @returns A copy of the animation range
  5915. */
  5916. clone(): AnimationRange;
  5917. }
  5918. }
  5919. declare module BABYLON {
  5920. /**
  5921. * Composed of a frame, and an action function
  5922. */
  5923. export class AnimationEvent {
  5924. /** The frame for which the event is triggered **/
  5925. frame: number;
  5926. /** The event to perform when triggered **/
  5927. action: (currentFrame: number) => void;
  5928. /** Specifies if the event should be triggered only once**/
  5929. onlyOnce?: boolean | undefined;
  5930. /**
  5931. * Specifies if the animation event is done
  5932. */
  5933. isDone: boolean;
  5934. /**
  5935. * Initializes the animation event
  5936. * @param frame The frame for which the event is triggered
  5937. * @param action The event to perform when triggered
  5938. * @param onlyOnce Specifies if the event should be triggered only once
  5939. */
  5940. constructor(
  5941. /** The frame for which the event is triggered **/
  5942. frame: number,
  5943. /** The event to perform when triggered **/
  5944. action: (currentFrame: number) => void,
  5945. /** Specifies if the event should be triggered only once**/
  5946. onlyOnce?: boolean | undefined);
  5947. /** @hidden */
  5948. _clone(): AnimationEvent;
  5949. }
  5950. }
  5951. declare module BABYLON {
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module BABYLON {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module BABYLON {
  6103. /**
  6104. * @ignore
  6105. * This is a list of all the different input types that are available in the application.
  6106. * Fo instance: ArcRotateCameraGamepadInput...
  6107. */
  6108. export var CameraInputTypes: {};
  6109. /**
  6110. * This is the contract to implement in order to create a new input class.
  6111. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6112. */
  6113. export interface ICameraInput<TCamera extends Camera> {
  6114. /**
  6115. * Defines the camera the input is attached to.
  6116. */
  6117. camera: Nullable<TCamera>;
  6118. /**
  6119. * Gets the class name of the current intput.
  6120. * @returns the class name
  6121. */
  6122. getClassName(): string;
  6123. /**
  6124. * Get the friendly name associated with the input class.
  6125. * @returns the input friendly name
  6126. */
  6127. getSimpleName(): string;
  6128. /**
  6129. * Attach the input controls to a specific dom element to get the input from.
  6130. * @param element Defines the element the controls should be listened from
  6131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6132. */
  6133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6134. /**
  6135. * Detach the current controls from the specified dom element.
  6136. * @param element Defines the element to stop listening the inputs from
  6137. */
  6138. detachControl(element: Nullable<HTMLElement>): void;
  6139. /**
  6140. * Update the current camera state depending on the inputs that have been used this frame.
  6141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6142. */
  6143. checkInputs?: () => void;
  6144. }
  6145. /**
  6146. * Represents a map of input types to input instance or input index to input instance.
  6147. */
  6148. export interface CameraInputsMap<TCamera extends Camera> {
  6149. /**
  6150. * Accessor to the input by input type.
  6151. */
  6152. [name: string]: ICameraInput<TCamera>;
  6153. /**
  6154. * Accessor to the input by input index.
  6155. */
  6156. [idx: number]: ICameraInput<TCamera>;
  6157. }
  6158. /**
  6159. * This represents the input manager used within a camera.
  6160. * It helps dealing with all the different kind of input attached to a camera.
  6161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6162. */
  6163. export class CameraInputsManager<TCamera extends Camera> {
  6164. /**
  6165. * Defines the list of inputs attahed to the camera.
  6166. */
  6167. attached: CameraInputsMap<TCamera>;
  6168. /**
  6169. * Defines the dom element the camera is collecting inputs from.
  6170. * This is null if the controls have not been attached.
  6171. */
  6172. attachedElement: Nullable<HTMLElement>;
  6173. /**
  6174. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6175. */
  6176. noPreventDefault: boolean;
  6177. /**
  6178. * Defined the camera the input manager belongs to.
  6179. */
  6180. camera: TCamera;
  6181. /**
  6182. * Update the current camera state depending on the inputs that have been used this frame.
  6183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6184. */
  6185. checkInputs: () => void;
  6186. /**
  6187. * Instantiate a new Camera Input Manager.
  6188. * @param camera Defines the camera the input manager blongs to
  6189. */
  6190. constructor(camera: TCamera);
  6191. /**
  6192. * Add an input method to a camera
  6193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6194. * @param input camera input method
  6195. */
  6196. add(input: ICameraInput<TCamera>): void;
  6197. /**
  6198. * Remove a specific input method from a camera
  6199. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6200. * @param inputToRemove camera input method
  6201. */
  6202. remove(inputToRemove: ICameraInput<TCamera>): void;
  6203. /**
  6204. * Remove a specific input type from a camera
  6205. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6206. * @param inputType the type of the input to remove
  6207. */
  6208. removeByType(inputType: string): void;
  6209. private _addCheckInputs;
  6210. /**
  6211. * Attach the input controls to the currently attached dom element to listen the events from.
  6212. * @param input Defines the input to attach
  6213. */
  6214. attachInput(input: ICameraInput<TCamera>): void;
  6215. /**
  6216. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6217. * @param element Defines the dom element to collect the events from
  6218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6219. */
  6220. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6221. /**
  6222. * Detach the current manager inputs controls from a specific dom element.
  6223. * @param element Defines the dom element to collect the events from
  6224. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6225. */
  6226. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6227. /**
  6228. * Rebuild the dynamic inputCheck function from the current list of
  6229. * defined inputs in the manager.
  6230. */
  6231. rebuildInputCheck(): void;
  6232. /**
  6233. * Remove all attached input methods from a camera
  6234. */
  6235. clear(): void;
  6236. /**
  6237. * Serialize the current input manager attached to a camera.
  6238. * This ensures than once parsed,
  6239. * the input associated to the camera will be identical to the current ones
  6240. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6241. */
  6242. serialize(serializedCamera: any): void;
  6243. /**
  6244. * Parses an input manager serialized JSON to restore the previous list of inputs
  6245. * and states associated to a camera.
  6246. * @param parsedCamera Defines the JSON to parse
  6247. */
  6248. parse(parsedCamera: any): void;
  6249. }
  6250. }
  6251. declare module BABYLON {
  6252. /**
  6253. * Class used to store data that will be store in GPU memory
  6254. */
  6255. export class Buffer {
  6256. private _engine;
  6257. private _buffer;
  6258. /** @hidden */
  6259. _data: Nullable<DataArray>;
  6260. private _updatable;
  6261. private _instanced;
  6262. private _divisor;
  6263. /**
  6264. * Gets the byte stride.
  6265. */
  6266. readonly byteStride: number;
  6267. /**
  6268. * Constructor
  6269. * @param engine the engine
  6270. * @param data the data to use for this buffer
  6271. * @param updatable whether the data is updatable
  6272. * @param stride the stride (optional)
  6273. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6274. * @param instanced whether the buffer is instanced (optional)
  6275. * @param useBytes set to true if the stride in in bytes (optional)
  6276. * @param divisor sets an optional divisor for instances (1 by default)
  6277. */
  6278. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6279. /**
  6280. * Create a new VertexBuffer based on the current buffer
  6281. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6282. * @param offset defines offset in the buffer (0 by default)
  6283. * @param size defines the size in floats of attributes (position is 3 for instance)
  6284. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6285. * @param instanced defines if the vertex buffer contains indexed data
  6286. * @param useBytes defines if the offset and stride are in bytes *
  6287. * @param divisor sets an optional divisor for instances (1 by default)
  6288. * @returns the new vertex buffer
  6289. */
  6290. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6291. /**
  6292. * Gets a boolean indicating if the Buffer is updatable?
  6293. * @returns true if the buffer is updatable
  6294. */
  6295. isUpdatable(): boolean;
  6296. /**
  6297. * Gets current buffer's data
  6298. * @returns a DataArray or null
  6299. */
  6300. getData(): Nullable<DataArray>;
  6301. /**
  6302. * Gets underlying native buffer
  6303. * @returns underlying native buffer
  6304. */
  6305. getBuffer(): Nullable<DataBuffer>;
  6306. /**
  6307. * Gets the stride in float32 units (i.e. byte stride / 4).
  6308. * May not be an integer if the byte stride is not divisible by 4.
  6309. * @returns the stride in float32 units
  6310. * @deprecated Please use byteStride instead.
  6311. */
  6312. getStrideSize(): number;
  6313. /**
  6314. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6315. * @param data defines the data to store
  6316. */
  6317. create(data?: Nullable<DataArray>): void;
  6318. /** @hidden */
  6319. _rebuild(): void;
  6320. /**
  6321. * Update current buffer data
  6322. * @param data defines the data to store
  6323. */
  6324. update(data: DataArray): void;
  6325. /**
  6326. * Updates the data directly.
  6327. * @param data the new data
  6328. * @param offset the new offset
  6329. * @param vertexCount the vertex count (optional)
  6330. * @param useBytes set to true if the offset is in bytes
  6331. */
  6332. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6333. /**
  6334. * Release all resources
  6335. */
  6336. dispose(): void;
  6337. }
  6338. /**
  6339. * Specialized buffer used to store vertex data
  6340. */
  6341. export class VertexBuffer {
  6342. /** @hidden */
  6343. _buffer: Buffer;
  6344. private _kind;
  6345. private _size;
  6346. private _ownsBuffer;
  6347. private _instanced;
  6348. private _instanceDivisor;
  6349. /**
  6350. * The byte type.
  6351. */
  6352. static readonly BYTE: number;
  6353. /**
  6354. * The unsigned byte type.
  6355. */
  6356. static readonly UNSIGNED_BYTE: number;
  6357. /**
  6358. * The short type.
  6359. */
  6360. static readonly SHORT: number;
  6361. /**
  6362. * The unsigned short type.
  6363. */
  6364. static readonly UNSIGNED_SHORT: number;
  6365. /**
  6366. * The integer type.
  6367. */
  6368. static readonly INT: number;
  6369. /**
  6370. * The unsigned integer type.
  6371. */
  6372. static readonly UNSIGNED_INT: number;
  6373. /**
  6374. * The float type.
  6375. */
  6376. static readonly FLOAT: number;
  6377. /**
  6378. * Gets or sets the instance divisor when in instanced mode
  6379. */
  6380. get instanceDivisor(): number;
  6381. set instanceDivisor(value: number);
  6382. /**
  6383. * Gets the byte stride.
  6384. */
  6385. readonly byteStride: number;
  6386. /**
  6387. * Gets the byte offset.
  6388. */
  6389. readonly byteOffset: number;
  6390. /**
  6391. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6392. */
  6393. readonly normalized: boolean;
  6394. /**
  6395. * Gets the data type of each component in the array.
  6396. */
  6397. readonly type: number;
  6398. /**
  6399. * Constructor
  6400. * @param engine the engine
  6401. * @param data the data to use for this vertex buffer
  6402. * @param kind the vertex buffer kind
  6403. * @param updatable whether the data is updatable
  6404. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6405. * @param stride the stride (optional)
  6406. * @param instanced whether the buffer is instanced (optional)
  6407. * @param offset the offset of the data (optional)
  6408. * @param size the number of components (optional)
  6409. * @param type the type of the component (optional)
  6410. * @param normalized whether the data contains normalized data (optional)
  6411. * @param useBytes set to true if stride and offset are in bytes (optional)
  6412. * @param divisor defines the instance divisor to use (1 by default)
  6413. */
  6414. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6415. /** @hidden */
  6416. _rebuild(): void;
  6417. /**
  6418. * Returns the kind of the VertexBuffer (string)
  6419. * @returns a string
  6420. */
  6421. getKind(): string;
  6422. /**
  6423. * Gets a boolean indicating if the VertexBuffer is updatable?
  6424. * @returns true if the buffer is updatable
  6425. */
  6426. isUpdatable(): boolean;
  6427. /**
  6428. * Gets current buffer's data
  6429. * @returns a DataArray or null
  6430. */
  6431. getData(): Nullable<DataArray>;
  6432. /**
  6433. * Gets underlying native buffer
  6434. * @returns underlying native buffer
  6435. */
  6436. getBuffer(): Nullable<DataBuffer>;
  6437. /**
  6438. * Gets the stride in float32 units (i.e. byte stride / 4).
  6439. * May not be an integer if the byte stride is not divisible by 4.
  6440. * @returns the stride in float32 units
  6441. * @deprecated Please use byteStride instead.
  6442. */
  6443. getStrideSize(): number;
  6444. /**
  6445. * Returns the offset as a multiple of the type byte length.
  6446. * @returns the offset in bytes
  6447. * @deprecated Please use byteOffset instead.
  6448. */
  6449. getOffset(): number;
  6450. /**
  6451. * Returns the number of components per vertex attribute (integer)
  6452. * @returns the size in float
  6453. */
  6454. getSize(): number;
  6455. /**
  6456. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6457. * @returns true if this buffer is instanced
  6458. */
  6459. getIsInstanced(): boolean;
  6460. /**
  6461. * Returns the instancing divisor, zero for non-instanced (integer).
  6462. * @returns a number
  6463. */
  6464. getInstanceDivisor(): number;
  6465. /**
  6466. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6467. * @param data defines the data to store
  6468. */
  6469. create(data?: DataArray): void;
  6470. /**
  6471. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6472. * This function will create a new buffer if the current one is not updatable
  6473. * @param data defines the data to store
  6474. */
  6475. update(data: DataArray): void;
  6476. /**
  6477. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6478. * Returns the directly updated WebGLBuffer.
  6479. * @param data the new data
  6480. * @param offset the new offset
  6481. * @param useBytes set to true if the offset is in bytes
  6482. */
  6483. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6484. /**
  6485. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6486. */
  6487. dispose(): void;
  6488. /**
  6489. * Enumerates each value of this vertex buffer as numbers.
  6490. * @param count the number of values to enumerate
  6491. * @param callback the callback function called for each value
  6492. */
  6493. forEach(count: number, callback: (value: number, index: number) => void): void;
  6494. /**
  6495. * Positions
  6496. */
  6497. static readonly PositionKind: string;
  6498. /**
  6499. * Normals
  6500. */
  6501. static readonly NormalKind: string;
  6502. /**
  6503. * Tangents
  6504. */
  6505. static readonly TangentKind: string;
  6506. /**
  6507. * Texture coordinates
  6508. */
  6509. static readonly UVKind: string;
  6510. /**
  6511. * Texture coordinates 2
  6512. */
  6513. static readonly UV2Kind: string;
  6514. /**
  6515. * Texture coordinates 3
  6516. */
  6517. static readonly UV3Kind: string;
  6518. /**
  6519. * Texture coordinates 4
  6520. */
  6521. static readonly UV4Kind: string;
  6522. /**
  6523. * Texture coordinates 5
  6524. */
  6525. static readonly UV5Kind: string;
  6526. /**
  6527. * Texture coordinates 6
  6528. */
  6529. static readonly UV6Kind: string;
  6530. /**
  6531. * Colors
  6532. */
  6533. static readonly ColorKind: string;
  6534. /**
  6535. * Matrix indices (for bones)
  6536. */
  6537. static readonly MatricesIndicesKind: string;
  6538. /**
  6539. * Matrix weights (for bones)
  6540. */
  6541. static readonly MatricesWeightsKind: string;
  6542. /**
  6543. * Additional matrix indices (for bones)
  6544. */
  6545. static readonly MatricesIndicesExtraKind: string;
  6546. /**
  6547. * Additional matrix weights (for bones)
  6548. */
  6549. static readonly MatricesWeightsExtraKind: string;
  6550. /**
  6551. * Deduces the stride given a kind.
  6552. * @param kind The kind string to deduce
  6553. * @returns The deduced stride
  6554. */
  6555. static DeduceStride(kind: string): number;
  6556. /**
  6557. * Gets the byte length of the given type.
  6558. * @param type the type
  6559. * @returns the number of bytes
  6560. */
  6561. static GetTypeByteLength(type: number): number;
  6562. /**
  6563. * Enumerates each value of the given parameters as numbers.
  6564. * @param data the data to enumerate
  6565. * @param byteOffset the byte offset of the data
  6566. * @param byteStride the byte stride of the data
  6567. * @param componentCount the number of components per element
  6568. * @param componentType the type of the component
  6569. * @param count the number of values to enumerate
  6570. * @param normalized whether the data is normalized
  6571. * @param callback the callback function called for each value
  6572. */
  6573. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6574. private static _GetFloatValue;
  6575. }
  6576. }
  6577. declare module BABYLON {
  6578. /**
  6579. * @hidden
  6580. */
  6581. export class IntersectionInfo {
  6582. bu: Nullable<number>;
  6583. bv: Nullable<number>;
  6584. distance: number;
  6585. faceId: number;
  6586. subMeshId: number;
  6587. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6588. }
  6589. }
  6590. declare module BABYLON {
  6591. /**
  6592. * Represens a plane by the equation ax + by + cz + d = 0
  6593. */
  6594. export class Plane {
  6595. private static _TmpMatrix;
  6596. /**
  6597. * Normal of the plane (a,b,c)
  6598. */
  6599. normal: Vector3;
  6600. /**
  6601. * d component of the plane
  6602. */
  6603. d: number;
  6604. /**
  6605. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6606. * @param a a component of the plane
  6607. * @param b b component of the plane
  6608. * @param c c component of the plane
  6609. * @param d d component of the plane
  6610. */
  6611. constructor(a: number, b: number, c: number, d: number);
  6612. /**
  6613. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6614. */
  6615. asArray(): number[];
  6616. /**
  6617. * @returns a new plane copied from the current Plane.
  6618. */
  6619. clone(): Plane;
  6620. /**
  6621. * @returns the string "Plane".
  6622. */
  6623. getClassName(): string;
  6624. /**
  6625. * @returns the Plane hash code.
  6626. */
  6627. getHashCode(): number;
  6628. /**
  6629. * Normalize the current Plane in place.
  6630. * @returns the updated Plane.
  6631. */
  6632. normalize(): Plane;
  6633. /**
  6634. * Applies a transformation the plane and returns the result
  6635. * @param transformation the transformation matrix to be applied to the plane
  6636. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6637. */
  6638. transform(transformation: DeepImmutable<Matrix>): Plane;
  6639. /**
  6640. * Calcualtte the dot product between the point and the plane normal
  6641. * @param point point to calculate the dot product with
  6642. * @returns the dot product (float) of the point coordinates and the plane normal.
  6643. */
  6644. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6645. /**
  6646. * Updates the current Plane from the plane defined by the three given points.
  6647. * @param point1 one of the points used to contruct the plane
  6648. * @param point2 one of the points used to contruct the plane
  6649. * @param point3 one of the points used to contruct the plane
  6650. * @returns the updated Plane.
  6651. */
  6652. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6653. /**
  6654. * Checks if the plane is facing a given direction
  6655. * @param direction the direction to check if the plane is facing
  6656. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6657. * @returns True is the vector "direction" is the same side than the plane normal.
  6658. */
  6659. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6660. /**
  6661. * Calculates the distance to a point
  6662. * @param point point to calculate distance to
  6663. * @returns the signed distance (float) from the given point to the Plane.
  6664. */
  6665. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6666. /**
  6667. * Creates a plane from an array
  6668. * @param array the array to create a plane from
  6669. * @returns a new Plane from the given array.
  6670. */
  6671. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6672. /**
  6673. * Creates a plane from three points
  6674. * @param point1 point used to create the plane
  6675. * @param point2 point used to create the plane
  6676. * @param point3 point used to create the plane
  6677. * @returns a new Plane defined by the three given points.
  6678. */
  6679. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6680. /**
  6681. * Creates a plane from an origin point and a normal
  6682. * @param origin origin of the plane to be constructed
  6683. * @param normal normal of the plane to be constructed
  6684. * @returns a new Plane the normal vector to this plane at the given origin point.
  6685. * Note : the vector "normal" is updated because normalized.
  6686. */
  6687. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6688. /**
  6689. * Calculates the distance from a plane and a point
  6690. * @param origin origin of the plane to be constructed
  6691. * @param normal normal of the plane to be constructed
  6692. * @param point point to calculate distance to
  6693. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6694. */
  6695. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6696. }
  6697. }
  6698. declare module BABYLON {
  6699. /**
  6700. * Class used to store bounding sphere information
  6701. */
  6702. export class BoundingSphere {
  6703. /**
  6704. * Gets the center of the bounding sphere in local space
  6705. */
  6706. readonly center: Vector3;
  6707. /**
  6708. * Radius of the bounding sphere in local space
  6709. */
  6710. radius: number;
  6711. /**
  6712. * Gets the center of the bounding sphere in world space
  6713. */
  6714. readonly centerWorld: Vector3;
  6715. /**
  6716. * Radius of the bounding sphere in world space
  6717. */
  6718. radiusWorld: number;
  6719. /**
  6720. * Gets the minimum vector in local space
  6721. */
  6722. readonly minimum: Vector3;
  6723. /**
  6724. * Gets the maximum vector in local space
  6725. */
  6726. readonly maximum: Vector3;
  6727. private _worldMatrix;
  6728. private static readonly TmpVector3;
  6729. /**
  6730. * Creates a new bounding sphere
  6731. * @param min defines the minimum vector (in local space)
  6732. * @param max defines the maximum vector (in local space)
  6733. * @param worldMatrix defines the new world matrix
  6734. */
  6735. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6736. /**
  6737. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6738. * @param min defines the new minimum vector (in local space)
  6739. * @param max defines the new maximum vector (in local space)
  6740. * @param worldMatrix defines the new world matrix
  6741. */
  6742. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6743. /**
  6744. * Scale the current bounding sphere by applying a scale factor
  6745. * @param factor defines the scale factor to apply
  6746. * @returns the current bounding box
  6747. */
  6748. scale(factor: number): BoundingSphere;
  6749. /**
  6750. * Gets the world matrix of the bounding box
  6751. * @returns a matrix
  6752. */
  6753. getWorldMatrix(): DeepImmutable<Matrix>;
  6754. /** @hidden */
  6755. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6756. /**
  6757. * Tests if the bounding sphere is intersecting the frustum planes
  6758. * @param frustumPlanes defines the frustum planes to test
  6759. * @returns true if there is an intersection
  6760. */
  6761. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6762. /**
  6763. * Tests if the bounding sphere center is in between the frustum planes.
  6764. * Used for optimistic fast inclusion.
  6765. * @param frustumPlanes defines the frustum planes to test
  6766. * @returns true if the sphere center is in between the frustum planes
  6767. */
  6768. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6769. /**
  6770. * Tests if a point is inside the bounding sphere
  6771. * @param point defines the point to test
  6772. * @returns true if the point is inside the bounding sphere
  6773. */
  6774. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6775. /**
  6776. * Checks if two sphere intersct
  6777. * @param sphere0 sphere 0
  6778. * @param sphere1 sphere 1
  6779. * @returns true if the speres intersect
  6780. */
  6781. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6782. }
  6783. }
  6784. declare module BABYLON {
  6785. /**
  6786. * Class used to store bounding box information
  6787. */
  6788. export class BoundingBox implements ICullable {
  6789. /**
  6790. * Gets the 8 vectors representing the bounding box in local space
  6791. */
  6792. readonly vectors: Vector3[];
  6793. /**
  6794. * Gets the center of the bounding box in local space
  6795. */
  6796. readonly center: Vector3;
  6797. /**
  6798. * Gets the center of the bounding box in world space
  6799. */
  6800. readonly centerWorld: Vector3;
  6801. /**
  6802. * Gets the extend size in local space
  6803. */
  6804. readonly extendSize: Vector3;
  6805. /**
  6806. * Gets the extend size in world space
  6807. */
  6808. readonly extendSizeWorld: Vector3;
  6809. /**
  6810. * Gets the OBB (object bounding box) directions
  6811. */
  6812. readonly directions: Vector3[];
  6813. /**
  6814. * Gets the 8 vectors representing the bounding box in world space
  6815. */
  6816. readonly vectorsWorld: Vector3[];
  6817. /**
  6818. * Gets the minimum vector in world space
  6819. */
  6820. readonly minimumWorld: Vector3;
  6821. /**
  6822. * Gets the maximum vector in world space
  6823. */
  6824. readonly maximumWorld: Vector3;
  6825. /**
  6826. * Gets the minimum vector in local space
  6827. */
  6828. readonly minimum: Vector3;
  6829. /**
  6830. * Gets the maximum vector in local space
  6831. */
  6832. readonly maximum: Vector3;
  6833. private _worldMatrix;
  6834. private static readonly TmpVector3;
  6835. /**
  6836. * @hidden
  6837. */
  6838. _tag: number;
  6839. /**
  6840. * Creates a new bounding box
  6841. * @param min defines the minimum vector (in local space)
  6842. * @param max defines the maximum vector (in local space)
  6843. * @param worldMatrix defines the new world matrix
  6844. */
  6845. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6846. /**
  6847. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6848. * @param min defines the new minimum vector (in local space)
  6849. * @param max defines the new maximum vector (in local space)
  6850. * @param worldMatrix defines the new world matrix
  6851. */
  6852. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6853. /**
  6854. * Scale the current bounding box by applying a scale factor
  6855. * @param factor defines the scale factor to apply
  6856. * @returns the current bounding box
  6857. */
  6858. scale(factor: number): BoundingBox;
  6859. /**
  6860. * Gets the world matrix of the bounding box
  6861. * @returns a matrix
  6862. */
  6863. getWorldMatrix(): DeepImmutable<Matrix>;
  6864. /** @hidden */
  6865. _update(world: DeepImmutable<Matrix>): void;
  6866. /**
  6867. * Tests if the bounding box is intersecting the frustum planes
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @returns true if there is an intersection
  6870. */
  6871. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. /**
  6873. * Tests if the bounding box is entirely inside the frustum planes
  6874. * @param frustumPlanes defines the frustum planes to test
  6875. * @returns true if there is an inclusion
  6876. */
  6877. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6878. /**
  6879. * Tests if a point is inside the bounding box
  6880. * @param point defines the point to test
  6881. * @returns true if the point is inside the bounding box
  6882. */
  6883. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6884. /**
  6885. * Tests if the bounding box intersects with a bounding sphere
  6886. * @param sphere defines the sphere to test
  6887. * @returns true if there is an intersection
  6888. */
  6889. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6890. /**
  6891. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6892. * @param min defines the min vector to use
  6893. * @param max defines the max vector to use
  6894. * @returns true if there is an intersection
  6895. */
  6896. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6897. /**
  6898. * Tests if two bounding boxes are intersections
  6899. * @param box0 defines the first box to test
  6900. * @param box1 defines the second box to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6904. /**
  6905. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6906. * @param minPoint defines the minimum vector of the bounding box
  6907. * @param maxPoint defines the maximum vector of the bounding box
  6908. * @param sphereCenter defines the sphere center
  6909. * @param sphereRadius defines the sphere radius
  6910. * @returns true if there is an intersection
  6911. */
  6912. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6913. /**
  6914. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6915. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @return true if there is an inclusion
  6918. */
  6919. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6922. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6923. * @param frustumPlanes defines the frustum planes to test
  6924. * @return true if there is an intersection
  6925. */
  6926. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6927. }
  6928. }
  6929. declare module BABYLON {
  6930. /** @hidden */
  6931. export class Collider {
  6932. /** Define if a collision was found */
  6933. collisionFound: boolean;
  6934. /**
  6935. * Define last intersection point in local space
  6936. */
  6937. intersectionPoint: Vector3;
  6938. /**
  6939. * Define last collided mesh
  6940. */
  6941. collidedMesh: Nullable<AbstractMesh>;
  6942. private _collisionPoint;
  6943. private _planeIntersectionPoint;
  6944. private _tempVector;
  6945. private _tempVector2;
  6946. private _tempVector3;
  6947. private _tempVector4;
  6948. private _edge;
  6949. private _baseToVertex;
  6950. private _destinationPoint;
  6951. private _slidePlaneNormal;
  6952. private _displacementVector;
  6953. /** @hidden */
  6954. _radius: Vector3;
  6955. /** @hidden */
  6956. _retry: number;
  6957. private _velocity;
  6958. private _basePoint;
  6959. private _epsilon;
  6960. /** @hidden */
  6961. _velocityWorldLength: number;
  6962. /** @hidden */
  6963. _basePointWorld: Vector3;
  6964. private _velocityWorld;
  6965. private _normalizedVelocity;
  6966. /** @hidden */
  6967. _initialVelocity: Vector3;
  6968. /** @hidden */
  6969. _initialPosition: Vector3;
  6970. private _nearestDistance;
  6971. private _collisionMask;
  6972. get collisionMask(): number;
  6973. set collisionMask(mask: number);
  6974. /**
  6975. * Gets the plane normal used to compute the sliding response (in local space)
  6976. */
  6977. get slidePlaneNormal(): Vector3;
  6978. /** @hidden */
  6979. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6980. /** @hidden */
  6981. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6982. /** @hidden */
  6983. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6984. /** @hidden */
  6985. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6986. /** @hidden */
  6987. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6988. /** @hidden */
  6989. _getResponse(pos: Vector3, vel: Vector3): void;
  6990. }
  6991. }
  6992. declare module BABYLON {
  6993. /**
  6994. * Interface for cullable objects
  6995. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6996. */
  6997. export interface ICullable {
  6998. /**
  6999. * Checks if the object or part of the object is in the frustum
  7000. * @param frustumPlanes Camera near/planes
  7001. * @returns true if the object is in frustum otherwise false
  7002. */
  7003. isInFrustum(frustumPlanes: Plane[]): boolean;
  7004. /**
  7005. * Checks if a cullable object (mesh...) is in the camera frustum
  7006. * Unlike isInFrustum this cheks the full bounding box
  7007. * @param frustumPlanes Camera near/planes
  7008. * @returns true if the object is in frustum otherwise false
  7009. */
  7010. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7011. }
  7012. /**
  7013. * Info for a bounding data of a mesh
  7014. */
  7015. export class BoundingInfo implements ICullable {
  7016. /**
  7017. * Bounding box for the mesh
  7018. */
  7019. readonly boundingBox: BoundingBox;
  7020. /**
  7021. * Bounding sphere for the mesh
  7022. */
  7023. readonly boundingSphere: BoundingSphere;
  7024. private _isLocked;
  7025. private static readonly TmpVector3;
  7026. /**
  7027. * Constructs bounding info
  7028. * @param minimum min vector of the bounding box/sphere
  7029. * @param maximum max vector of the bounding box/sphere
  7030. * @param worldMatrix defines the new world matrix
  7031. */
  7032. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7033. /**
  7034. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7035. * @param min defines the new minimum vector (in local space)
  7036. * @param max defines the new maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7040. /**
  7041. * min vector of the bounding box/sphere
  7042. */
  7043. get minimum(): Vector3;
  7044. /**
  7045. * max vector of the bounding box/sphere
  7046. */
  7047. get maximum(): Vector3;
  7048. /**
  7049. * If the info is locked and won't be updated to avoid perf overhead
  7050. */
  7051. get isLocked(): boolean;
  7052. set isLocked(value: boolean);
  7053. /**
  7054. * Updates the bounding sphere and box
  7055. * @param world world matrix to be used to update
  7056. */
  7057. update(world: DeepImmutable<Matrix>): void;
  7058. /**
  7059. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7060. * @param center New center of the bounding info
  7061. * @param extend New extend of the bounding info
  7062. * @returns the current bounding info
  7063. */
  7064. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7065. /**
  7066. * Scale the current bounding info by applying a scale factor
  7067. * @param factor defines the scale factor to apply
  7068. * @returns the current bounding info
  7069. */
  7070. scale(factor: number): BoundingInfo;
  7071. /**
  7072. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7073. * @param frustumPlanes defines the frustum to test
  7074. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7075. * @returns true if the bounding info is in the frustum planes
  7076. */
  7077. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7078. /**
  7079. * Gets the world distance between the min and max points of the bounding box
  7080. */
  7081. get diagonalLength(): number;
  7082. /**
  7083. * Checks if a cullable object (mesh...) is in the camera frustum
  7084. * Unlike isInFrustum this cheks the full bounding box
  7085. * @param frustumPlanes Camera near/planes
  7086. * @returns true if the object is in frustum otherwise false
  7087. */
  7088. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7089. /** @hidden */
  7090. _checkCollision(collider: Collider): boolean;
  7091. /**
  7092. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7093. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7094. * @param point the point to check intersection with
  7095. * @returns if the point intersects
  7096. */
  7097. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7098. /**
  7099. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7100. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7101. * @param boundingInfo the bounding info to check intersection with
  7102. * @param precise if the intersection should be done using OBB
  7103. * @returns if the bounding info intersects
  7104. */
  7105. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7106. }
  7107. }
  7108. declare module BABYLON {
  7109. /**
  7110. * Extracts minimum and maximum values from a list of indexed positions
  7111. * @param positions defines the positions to use
  7112. * @param indices defines the indices to the positions
  7113. * @param indexStart defines the start index
  7114. * @param indexCount defines the end index
  7115. * @param bias defines bias value to add to the result
  7116. * @return minimum and maximum values
  7117. */
  7118. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7119. minimum: Vector3;
  7120. maximum: Vector3;
  7121. };
  7122. /**
  7123. * Extracts minimum and maximum values from a list of positions
  7124. * @param positions defines the positions to use
  7125. * @param start defines the start index in the positions array
  7126. * @param count defines the number of positions to handle
  7127. * @param bias defines bias value to add to the result
  7128. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7129. * @return minimum and maximum values
  7130. */
  7131. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7132. minimum: Vector3;
  7133. maximum: Vector3;
  7134. };
  7135. }
  7136. declare module BABYLON {
  7137. /** @hidden */
  7138. export class WebGLDataBuffer extends DataBuffer {
  7139. private _buffer;
  7140. constructor(resource: WebGLBuffer);
  7141. get underlyingResource(): any;
  7142. }
  7143. }
  7144. declare module BABYLON {
  7145. /** @hidden */
  7146. export class WebGLPipelineContext implements IPipelineContext {
  7147. engine: ThinEngine;
  7148. program: Nullable<WebGLProgram>;
  7149. context?: WebGLRenderingContext;
  7150. vertexShader?: WebGLShader;
  7151. fragmentShader?: WebGLShader;
  7152. isParallelCompiled: boolean;
  7153. onCompiled?: () => void;
  7154. transformFeedback?: WebGLTransformFeedback | null;
  7155. vertexCompilationError: Nullable<string>;
  7156. fragmentCompilationError: Nullable<string>;
  7157. programLinkError: Nullable<string>;
  7158. programValidationError: Nullable<string>;
  7159. get isAsync(): boolean;
  7160. get isReady(): boolean;
  7161. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7162. _getVertexShaderCode(): string | null;
  7163. _getFragmentShaderCode(): string | null;
  7164. }
  7165. }
  7166. declare module BABYLON {
  7167. interface ThinEngine {
  7168. /**
  7169. * Create an uniform buffer
  7170. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7171. * @param elements defines the content of the uniform buffer
  7172. * @returns the webGL uniform buffer
  7173. */
  7174. createUniformBuffer(elements: FloatArray): DataBuffer;
  7175. /**
  7176. * Create a dynamic uniform buffer
  7177. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7178. * @param elements defines the content of the uniform buffer
  7179. * @returns the webGL uniform buffer
  7180. */
  7181. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7182. /**
  7183. * Update an existing uniform buffer
  7184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7185. * @param uniformBuffer defines the target uniform buffer
  7186. * @param elements defines the content to update
  7187. * @param offset defines the offset in the uniform buffer where update should start
  7188. * @param count defines the size of the data to update
  7189. */
  7190. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7191. /**
  7192. * Bind an uniform buffer to the current webGL context
  7193. * @param buffer defines the buffer to bind
  7194. */
  7195. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7196. /**
  7197. * Bind a buffer to the current webGL context at a given location
  7198. * @param buffer defines the buffer to bind
  7199. * @param location defines the index where to bind the buffer
  7200. */
  7201. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7202. /**
  7203. * Bind a specific block at a given index in a specific shader program
  7204. * @param pipelineContext defines the pipeline context to use
  7205. * @param blockName defines the block name
  7206. * @param index defines the index where to bind the block
  7207. */
  7208. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7209. }
  7210. }
  7211. declare module BABYLON {
  7212. /**
  7213. * Uniform buffer objects.
  7214. *
  7215. * Handles blocks of uniform on the GPU.
  7216. *
  7217. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7218. *
  7219. * For more information, please refer to :
  7220. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7221. */
  7222. export class UniformBuffer {
  7223. private _engine;
  7224. private _buffer;
  7225. private _data;
  7226. private _bufferData;
  7227. private _dynamic?;
  7228. private _uniformLocations;
  7229. private _uniformSizes;
  7230. private _uniformLocationPointer;
  7231. private _needSync;
  7232. private _noUBO;
  7233. private _currentEffect;
  7234. /** @hidden */
  7235. _alreadyBound: boolean;
  7236. private static _MAX_UNIFORM_SIZE;
  7237. private static _tempBuffer;
  7238. /**
  7239. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7240. * This is dynamic to allow compat with webgl 1 and 2.
  7241. * You will need to pass the name of the uniform as well as the value.
  7242. */
  7243. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7244. /**
  7245. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7246. * This is dynamic to allow compat with webgl 1 and 2.
  7247. * You will need to pass the name of the uniform as well as the value.
  7248. */
  7249. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7250. /**
  7251. * Lambda to Update a single float in a uniform buffer.
  7252. * This is dynamic to allow compat with webgl 1 and 2.
  7253. * You will need to pass the name of the uniform as well as the value.
  7254. */
  7255. updateFloat: (name: string, x: number) => void;
  7256. /**
  7257. * Lambda to Update a vec2 of float in a uniform buffer.
  7258. * This is dynamic to allow compat with webgl 1 and 2.
  7259. * You will need to pass the name of the uniform as well as the value.
  7260. */
  7261. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7262. /**
  7263. * Lambda to Update a vec3 of float in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7268. /**
  7269. * Lambda to Update a vec4 of float in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7274. /**
  7275. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateMatrix: (name: string, mat: Matrix) => void;
  7280. /**
  7281. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateVector3: (name: string, vector: Vector3) => void;
  7286. /**
  7287. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateVector4: (name: string, vector: Vector4) => void;
  7292. /**
  7293. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7298. /**
  7299. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7304. /**
  7305. * Instantiates a new Uniform buffer objects.
  7306. *
  7307. * Handles blocks of uniform on the GPU.
  7308. *
  7309. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7310. *
  7311. * For more information, please refer to :
  7312. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7313. * @param engine Define the engine the buffer is associated with
  7314. * @param data Define the data contained in the buffer
  7315. * @param dynamic Define if the buffer is updatable
  7316. */
  7317. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7318. /**
  7319. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7320. * or just falling back on setUniformXXX calls.
  7321. */
  7322. get useUbo(): boolean;
  7323. /**
  7324. * Indicates if the WebGL underlying uniform buffer is in sync
  7325. * with the javascript cache data.
  7326. */
  7327. get isSync(): boolean;
  7328. /**
  7329. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7330. * Also, a dynamic UniformBuffer will disable cache verification and always
  7331. * update the underlying WebGL uniform buffer to the GPU.
  7332. * @returns if Dynamic, otherwise false
  7333. */
  7334. isDynamic(): boolean;
  7335. /**
  7336. * The data cache on JS side.
  7337. * @returns the underlying data as a float array
  7338. */
  7339. getData(): Float32Array;
  7340. /**
  7341. * The underlying WebGL Uniform buffer.
  7342. * @returns the webgl buffer
  7343. */
  7344. getBuffer(): Nullable<DataBuffer>;
  7345. /**
  7346. * std140 layout specifies how to align data within an UBO structure.
  7347. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7348. * for specs.
  7349. */
  7350. private _fillAlignment;
  7351. /**
  7352. * Adds an uniform in the buffer.
  7353. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7354. * for the layout to be correct !
  7355. * @param name Name of the uniform, as used in the uniform block in the shader.
  7356. * @param size Data size, or data directly.
  7357. */
  7358. addUniform(name: string, size: number | number[]): void;
  7359. /**
  7360. * Adds a Matrix 4x4 to the uniform buffer.
  7361. * @param name Name of the uniform, as used in the uniform block in the shader.
  7362. * @param mat A 4x4 matrix.
  7363. */
  7364. addMatrix(name: string, mat: Matrix): void;
  7365. /**
  7366. * Adds a vec2 to the uniform buffer.
  7367. * @param name Name of the uniform, as used in the uniform block in the shader.
  7368. * @param x Define the x component value of the vec2
  7369. * @param y Define the y component value of the vec2
  7370. */
  7371. addFloat2(name: string, x: number, y: number): void;
  7372. /**
  7373. * Adds a vec3 to the uniform buffer.
  7374. * @param name Name of the uniform, as used in the uniform block in the shader.
  7375. * @param x Define the x component value of the vec3
  7376. * @param y Define the y component value of the vec3
  7377. * @param z Define the z component value of the vec3
  7378. */
  7379. addFloat3(name: string, x: number, y: number, z: number): void;
  7380. /**
  7381. * Adds a vec3 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param color Define the vec3 from a Color
  7384. */
  7385. addColor3(name: string, color: Color3): void;
  7386. /**
  7387. * Adds a vec4 to the uniform buffer.
  7388. * @param name Name of the uniform, as used in the uniform block in the shader.
  7389. * @param color Define the rgb components from a Color
  7390. * @param alpha Define the a component of the vec4
  7391. */
  7392. addColor4(name: string, color: Color3, alpha: number): void;
  7393. /**
  7394. * Adds a vec3 to the uniform buffer.
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param vector Define the vec3 components from a Vector
  7397. */
  7398. addVector3(name: string, vector: Vector3): void;
  7399. /**
  7400. * Adds a Matrix 3x3 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. */
  7403. addMatrix3x3(name: string): void;
  7404. /**
  7405. * Adds a Matrix 2x2 to the uniform buffer.
  7406. * @param name Name of the uniform, as used in the uniform block in the shader.
  7407. */
  7408. addMatrix2x2(name: string): void;
  7409. /**
  7410. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7411. */
  7412. create(): void;
  7413. /** @hidden */
  7414. _rebuild(): void;
  7415. /**
  7416. * Updates the WebGL Uniform Buffer on the GPU.
  7417. * If the `dynamic` flag is set to true, no cache comparison is done.
  7418. * Otherwise, the buffer will be updated only if the cache differs.
  7419. */
  7420. update(): void;
  7421. /**
  7422. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7423. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7424. * @param data Define the flattened data
  7425. * @param size Define the size of the data.
  7426. */
  7427. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7428. private _valueCache;
  7429. private _cacheMatrix;
  7430. private _updateMatrix3x3ForUniform;
  7431. private _updateMatrix3x3ForEffect;
  7432. private _updateMatrix2x2ForEffect;
  7433. private _updateMatrix2x2ForUniform;
  7434. private _updateFloatForEffect;
  7435. private _updateFloatForUniform;
  7436. private _updateFloat2ForEffect;
  7437. private _updateFloat2ForUniform;
  7438. private _updateFloat3ForEffect;
  7439. private _updateFloat3ForUniform;
  7440. private _updateFloat4ForEffect;
  7441. private _updateFloat4ForUniform;
  7442. private _updateMatrixForEffect;
  7443. private _updateMatrixForUniform;
  7444. private _updateVector3ForEffect;
  7445. private _updateVector3ForUniform;
  7446. private _updateVector4ForEffect;
  7447. private _updateVector4ForUniform;
  7448. private _updateColor3ForEffect;
  7449. private _updateColor3ForUniform;
  7450. private _updateColor4ForEffect;
  7451. private _updateColor4ForUniform;
  7452. /**
  7453. * Sets a sampler uniform on the effect.
  7454. * @param name Define the name of the sampler.
  7455. * @param texture Define the texture to set in the sampler
  7456. */
  7457. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7458. /**
  7459. * Directly updates the value of the uniform in the cache AND on the GPU.
  7460. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7461. * @param data Define the flattened data
  7462. */
  7463. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7464. /**
  7465. * Binds this uniform buffer to an effect.
  7466. * @param effect Define the effect to bind the buffer to
  7467. * @param name Name of the uniform block in the shader.
  7468. */
  7469. bindToEffect(effect: Effect, name: string): void;
  7470. /**
  7471. * Disposes the uniform buffer.
  7472. */
  7473. dispose(): void;
  7474. }
  7475. }
  7476. declare module BABYLON {
  7477. /**
  7478. * Enum that determines the text-wrapping mode to use.
  7479. */
  7480. export enum InspectableType {
  7481. /**
  7482. * Checkbox for booleans
  7483. */
  7484. Checkbox = 0,
  7485. /**
  7486. * Sliders for numbers
  7487. */
  7488. Slider = 1,
  7489. /**
  7490. * Vector3
  7491. */
  7492. Vector3 = 2,
  7493. /**
  7494. * Quaternions
  7495. */
  7496. Quaternion = 3,
  7497. /**
  7498. * Color3
  7499. */
  7500. Color3 = 4,
  7501. /**
  7502. * String
  7503. */
  7504. String = 5
  7505. }
  7506. /**
  7507. * Interface used to define custom inspectable properties.
  7508. * This interface is used by the inspector to display custom property grids
  7509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7510. */
  7511. export interface IInspectable {
  7512. /**
  7513. * Gets the label to display
  7514. */
  7515. label: string;
  7516. /**
  7517. * Gets the name of the property to edit
  7518. */
  7519. propertyName: string;
  7520. /**
  7521. * Gets the type of the editor to use
  7522. */
  7523. type: InspectableType;
  7524. /**
  7525. * Gets the minimum value of the property when using in "slider" mode
  7526. */
  7527. min?: number;
  7528. /**
  7529. * Gets the maximum value of the property when using in "slider" mode
  7530. */
  7531. max?: number;
  7532. /**
  7533. * Gets the setp to use when using in "slider" mode
  7534. */
  7535. step?: number;
  7536. }
  7537. }
  7538. declare module BABYLON {
  7539. /**
  7540. * Class used to provide helper for timing
  7541. */
  7542. export class TimingTools {
  7543. /**
  7544. * Polyfill for setImmediate
  7545. * @param action defines the action to execute after the current execution block
  7546. */
  7547. static SetImmediate(action: () => void): void;
  7548. }
  7549. }
  7550. declare module BABYLON {
  7551. /**
  7552. * Class used to enable instatition of objects by class name
  7553. */
  7554. export class InstantiationTools {
  7555. /**
  7556. * Use this object to register external classes like custom textures or material
  7557. * to allow the laoders to instantiate them
  7558. */
  7559. static RegisteredExternalClasses: {
  7560. [key: string]: Object;
  7561. };
  7562. /**
  7563. * Tries to instantiate a new object from a given class name
  7564. * @param className defines the class name to instantiate
  7565. * @returns the new object or null if the system was not able to do the instantiation
  7566. */
  7567. static Instantiate(className: string): any;
  7568. }
  7569. }
  7570. declare module BABYLON {
  7571. /**
  7572. * Define options used to create a depth texture
  7573. */
  7574. export class DepthTextureCreationOptions {
  7575. /** Specifies whether or not a stencil should be allocated in the texture */
  7576. generateStencil?: boolean;
  7577. /** Specifies whether or not bilinear filtering is enable on the texture */
  7578. bilinearFiltering?: boolean;
  7579. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7580. comparisonFunction?: number;
  7581. /** Specifies if the created texture is a cube texture */
  7582. isCube?: boolean;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. interface ThinEngine {
  7587. /**
  7588. * Creates a depth stencil cube texture.
  7589. * This is only available in WebGL 2.
  7590. * @param size The size of face edge in the cube texture.
  7591. * @param options The options defining the cube texture.
  7592. * @returns The cube texture
  7593. */
  7594. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7595. /**
  7596. * Creates a cube texture
  7597. * @param rootUrl defines the url where the files to load is located
  7598. * @param scene defines the current scene
  7599. * @param files defines the list of files to load (1 per face)
  7600. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7601. * @param onLoad defines an optional callback raised when the texture is loaded
  7602. * @param onError defines an optional callback raised if there is an issue to load the texture
  7603. * @param format defines the format of the data
  7604. * @param forcedExtension defines the extension to use to pick the right loader
  7605. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7606. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7607. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7608. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7609. * @returns the cube texture as an InternalTexture
  7610. */
  7611. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7612. /**
  7613. * Creates a cube texture
  7614. * @param rootUrl defines the url where the files to load is located
  7615. * @param scene defines the current scene
  7616. * @param files defines the list of files to load (1 per face)
  7617. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7618. * @param onLoad defines an optional callback raised when the texture is loaded
  7619. * @param onError defines an optional callback raised if there is an issue to load the texture
  7620. * @param format defines the format of the data
  7621. * @param forcedExtension defines the extension to use to pick the right loader
  7622. * @returns the cube texture as an InternalTexture
  7623. */
  7624. 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;
  7625. /**
  7626. * Creates a cube texture
  7627. * @param rootUrl defines the url where the files to load is located
  7628. * @param scene defines the current scene
  7629. * @param files defines the list of files to load (1 per face)
  7630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7631. * @param onLoad defines an optional callback raised when the texture is loaded
  7632. * @param onError defines an optional callback raised if there is an issue to load the texture
  7633. * @param format defines the format of the data
  7634. * @param forcedExtension defines the extension to use to pick the right loader
  7635. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7636. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7637. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7638. * @returns the cube texture as an InternalTexture
  7639. */
  7640. 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;
  7641. /** @hidden */
  7642. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7643. /** @hidden */
  7644. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7645. /** @hidden */
  7646. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7647. /** @hidden */
  7648. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7649. /**
  7650. * @hidden
  7651. */
  7652. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7653. }
  7654. }
  7655. declare module BABYLON {
  7656. /**
  7657. * Class for creating a cube texture
  7658. */
  7659. export class CubeTexture extends BaseTexture {
  7660. private _delayedOnLoad;
  7661. /**
  7662. * Observable triggered once the texture has been loaded.
  7663. */
  7664. onLoadObservable: Observable<CubeTexture>;
  7665. /**
  7666. * The url of the texture
  7667. */
  7668. url: string;
  7669. /**
  7670. * Gets or sets the center of the bounding box associated with the cube texture.
  7671. * It must define where the camera used to render the texture was set
  7672. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7673. */
  7674. boundingBoxPosition: Vector3;
  7675. private _boundingBoxSize;
  7676. /**
  7677. * Gets or sets the size of the bounding box associated with the cube texture
  7678. * When defined, the cubemap will switch to local mode
  7679. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7680. * @example https://www.babylonjs-playground.com/#RNASML
  7681. */
  7682. set boundingBoxSize(value: Vector3);
  7683. /**
  7684. * Returns the bounding box size
  7685. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7686. */
  7687. get boundingBoxSize(): Vector3;
  7688. protected _rotationY: number;
  7689. /**
  7690. * Sets texture matrix rotation angle around Y axis in radians.
  7691. */
  7692. set rotationY(value: number);
  7693. /**
  7694. * Gets texture matrix rotation angle around Y axis radians.
  7695. */
  7696. get rotationY(): number;
  7697. /**
  7698. * Are mip maps generated for this texture or not.
  7699. */
  7700. get noMipmap(): boolean;
  7701. private _noMipmap;
  7702. private _files;
  7703. protected _forcedExtension: Nullable<string>;
  7704. private _extensions;
  7705. private _textureMatrix;
  7706. private _format;
  7707. private _createPolynomials;
  7708. /** @hidden */
  7709. _prefiltered: boolean;
  7710. /**
  7711. * Creates a cube texture from an array of image urls
  7712. * @param files defines an array of image urls
  7713. * @param scene defines the hosting scene
  7714. * @param noMipmap specifies if mip maps are not used
  7715. * @returns a cube texture
  7716. */
  7717. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7718. /**
  7719. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7720. * @param url defines the url of the prefiltered texture
  7721. * @param scene defines the scene the texture is attached to
  7722. * @param forcedExtension defines the extension of the file if different from the url
  7723. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7724. * @return the prefiltered texture
  7725. */
  7726. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7727. /**
  7728. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7729. * as prefiltered data.
  7730. * @param rootUrl defines the url of the texture or the root name of the six images
  7731. * @param scene defines the scene the texture is attached to
  7732. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7733. * @param noMipmap defines if mipmaps should be created or not
  7734. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7735. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7736. * @param onError defines a callback triggered in case of error during load
  7737. * @param format defines the internal format to use for the texture once loaded
  7738. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7739. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7740. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @return the cube texture
  7744. */
  7745. 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);
  7746. /**
  7747. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7748. */
  7749. get isPrefiltered(): boolean;
  7750. /**
  7751. * Get the current class name of the texture useful for serialization or dynamic coding.
  7752. * @returns "CubeTexture"
  7753. */
  7754. getClassName(): string;
  7755. /**
  7756. * Update the url (and optional buffer) of this texture if url was null during construction.
  7757. * @param url the url of the texture
  7758. * @param forcedExtension defines the extension to use
  7759. * @param onLoad callback called when the texture is loaded (defaults to null)
  7760. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7761. */
  7762. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7763. /**
  7764. * Delays loading of the cube texture
  7765. * @param forcedExtension defines the extension to use
  7766. */
  7767. delayLoad(forcedExtension?: string): void;
  7768. /**
  7769. * Returns the reflection texture matrix
  7770. * @returns the reflection texture matrix
  7771. */
  7772. getReflectionTextureMatrix(): Matrix;
  7773. /**
  7774. * Sets the reflection texture matrix
  7775. * @param value Reflection texture matrix
  7776. */
  7777. setReflectionTextureMatrix(value: Matrix): void;
  7778. /**
  7779. * Parses text to create a cube texture
  7780. * @param parsedTexture define the serialized text to read from
  7781. * @param scene defines the hosting scene
  7782. * @param rootUrl defines the root url of the cube texture
  7783. * @returns a cube texture
  7784. */
  7785. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7786. /**
  7787. * Makes a clone, or deep copy, of the cube texture
  7788. * @returns a new cube texture
  7789. */
  7790. clone(): CubeTexture;
  7791. }
  7792. }
  7793. declare module BABYLON {
  7794. /**
  7795. * Manages the defines for the Material
  7796. */
  7797. export class MaterialDefines {
  7798. /** @hidden */
  7799. protected _keys: string[];
  7800. private _isDirty;
  7801. /** @hidden */
  7802. _renderId: number;
  7803. /** @hidden */
  7804. _areLightsDirty: boolean;
  7805. /** @hidden */
  7806. _areLightsDisposed: boolean;
  7807. /** @hidden */
  7808. _areAttributesDirty: boolean;
  7809. /** @hidden */
  7810. _areTexturesDirty: boolean;
  7811. /** @hidden */
  7812. _areFresnelDirty: boolean;
  7813. /** @hidden */
  7814. _areMiscDirty: boolean;
  7815. /** @hidden */
  7816. _areImageProcessingDirty: boolean;
  7817. /** @hidden */
  7818. _normals: boolean;
  7819. /** @hidden */
  7820. _uvs: boolean;
  7821. /** @hidden */
  7822. _needNormals: boolean;
  7823. /** @hidden */
  7824. _needUVs: boolean;
  7825. [id: string]: any;
  7826. /**
  7827. * Specifies if the material needs to be re-calculated
  7828. */
  7829. get isDirty(): boolean;
  7830. /**
  7831. * Marks the material to indicate that it has been re-calculated
  7832. */
  7833. markAsProcessed(): void;
  7834. /**
  7835. * Marks the material to indicate that it needs to be re-calculated
  7836. */
  7837. markAsUnprocessed(): void;
  7838. /**
  7839. * Marks the material to indicate all of its defines need to be re-calculated
  7840. */
  7841. markAllAsDirty(): void;
  7842. /**
  7843. * Marks the material to indicate that image processing needs to be re-calculated
  7844. */
  7845. markAsImageProcessingDirty(): void;
  7846. /**
  7847. * Marks the material to indicate the lights need to be re-calculated
  7848. * @param disposed Defines whether the light is dirty due to dispose or not
  7849. */
  7850. markAsLightDirty(disposed?: boolean): void;
  7851. /**
  7852. * Marks the attribute state as changed
  7853. */
  7854. markAsAttributesDirty(): void;
  7855. /**
  7856. * Marks the texture state as changed
  7857. */
  7858. markAsTexturesDirty(): void;
  7859. /**
  7860. * Marks the fresnel state as changed
  7861. */
  7862. markAsFresnelDirty(): void;
  7863. /**
  7864. * Marks the misc state as changed
  7865. */
  7866. markAsMiscDirty(): void;
  7867. /**
  7868. * Rebuilds the material defines
  7869. */
  7870. rebuild(): void;
  7871. /**
  7872. * Specifies if two material defines are equal
  7873. * @param other - A material define instance to compare to
  7874. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7875. */
  7876. isEqual(other: MaterialDefines): boolean;
  7877. /**
  7878. * Clones this instance's defines to another instance
  7879. * @param other - material defines to clone values to
  7880. */
  7881. cloneTo(other: MaterialDefines): void;
  7882. /**
  7883. * Resets the material define values
  7884. */
  7885. reset(): void;
  7886. /**
  7887. * Converts the material define values to a string
  7888. * @returns - String of material define information
  7889. */
  7890. toString(): string;
  7891. }
  7892. }
  7893. declare module BABYLON {
  7894. /**
  7895. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7896. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7897. * 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;
  7898. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7899. */
  7900. export class ColorCurves {
  7901. private _dirty;
  7902. private _tempColor;
  7903. private _globalCurve;
  7904. private _highlightsCurve;
  7905. private _midtonesCurve;
  7906. private _shadowsCurve;
  7907. private _positiveCurve;
  7908. private _negativeCurve;
  7909. private _globalHue;
  7910. private _globalDensity;
  7911. private _globalSaturation;
  7912. private _globalExposure;
  7913. /**
  7914. * Gets the global Hue value.
  7915. * 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).
  7916. */
  7917. get globalHue(): number;
  7918. /**
  7919. * Sets the global Hue value.
  7920. * 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).
  7921. */
  7922. set globalHue(value: number);
  7923. /**
  7924. * Gets the global Density value.
  7925. * 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.
  7926. * Values less than zero provide a filter of opposite hue.
  7927. */
  7928. get globalDensity(): number;
  7929. /**
  7930. * Sets the global Density value.
  7931. * 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.
  7932. * Values less than zero provide a filter of opposite hue.
  7933. */
  7934. set globalDensity(value: number);
  7935. /**
  7936. * Gets the global Saturation value.
  7937. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7938. */
  7939. get globalSaturation(): number;
  7940. /**
  7941. * Sets the global Saturation value.
  7942. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7943. */
  7944. set globalSaturation(value: number);
  7945. /**
  7946. * Gets the global Exposure value.
  7947. * 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.
  7948. */
  7949. get globalExposure(): number;
  7950. /**
  7951. * Sets the global Exposure value.
  7952. * 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.
  7953. */
  7954. set globalExposure(value: number);
  7955. private _highlightsHue;
  7956. private _highlightsDensity;
  7957. private _highlightsSaturation;
  7958. private _highlightsExposure;
  7959. /**
  7960. * Gets the highlights Hue value.
  7961. * 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).
  7962. */
  7963. get highlightsHue(): number;
  7964. /**
  7965. * Sets the highlights Hue value.
  7966. * 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).
  7967. */
  7968. set highlightsHue(value: number);
  7969. /**
  7970. * Gets the highlights Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. get highlightsDensity(): number;
  7975. /**
  7976. * Sets the highlights 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. set highlightsDensity(value: number);
  7981. /**
  7982. * Gets the highlights Saturation value.
  7983. * 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.
  7984. */
  7985. get highlightsSaturation(): number;
  7986. /**
  7987. * Sets the highlights 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. set highlightsSaturation(value: number);
  7991. /**
  7992. * Gets the highlights Exposure value.
  7993. * 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.
  7994. */
  7995. get highlightsExposure(): number;
  7996. /**
  7997. * Sets the highlights Exposure value.
  7998. * 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.
  7999. */
  8000. set highlightsExposure(value: number);
  8001. private _midtonesHue;
  8002. private _midtonesDensity;
  8003. private _midtonesSaturation;
  8004. private _midtonesExposure;
  8005. /**
  8006. * Gets the midtones Hue value.
  8007. * 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).
  8008. */
  8009. get midtonesHue(): number;
  8010. /**
  8011. * Sets the midtones Hue value.
  8012. * 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).
  8013. */
  8014. set midtonesHue(value: number);
  8015. /**
  8016. * Gets the midtones Density value.
  8017. * 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.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. get midtonesDensity(): number;
  8021. /**
  8022. * Sets the midtones Density value.
  8023. * 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.
  8024. * Values less than zero provide a filter of opposite hue.
  8025. */
  8026. set midtonesDensity(value: number);
  8027. /**
  8028. * Gets the midtones Saturation value.
  8029. * 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.
  8030. */
  8031. get midtonesSaturation(): number;
  8032. /**
  8033. * Sets the midtones Saturation value.
  8034. * 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.
  8035. */
  8036. set midtonesSaturation(value: number);
  8037. /**
  8038. * Gets the midtones Exposure value.
  8039. * 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.
  8040. */
  8041. get midtonesExposure(): number;
  8042. /**
  8043. * Sets the midtones Exposure value.
  8044. * 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.
  8045. */
  8046. set midtonesExposure(value: number);
  8047. private _shadowsHue;
  8048. private _shadowsDensity;
  8049. private _shadowsSaturation;
  8050. private _shadowsExposure;
  8051. /**
  8052. * Gets the shadows Hue value.
  8053. * 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).
  8054. */
  8055. get shadowsHue(): number;
  8056. /**
  8057. * Sets the shadows Hue value.
  8058. * 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).
  8059. */
  8060. set shadowsHue(value: number);
  8061. /**
  8062. * Gets the shadows Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get shadowsDensity(): number;
  8067. /**
  8068. * Sets the shadows Density value.
  8069. * 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.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set shadowsDensity(value: number);
  8073. /**
  8074. * Gets the shadows Saturation value.
  8075. * 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.
  8076. */
  8077. get shadowsSaturation(): number;
  8078. /**
  8079. * Sets the shadows Saturation value.
  8080. * 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.
  8081. */
  8082. set shadowsSaturation(value: number);
  8083. /**
  8084. * Gets the shadows Exposure value.
  8085. * 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.
  8086. */
  8087. get shadowsExposure(): number;
  8088. /**
  8089. * Sets the shadows Exposure value.
  8090. * 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.
  8091. */
  8092. set shadowsExposure(value: number);
  8093. /**
  8094. * Returns the class name
  8095. * @returns The class name
  8096. */
  8097. getClassName(): string;
  8098. /**
  8099. * Binds the color curves to the shader.
  8100. * @param colorCurves The color curve to bind
  8101. * @param effect The effect to bind to
  8102. * @param positiveUniform The positive uniform shader parameter
  8103. * @param neutralUniform The neutral uniform shader parameter
  8104. * @param negativeUniform The negative uniform shader parameter
  8105. */
  8106. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8107. /**
  8108. * Prepare the list of uniforms associated with the ColorCurves effects.
  8109. * @param uniformsList The list of uniforms used in the effect
  8110. */
  8111. static PrepareUniforms(uniformsList: string[]): void;
  8112. /**
  8113. * Returns color grading data based on a hue, density, saturation and exposure value.
  8114. * @param filterHue The hue of the color filter.
  8115. * @param filterDensity The density of the color filter.
  8116. * @param saturation The saturation.
  8117. * @param exposure The exposure.
  8118. * @param result The result data container.
  8119. */
  8120. private getColorGradingDataToRef;
  8121. /**
  8122. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8123. * @param value The input slider value in range [-100,100].
  8124. * @returns Adjusted value.
  8125. */
  8126. private static applyColorGradingSliderNonlinear;
  8127. /**
  8128. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8129. * @param hue The hue (H) input.
  8130. * @param saturation The saturation (S) input.
  8131. * @param brightness The brightness (B) input.
  8132. * @result An RGBA color represented as Vector4.
  8133. */
  8134. private static fromHSBToRef;
  8135. /**
  8136. * Returns a value clamped between min and max
  8137. * @param value The value to clamp
  8138. * @param min The minimum of value
  8139. * @param max The maximum of value
  8140. * @returns The clamped value.
  8141. */
  8142. private static clamp;
  8143. /**
  8144. * Clones the current color curve instance.
  8145. * @return The cloned curves
  8146. */
  8147. clone(): ColorCurves;
  8148. /**
  8149. * Serializes the current color curve instance to a json representation.
  8150. * @return a JSON representation
  8151. */
  8152. serialize(): any;
  8153. /**
  8154. * Parses the color curve from a json representation.
  8155. * @param source the JSON source to parse
  8156. * @return The parsed curves
  8157. */
  8158. static Parse(source: any): ColorCurves;
  8159. }
  8160. }
  8161. declare module BABYLON {
  8162. /**
  8163. * Interface to follow in your material defines to integrate easily the
  8164. * Image proccessing functions.
  8165. * @hidden
  8166. */
  8167. export interface IImageProcessingConfigurationDefines {
  8168. IMAGEPROCESSING: boolean;
  8169. VIGNETTE: boolean;
  8170. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8171. VIGNETTEBLENDMODEOPAQUE: boolean;
  8172. TONEMAPPING: boolean;
  8173. TONEMAPPING_ACES: boolean;
  8174. CONTRAST: boolean;
  8175. EXPOSURE: boolean;
  8176. COLORCURVES: boolean;
  8177. COLORGRADING: boolean;
  8178. COLORGRADING3D: boolean;
  8179. SAMPLER3DGREENDEPTH: boolean;
  8180. SAMPLER3DBGRMAP: boolean;
  8181. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8182. }
  8183. /**
  8184. * @hidden
  8185. */
  8186. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8187. IMAGEPROCESSING: boolean;
  8188. VIGNETTE: boolean;
  8189. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8190. VIGNETTEBLENDMODEOPAQUE: boolean;
  8191. TONEMAPPING: boolean;
  8192. TONEMAPPING_ACES: boolean;
  8193. CONTRAST: boolean;
  8194. COLORCURVES: boolean;
  8195. COLORGRADING: boolean;
  8196. COLORGRADING3D: boolean;
  8197. SAMPLER3DGREENDEPTH: boolean;
  8198. SAMPLER3DBGRMAP: boolean;
  8199. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8200. EXPOSURE: boolean;
  8201. constructor();
  8202. }
  8203. /**
  8204. * This groups together the common properties used for image processing either in direct forward pass
  8205. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8206. * or not.
  8207. */
  8208. export class ImageProcessingConfiguration {
  8209. /**
  8210. * Default tone mapping applied in BabylonJS.
  8211. */
  8212. static readonly TONEMAPPING_STANDARD: number;
  8213. /**
  8214. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8215. * to other engines rendering to increase portability.
  8216. */
  8217. static readonly TONEMAPPING_ACES: number;
  8218. /**
  8219. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8220. */
  8221. colorCurves: Nullable<ColorCurves>;
  8222. private _colorCurvesEnabled;
  8223. /**
  8224. * Gets wether the color curves effect is enabled.
  8225. */
  8226. get colorCurvesEnabled(): boolean;
  8227. /**
  8228. * Sets wether the color curves effect is enabled.
  8229. */
  8230. set colorCurvesEnabled(value: boolean);
  8231. private _colorGradingTexture;
  8232. /**
  8233. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8234. */
  8235. get colorGradingTexture(): Nullable<BaseTexture>;
  8236. /**
  8237. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8238. */
  8239. set colorGradingTexture(value: Nullable<BaseTexture>);
  8240. private _colorGradingEnabled;
  8241. /**
  8242. * Gets wether the color grading effect is enabled.
  8243. */
  8244. get colorGradingEnabled(): boolean;
  8245. /**
  8246. * Sets wether the color grading effect is enabled.
  8247. */
  8248. set colorGradingEnabled(value: boolean);
  8249. private _colorGradingWithGreenDepth;
  8250. /**
  8251. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8252. */
  8253. get colorGradingWithGreenDepth(): boolean;
  8254. /**
  8255. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8256. */
  8257. set colorGradingWithGreenDepth(value: boolean);
  8258. private _colorGradingBGR;
  8259. /**
  8260. * Gets wether the color grading texture contains BGR values.
  8261. */
  8262. get colorGradingBGR(): boolean;
  8263. /**
  8264. * Sets wether the color grading texture contains BGR values.
  8265. */
  8266. set colorGradingBGR(value: boolean);
  8267. /** @hidden */
  8268. _exposure: number;
  8269. /**
  8270. * Gets the Exposure used in the effect.
  8271. */
  8272. get exposure(): number;
  8273. /**
  8274. * Sets the Exposure used in the effect.
  8275. */
  8276. set exposure(value: number);
  8277. private _toneMappingEnabled;
  8278. /**
  8279. * Gets wether the tone mapping effect is enabled.
  8280. */
  8281. get toneMappingEnabled(): boolean;
  8282. /**
  8283. * Sets wether the tone mapping effect is enabled.
  8284. */
  8285. set toneMappingEnabled(value: boolean);
  8286. private _toneMappingType;
  8287. /**
  8288. * Gets the type of tone mapping effect.
  8289. */
  8290. get toneMappingType(): number;
  8291. /**
  8292. * Sets the type of tone mapping effect used in BabylonJS.
  8293. */
  8294. set toneMappingType(value: number);
  8295. protected _contrast: number;
  8296. /**
  8297. * Gets the contrast used in the effect.
  8298. */
  8299. get contrast(): number;
  8300. /**
  8301. * Sets the contrast used in the effect.
  8302. */
  8303. set contrast(value: number);
  8304. /**
  8305. * Vignette stretch size.
  8306. */
  8307. vignetteStretch: number;
  8308. /**
  8309. * Vignette centre X Offset.
  8310. */
  8311. vignetteCentreX: number;
  8312. /**
  8313. * Vignette centre Y Offset.
  8314. */
  8315. vignetteCentreY: number;
  8316. /**
  8317. * Vignette weight or intensity of the vignette effect.
  8318. */
  8319. vignetteWeight: number;
  8320. /**
  8321. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8322. * if vignetteEnabled is set to true.
  8323. */
  8324. vignetteColor: Color4;
  8325. /**
  8326. * Camera field of view used by the Vignette effect.
  8327. */
  8328. vignetteCameraFov: number;
  8329. private _vignetteBlendMode;
  8330. /**
  8331. * Gets the vignette blend mode allowing different kind of effect.
  8332. */
  8333. get vignetteBlendMode(): number;
  8334. /**
  8335. * Sets the vignette blend mode allowing different kind of effect.
  8336. */
  8337. set vignetteBlendMode(value: number);
  8338. private _vignetteEnabled;
  8339. /**
  8340. * Gets wether the vignette effect is enabled.
  8341. */
  8342. get vignetteEnabled(): boolean;
  8343. /**
  8344. * Sets wether the vignette effect is enabled.
  8345. */
  8346. set vignetteEnabled(value: boolean);
  8347. private _applyByPostProcess;
  8348. /**
  8349. * Gets wether the image processing is applied through a post process or not.
  8350. */
  8351. get applyByPostProcess(): boolean;
  8352. /**
  8353. * Sets wether the image processing is applied through a post process or not.
  8354. */
  8355. set applyByPostProcess(value: boolean);
  8356. private _isEnabled;
  8357. /**
  8358. * Gets wether the image processing is enabled or not.
  8359. */
  8360. get isEnabled(): boolean;
  8361. /**
  8362. * Sets wether the image processing is enabled or not.
  8363. */
  8364. set isEnabled(value: boolean);
  8365. /**
  8366. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8367. */
  8368. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8369. /**
  8370. * Method called each time the image processing information changes requires to recompile the effect.
  8371. */
  8372. protected _updateParameters(): void;
  8373. /**
  8374. * Gets the current class name.
  8375. * @return "ImageProcessingConfiguration"
  8376. */
  8377. getClassName(): string;
  8378. /**
  8379. * Prepare the list of uniforms associated with the Image Processing effects.
  8380. * @param uniforms The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of samplers associated with the Image Processing effects.
  8386. * @param samplersList The list of uniforms used in the effect
  8387. * @param defines the list of defines currently in use
  8388. */
  8389. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8390. /**
  8391. * Prepare the list of defines associated to the shader.
  8392. * @param defines the list of defines to complete
  8393. * @param forPostProcess Define if we are currently in post process mode or not
  8394. */
  8395. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8396. /**
  8397. * Returns true if all the image processing information are ready.
  8398. * @returns True if ready, otherwise, false
  8399. */
  8400. isReady(): boolean;
  8401. /**
  8402. * Binds the image processing to the shader.
  8403. * @param effect The effect to bind to
  8404. * @param overrideAspectRatio Override the aspect ratio of the effect
  8405. */
  8406. bind(effect: Effect, overrideAspectRatio?: number): void;
  8407. /**
  8408. * Clones the current image processing instance.
  8409. * @return The cloned image processing
  8410. */
  8411. clone(): ImageProcessingConfiguration;
  8412. /**
  8413. * Serializes the current image processing instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the image processing from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed image processing
  8421. */
  8422. static Parse(source: any): ImageProcessingConfiguration;
  8423. private static _VIGNETTEMODE_MULTIPLY;
  8424. private static _VIGNETTEMODE_OPAQUE;
  8425. /**
  8426. * Used to apply the vignette as a mix with the pixel color.
  8427. */
  8428. static get VIGNETTEMODE_MULTIPLY(): number;
  8429. /**
  8430. * Used to apply the vignette as a replacement of the pixel color.
  8431. */
  8432. static get VIGNETTEMODE_OPAQUE(): number;
  8433. }
  8434. }
  8435. declare module BABYLON {
  8436. /** @hidden */
  8437. export var postprocessVertexShader: {
  8438. name: string;
  8439. shader: string;
  8440. };
  8441. }
  8442. declare module BABYLON {
  8443. interface ThinEngine {
  8444. /**
  8445. * Creates a new render target texture
  8446. * @param size defines the size of the texture
  8447. * @param options defines the options used to create the texture
  8448. * @returns a new render target texture stored in an InternalTexture
  8449. */
  8450. createRenderTargetTexture(size: number | {
  8451. width: number;
  8452. height: number;
  8453. layers?: number;
  8454. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8455. /**
  8456. * Creates a depth stencil texture.
  8457. * This is only available in WebGL 2 or with the depth texture extension available.
  8458. * @param size The size of face edge in the texture.
  8459. * @param options The options defining the texture.
  8460. * @returns The texture
  8461. */
  8462. createDepthStencilTexture(size: number | {
  8463. width: number;
  8464. height: number;
  8465. layers?: number;
  8466. }, options: DepthTextureCreationOptions): InternalTexture;
  8467. /** @hidden */
  8468. _createDepthStencilTexture(size: number | {
  8469. width: number;
  8470. height: number;
  8471. layers?: number;
  8472. }, options: DepthTextureCreationOptions): InternalTexture;
  8473. }
  8474. }
  8475. declare module BABYLON {
  8476. /** Defines supported spaces */
  8477. export enum Space {
  8478. /** Local (object) space */
  8479. LOCAL = 0,
  8480. /** World space */
  8481. WORLD = 1,
  8482. /** Bone space */
  8483. BONE = 2
  8484. }
  8485. /** Defines the 3 main axes */
  8486. export class Axis {
  8487. /** X axis */
  8488. static X: Vector3;
  8489. /** Y axis */
  8490. static Y: Vector3;
  8491. /** Z axis */
  8492. static Z: Vector3;
  8493. }
  8494. }
  8495. declare module BABYLON {
  8496. /**
  8497. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8498. * This is the base of the follow, arc rotate cameras and Free camera
  8499. * @see http://doc.babylonjs.com/features/cameras
  8500. */
  8501. export class TargetCamera extends Camera {
  8502. private static _RigCamTransformMatrix;
  8503. private static _TargetTransformMatrix;
  8504. private static _TargetFocalPoint;
  8505. /**
  8506. * Define the current direction the camera is moving to
  8507. */
  8508. cameraDirection: Vector3;
  8509. /**
  8510. * Define the current rotation the camera is rotating to
  8511. */
  8512. cameraRotation: Vector2;
  8513. /**
  8514. * When set, the up vector of the camera will be updated by the rotation of the camera
  8515. */
  8516. updateUpVectorFromRotation: boolean;
  8517. private _tmpQuaternion;
  8518. /**
  8519. * Define the current rotation of the camera
  8520. */
  8521. rotation: Vector3;
  8522. /**
  8523. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8524. */
  8525. rotationQuaternion: Quaternion;
  8526. /**
  8527. * Define the current speed of the camera
  8528. */
  8529. speed: number;
  8530. /**
  8531. * Add constraint to the camera to prevent it to move freely in all directions and
  8532. * around all axis.
  8533. */
  8534. noRotationConstraint: boolean;
  8535. /**
  8536. * Define the current target of the camera as an object or a position.
  8537. */
  8538. lockedTarget: any;
  8539. /** @hidden */
  8540. _currentTarget: Vector3;
  8541. /** @hidden */
  8542. _initialFocalDistance: number;
  8543. /** @hidden */
  8544. _viewMatrix: Matrix;
  8545. /** @hidden */
  8546. _camMatrix: Matrix;
  8547. /** @hidden */
  8548. _cameraTransformMatrix: Matrix;
  8549. /** @hidden */
  8550. _cameraRotationMatrix: Matrix;
  8551. /** @hidden */
  8552. _referencePoint: Vector3;
  8553. /** @hidden */
  8554. _transformedReferencePoint: Vector3;
  8555. protected _globalCurrentTarget: Vector3;
  8556. protected _globalCurrentUpVector: Vector3;
  8557. /** @hidden */
  8558. _reset: () => void;
  8559. private _defaultUp;
  8560. /**
  8561. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8562. * This is the base of the follow, arc rotate cameras and Free camera
  8563. * @see http://doc.babylonjs.com/features/cameras
  8564. * @param name Defines the name of the camera in the scene
  8565. * @param position Defines the start position of the camera in the scene
  8566. * @param scene Defines the scene the camera belongs to
  8567. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8568. */
  8569. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8570. /**
  8571. * Gets the position in front of the camera at a given distance.
  8572. * @param distance The distance from the camera we want the position to be
  8573. * @returns the position
  8574. */
  8575. getFrontPosition(distance: number): Vector3;
  8576. /** @hidden */
  8577. _getLockedTargetPosition(): Nullable<Vector3>;
  8578. private _storedPosition;
  8579. private _storedRotation;
  8580. private _storedRotationQuaternion;
  8581. /**
  8582. * Store current camera state of the camera (fov, position, rotation, etc..)
  8583. * @returns the camera
  8584. */
  8585. storeState(): Camera;
  8586. /**
  8587. * Restored camera state. You must call storeState() first
  8588. * @returns whether it was successful or not
  8589. * @hidden
  8590. */
  8591. _restoreStateValues(): boolean;
  8592. /** @hidden */
  8593. _initCache(): void;
  8594. /** @hidden */
  8595. _updateCache(ignoreParentClass?: boolean): void;
  8596. /** @hidden */
  8597. _isSynchronizedViewMatrix(): boolean;
  8598. /** @hidden */
  8599. _computeLocalCameraSpeed(): number;
  8600. /**
  8601. * Defines the target the camera should look at.
  8602. * @param target Defines the new target as a Vector or a mesh
  8603. */
  8604. setTarget(target: Vector3): void;
  8605. /**
  8606. * Return the current target position of the camera. This value is expressed in local space.
  8607. * @returns the target position
  8608. */
  8609. getTarget(): Vector3;
  8610. /** @hidden */
  8611. _decideIfNeedsToMove(): boolean;
  8612. /** @hidden */
  8613. _updatePosition(): void;
  8614. /** @hidden */
  8615. _checkInputs(): void;
  8616. protected _updateCameraRotationMatrix(): void;
  8617. /**
  8618. * 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)
  8619. * @returns the current camera
  8620. */
  8621. private _rotateUpVectorWithCameraRotationMatrix;
  8622. private _cachedRotationZ;
  8623. private _cachedQuaternionRotationZ;
  8624. /** @hidden */
  8625. _getViewMatrix(): Matrix;
  8626. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8627. /**
  8628. * @hidden
  8629. */
  8630. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8631. /**
  8632. * @hidden
  8633. */
  8634. _updateRigCameras(): void;
  8635. private _getRigCamPositionAndTarget;
  8636. /**
  8637. * Gets the current object class name.
  8638. * @return the class name
  8639. */
  8640. getClassName(): string;
  8641. }
  8642. }
  8643. declare module BABYLON {
  8644. /**
  8645. * Gather the list of keyboard event types as constants.
  8646. */
  8647. export class KeyboardEventTypes {
  8648. /**
  8649. * The keydown event is fired when a key becomes active (pressed).
  8650. */
  8651. static readonly KEYDOWN: number;
  8652. /**
  8653. * The keyup event is fired when a key has been released.
  8654. */
  8655. static readonly KEYUP: number;
  8656. }
  8657. /**
  8658. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8659. */
  8660. export class KeyboardInfo {
  8661. /**
  8662. * Defines the type of event (KeyboardEventTypes)
  8663. */
  8664. type: number;
  8665. /**
  8666. * Defines the related dom event
  8667. */
  8668. event: KeyboardEvent;
  8669. /**
  8670. * Instantiates a new keyboard info.
  8671. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8672. * @param type Defines the type of event (KeyboardEventTypes)
  8673. * @param event Defines the related dom event
  8674. */
  8675. constructor(
  8676. /**
  8677. * Defines the type of event (KeyboardEventTypes)
  8678. */
  8679. type: number,
  8680. /**
  8681. * Defines the related dom event
  8682. */
  8683. event: KeyboardEvent);
  8684. }
  8685. /**
  8686. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8687. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8688. */
  8689. export class KeyboardInfoPre extends KeyboardInfo {
  8690. /**
  8691. * Defines the type of event (KeyboardEventTypes)
  8692. */
  8693. type: number;
  8694. /**
  8695. * Defines the related dom event
  8696. */
  8697. event: KeyboardEvent;
  8698. /**
  8699. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8700. */
  8701. skipOnPointerObservable: boolean;
  8702. /**
  8703. * Instantiates a new keyboard pre info.
  8704. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8705. * @param type Defines the type of event (KeyboardEventTypes)
  8706. * @param event Defines the related dom event
  8707. */
  8708. constructor(
  8709. /**
  8710. * Defines the type of event (KeyboardEventTypes)
  8711. */
  8712. type: number,
  8713. /**
  8714. * Defines the related dom event
  8715. */
  8716. event: KeyboardEvent);
  8717. }
  8718. }
  8719. declare module BABYLON {
  8720. /**
  8721. * Manage the keyboard inputs to control the movement of a free camera.
  8722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8723. */
  8724. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8725. /**
  8726. * Defines the camera the input is attached to.
  8727. */
  8728. camera: FreeCamera;
  8729. /**
  8730. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8731. */
  8732. keysUp: number[];
  8733. /**
  8734. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8735. */
  8736. keysDown: number[];
  8737. /**
  8738. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8739. */
  8740. keysLeft: number[];
  8741. /**
  8742. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8743. */
  8744. keysRight: number[];
  8745. private _keys;
  8746. private _onCanvasBlurObserver;
  8747. private _onKeyboardObserver;
  8748. private _engine;
  8749. private _scene;
  8750. /**
  8751. * Attach the input controls to a specific dom element to get the input from.
  8752. * @param element Defines the element the controls should be listened from
  8753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8754. */
  8755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8756. /**
  8757. * Detach the current controls from the specified dom element.
  8758. * @param element Defines the element to stop listening the inputs from
  8759. */
  8760. detachControl(element: Nullable<HTMLElement>): void;
  8761. /**
  8762. * Update the current camera state depending on the inputs that have been used this frame.
  8763. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8764. */
  8765. checkInputs(): void;
  8766. /**
  8767. * Gets the class name of the current intput.
  8768. * @returns the class name
  8769. */
  8770. getClassName(): string;
  8771. /** @hidden */
  8772. _onLostFocus(): void;
  8773. /**
  8774. * Get the friendly name associated with the input class.
  8775. * @returns the input friendly name
  8776. */
  8777. getSimpleName(): string;
  8778. }
  8779. }
  8780. declare module BABYLON {
  8781. /**
  8782. * Interface describing all the common properties and methods a shadow light needs to implement.
  8783. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8784. * as well as binding the different shadow properties to the effects.
  8785. */
  8786. export interface IShadowLight extends Light {
  8787. /**
  8788. * The light id in the scene (used in scene.findLighById for instance)
  8789. */
  8790. id: string;
  8791. /**
  8792. * The position the shdow will be casted from.
  8793. */
  8794. position: Vector3;
  8795. /**
  8796. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8797. */
  8798. direction: Vector3;
  8799. /**
  8800. * The transformed position. Position of the light in world space taking parenting in account.
  8801. */
  8802. transformedPosition: Vector3;
  8803. /**
  8804. * The transformed direction. Direction of the light in world space taking parenting in account.
  8805. */
  8806. transformedDirection: Vector3;
  8807. /**
  8808. * The friendly name of the light in the scene.
  8809. */
  8810. name: string;
  8811. /**
  8812. * Defines the shadow projection clipping minimum z value.
  8813. */
  8814. shadowMinZ: number;
  8815. /**
  8816. * Defines the shadow projection clipping maximum z value.
  8817. */
  8818. shadowMaxZ: number;
  8819. /**
  8820. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8821. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8822. */
  8823. computeTransformedInformation(): boolean;
  8824. /**
  8825. * Gets the scene the light belongs to.
  8826. * @returns The scene
  8827. */
  8828. getScene(): Scene;
  8829. /**
  8830. * Callback defining a custom Projection Matrix Builder.
  8831. * This can be used to override the default projection matrix computation.
  8832. */
  8833. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8834. /**
  8835. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8836. * @param matrix The materix to updated with the projection information
  8837. * @param viewMatrix The transform matrix of the light
  8838. * @param renderList The list of mesh to render in the map
  8839. * @returns The current light
  8840. */
  8841. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8842. /**
  8843. * Gets the current depth scale used in ESM.
  8844. * @returns The scale
  8845. */
  8846. getDepthScale(): number;
  8847. /**
  8848. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8849. * @returns true if a cube texture needs to be use
  8850. */
  8851. needCube(): boolean;
  8852. /**
  8853. * Detects if the projection matrix requires to be recomputed this frame.
  8854. * @returns true if it requires to be recomputed otherwise, false.
  8855. */
  8856. needProjectionMatrixCompute(): boolean;
  8857. /**
  8858. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8859. */
  8860. forceProjectionMatrixCompute(): void;
  8861. /**
  8862. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8863. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8864. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8865. */
  8866. getShadowDirection(faceIndex?: number): Vector3;
  8867. /**
  8868. * Gets the minZ used for shadow according to both the scene and the light.
  8869. * @param activeCamera The camera we are returning the min for
  8870. * @returns the depth min z
  8871. */
  8872. getDepthMinZ(activeCamera: Camera): number;
  8873. /**
  8874. * Gets the maxZ used for shadow according to both the scene and the light.
  8875. * @param activeCamera The camera we are returning the max for
  8876. * @returns the depth max z
  8877. */
  8878. getDepthMaxZ(activeCamera: Camera): number;
  8879. }
  8880. /**
  8881. * Base implementation IShadowLight
  8882. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8883. */
  8884. export abstract class ShadowLight extends Light implements IShadowLight {
  8885. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8886. protected _position: Vector3;
  8887. protected _setPosition(value: Vector3): void;
  8888. /**
  8889. * Sets the position the shadow will be casted from. Also use as the light position for both
  8890. * point and spot lights.
  8891. */
  8892. get position(): Vector3;
  8893. /**
  8894. * Sets the position the shadow will be casted from. Also use as the light position for both
  8895. * point and spot lights.
  8896. */
  8897. set position(value: Vector3);
  8898. protected _direction: Vector3;
  8899. protected _setDirection(value: Vector3): void;
  8900. /**
  8901. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8902. * Also use as the light direction on spot and directional lights.
  8903. */
  8904. get direction(): Vector3;
  8905. /**
  8906. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8907. * Also use as the light direction on spot and directional lights.
  8908. */
  8909. set direction(value: Vector3);
  8910. protected _shadowMinZ: number;
  8911. /**
  8912. * Gets the shadow projection clipping minimum z value.
  8913. */
  8914. get shadowMinZ(): number;
  8915. /**
  8916. * Sets the shadow projection clipping minimum z value.
  8917. */
  8918. set shadowMinZ(value: number);
  8919. protected _shadowMaxZ: number;
  8920. /**
  8921. * Sets the shadow projection clipping maximum z value.
  8922. */
  8923. get shadowMaxZ(): number;
  8924. /**
  8925. * Gets the shadow projection clipping maximum z value.
  8926. */
  8927. set shadowMaxZ(value: number);
  8928. /**
  8929. * Callback defining a custom Projection Matrix Builder.
  8930. * This can be used to override the default projection matrix computation.
  8931. */
  8932. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8933. /**
  8934. * The transformed position. Position of the light in world space taking parenting in account.
  8935. */
  8936. transformedPosition: Vector3;
  8937. /**
  8938. * The transformed direction. Direction of the light in world space taking parenting in account.
  8939. */
  8940. transformedDirection: Vector3;
  8941. private _needProjectionMatrixCompute;
  8942. /**
  8943. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8944. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8945. */
  8946. computeTransformedInformation(): boolean;
  8947. /**
  8948. * Return the depth scale used for the shadow map.
  8949. * @returns the depth scale.
  8950. */
  8951. getDepthScale(): number;
  8952. /**
  8953. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8954. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8955. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8956. */
  8957. getShadowDirection(faceIndex?: number): Vector3;
  8958. /**
  8959. * Returns the ShadowLight absolute position in the World.
  8960. * @returns the position vector in world space
  8961. */
  8962. getAbsolutePosition(): Vector3;
  8963. /**
  8964. * Sets the ShadowLight direction toward the passed target.
  8965. * @param target The point to target in local space
  8966. * @returns the updated ShadowLight direction
  8967. */
  8968. setDirectionToTarget(target: Vector3): Vector3;
  8969. /**
  8970. * Returns the light rotation in euler definition.
  8971. * @returns the x y z rotation in local space.
  8972. */
  8973. getRotation(): Vector3;
  8974. /**
  8975. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8976. * @returns true if a cube texture needs to be use
  8977. */
  8978. needCube(): boolean;
  8979. /**
  8980. * Detects if the projection matrix requires to be recomputed this frame.
  8981. * @returns true if it requires to be recomputed otherwise, false.
  8982. */
  8983. needProjectionMatrixCompute(): boolean;
  8984. /**
  8985. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8986. */
  8987. forceProjectionMatrixCompute(): void;
  8988. /** @hidden */
  8989. _initCache(): void;
  8990. /** @hidden */
  8991. _isSynchronized(): boolean;
  8992. /**
  8993. * Computes the world matrix of the node
  8994. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8995. * @returns the world matrix
  8996. */
  8997. computeWorldMatrix(force?: boolean): Matrix;
  8998. /**
  8999. * Gets the minZ used for shadow according to both the scene and the light.
  9000. * @param activeCamera The camera we are returning the min for
  9001. * @returns the depth min z
  9002. */
  9003. getDepthMinZ(activeCamera: Camera): number;
  9004. /**
  9005. * Gets the maxZ used for shadow according to both the scene and the light.
  9006. * @param activeCamera The camera we are returning the max for
  9007. * @returns the depth max z
  9008. */
  9009. getDepthMaxZ(activeCamera: Camera): number;
  9010. /**
  9011. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9012. * @param matrix The materix to updated with the projection information
  9013. * @param viewMatrix The transform matrix of the light
  9014. * @param renderList The list of mesh to render in the map
  9015. * @returns The current light
  9016. */
  9017. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9018. }
  9019. }
  9020. declare module BABYLON {
  9021. /**
  9022. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9023. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9024. */
  9025. export class EffectFallbacks implements IEffectFallbacks {
  9026. private _defines;
  9027. private _currentRank;
  9028. private _maxRank;
  9029. private _mesh;
  9030. /**
  9031. * Removes the fallback from the bound mesh.
  9032. */
  9033. unBindMesh(): void;
  9034. /**
  9035. * Adds a fallback on the specified property.
  9036. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9037. * @param define The name of the define in the shader
  9038. */
  9039. addFallback(rank: number, define: string): void;
  9040. /**
  9041. * Sets the mesh to use CPU skinning when needing to fallback.
  9042. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9043. * @param mesh The mesh to use the fallbacks.
  9044. */
  9045. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9046. /**
  9047. * Checks to see if more fallbacks are still availible.
  9048. */
  9049. get hasMoreFallbacks(): boolean;
  9050. /**
  9051. * Removes the defines that should be removed when falling back.
  9052. * @param currentDefines defines the current define statements for the shader.
  9053. * @param effect defines the current effect we try to compile
  9054. * @returns The resulting defines with defines of the current rank removed.
  9055. */
  9056. reduce(currentDefines: string, effect: Effect): string;
  9057. }
  9058. }
  9059. declare module BABYLON {
  9060. /**
  9061. * "Static Class" containing the most commonly used helper while dealing with material for
  9062. * rendering purpose.
  9063. *
  9064. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9065. *
  9066. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9067. */
  9068. export class MaterialHelper {
  9069. /**
  9070. * Bind the current view position to an effect.
  9071. * @param effect The effect to be bound
  9072. * @param scene The scene the eyes position is used from
  9073. */
  9074. static BindEyePosition(effect: Effect, scene: Scene): void;
  9075. /**
  9076. * Helps preparing the defines values about the UVs in used in the effect.
  9077. * UVs are shared as much as we can accross channels in the shaders.
  9078. * @param texture The texture we are preparing the UVs for
  9079. * @param defines The defines to update
  9080. * @param key The channel key "diffuse", "specular"... used in the shader
  9081. */
  9082. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9083. /**
  9084. * Binds a texture matrix value to its corrsponding uniform
  9085. * @param texture The texture to bind the matrix for
  9086. * @param uniformBuffer The uniform buffer receivin the data
  9087. * @param key The channel key "diffuse", "specular"... used in the shader
  9088. */
  9089. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9090. /**
  9091. * Gets the current status of the fog (should it be enabled?)
  9092. * @param mesh defines the mesh to evaluate for fog support
  9093. * @param scene defines the hosting scene
  9094. * @returns true if fog must be enabled
  9095. */
  9096. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9097. /**
  9098. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9099. * @param mesh defines the current mesh
  9100. * @param scene defines the current scene
  9101. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9102. * @param pointsCloud defines if point cloud rendering has to be turned on
  9103. * @param fogEnabled defines if fog has to be turned on
  9104. * @param alphaTest defines if alpha testing has to be turned on
  9105. * @param defines defines the current list of defines
  9106. */
  9107. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9108. /**
  9109. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9110. * @param scene defines the current scene
  9111. * @param engine defines the current engine
  9112. * @param defines specifies the list of active defines
  9113. * @param useInstances defines if instances have to be turned on
  9114. * @param useClipPlane defines if clip plane have to be turned on
  9115. */
  9116. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9117. /**
  9118. * Prepares the defines for bones
  9119. * @param mesh The mesh containing the geometry data we will draw
  9120. * @param defines The defines to update
  9121. */
  9122. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9123. /**
  9124. * Prepares the defines for morph targets
  9125. * @param mesh The mesh containing the geometry data we will draw
  9126. * @param defines The defines to update
  9127. */
  9128. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9129. /**
  9130. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9131. * @param mesh The mesh containing the geometry data we will draw
  9132. * @param defines The defines to update
  9133. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9134. * @param useBones Precise whether bones should be used or not (override mesh info)
  9135. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9136. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9137. * @returns false if defines are considered not dirty and have not been checked
  9138. */
  9139. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9140. /**
  9141. * Prepares the defines related to multiview
  9142. * @param scene The scene we are intending to draw
  9143. * @param defines The defines to update
  9144. */
  9145. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9146. /**
  9147. * Prepares the defines related to the light information passed in parameter
  9148. * @param scene The scene we are intending to draw
  9149. * @param mesh The mesh the effect is compiling for
  9150. * @param light The light the effect is compiling for
  9151. * @param lightIndex The index of the light
  9152. * @param defines The defines to update
  9153. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9154. * @param state Defines the current state regarding what is needed (normals, etc...)
  9155. */
  9156. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9157. needNormals: boolean;
  9158. needRebuild: boolean;
  9159. shadowEnabled: boolean;
  9160. specularEnabled: boolean;
  9161. lightmapMode: boolean;
  9162. }): void;
  9163. /**
  9164. * Prepares the defines related to the light information passed in parameter
  9165. * @param scene The scene we are intending to draw
  9166. * @param mesh The mesh the effect is compiling for
  9167. * @param defines The defines to update
  9168. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9169. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9170. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9171. * @returns true if normals will be required for the rest of the effect
  9172. */
  9173. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9174. /**
  9175. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9176. * @param lightIndex defines the light index
  9177. * @param uniformsList The uniform list
  9178. * @param samplersList The sampler list
  9179. * @param projectedLightTexture defines if projected texture must be used
  9180. * @param uniformBuffersList defines an optional list of uniform buffers
  9181. */
  9182. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9183. /**
  9184. * Prepares the uniforms and samplers list to be used in the effect
  9185. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9186. * @param samplersList The sampler list
  9187. * @param defines The defines helping in the list generation
  9188. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9189. */
  9190. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9191. /**
  9192. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9193. * @param defines The defines to update while falling back
  9194. * @param fallbacks The authorized effect fallbacks
  9195. * @param maxSimultaneousLights The maximum number of lights allowed
  9196. * @param rank the current rank of the Effect
  9197. * @returns The newly affected rank
  9198. */
  9199. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9200. private static _TmpMorphInfluencers;
  9201. /**
  9202. * Prepares the list of attributes required for morph targets according to the effect defines.
  9203. * @param attribs The current list of supported attribs
  9204. * @param mesh The mesh to prepare the morph targets attributes for
  9205. * @param influencers The number of influencers
  9206. */
  9207. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9208. /**
  9209. * Prepares the list of attributes required for morph targets according to the effect defines.
  9210. * @param attribs The current list of supported attribs
  9211. * @param mesh The mesh to prepare the morph targets attributes for
  9212. * @param defines The current Defines of the effect
  9213. */
  9214. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9215. /**
  9216. * Prepares the list of attributes required for bones according to the effect defines.
  9217. * @param attribs The current list of supported attribs
  9218. * @param mesh The mesh to prepare the bones attributes for
  9219. * @param defines The current Defines of the effect
  9220. * @param fallbacks The current efffect fallback strategy
  9221. */
  9222. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9223. /**
  9224. * Check and prepare the list of attributes required for instances according to the effect defines.
  9225. * @param attribs The current list of supported attribs
  9226. * @param defines The current MaterialDefines of the effect
  9227. */
  9228. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9229. /**
  9230. * Add the list of attributes required for instances to the attribs array.
  9231. * @param attribs The current list of supported attribs
  9232. */
  9233. static PushAttributesForInstances(attribs: string[]): void;
  9234. /**
  9235. * Binds the light information to the effect.
  9236. * @param light The light containing the generator
  9237. * @param effect The effect we are binding the data to
  9238. * @param lightIndex The light index in the effect used to render
  9239. */
  9240. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9241. /**
  9242. * Binds the lights information from the scene to the effect for the given mesh.
  9243. * @param light Light to bind
  9244. * @param lightIndex Light index
  9245. * @param scene The scene where the light belongs to
  9246. * @param effect The effect we are binding the data to
  9247. * @param useSpecular Defines if specular is supported
  9248. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9249. */
  9250. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9251. /**
  9252. * Binds the lights information from the scene to the effect for the given mesh.
  9253. * @param scene The scene the lights belongs to
  9254. * @param mesh The mesh we are binding the information to render
  9255. * @param effect The effect we are binding the data to
  9256. * @param defines The generated defines for the effect
  9257. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9258. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9259. */
  9260. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9261. private static _tempFogColor;
  9262. /**
  9263. * Binds the fog information from the scene to the effect for the given mesh.
  9264. * @param scene The scene the lights belongs to
  9265. * @param mesh The mesh we are binding the information to render
  9266. * @param effect The effect we are binding the data to
  9267. * @param linearSpace Defines if the fog effect is applied in linear space
  9268. */
  9269. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9270. /**
  9271. * Binds the bones information from the mesh to the effect.
  9272. * @param mesh The mesh we are binding the information to render
  9273. * @param effect The effect we are binding the data to
  9274. */
  9275. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9276. /**
  9277. * Binds the morph targets information from the mesh to the effect.
  9278. * @param abstractMesh The mesh we are binding the information to render
  9279. * @param effect The effect we are binding the data to
  9280. */
  9281. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9282. /**
  9283. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9284. * @param defines The generated defines used in the effect
  9285. * @param effect The effect we are binding the data to
  9286. * @param scene The scene we are willing to render with logarithmic scale for
  9287. */
  9288. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9289. /**
  9290. * Binds the clip plane information from the scene to the effect.
  9291. * @param scene The scene the clip plane information are extracted from
  9292. * @param effect The effect we are binding the data to
  9293. */
  9294. static BindClipPlane(effect: Effect, scene: Scene): void;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /** @hidden */
  9299. export var packingFunctions: {
  9300. name: string;
  9301. shader: string;
  9302. };
  9303. }
  9304. declare module BABYLON {
  9305. /** @hidden */
  9306. export var clipPlaneFragmentDeclaration: {
  9307. name: string;
  9308. shader: string;
  9309. };
  9310. }
  9311. declare module BABYLON {
  9312. /** @hidden */
  9313. export var clipPlaneFragment: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module BABYLON {
  9319. /** @hidden */
  9320. export var shadowMapPixelShader: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module BABYLON {
  9326. /** @hidden */
  9327. export var bonesDeclaration: {
  9328. name: string;
  9329. shader: string;
  9330. };
  9331. }
  9332. declare module BABYLON {
  9333. /** @hidden */
  9334. export var morphTargetsVertexGlobalDeclaration: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module BABYLON {
  9340. /** @hidden */
  9341. export var morphTargetsVertexDeclaration: {
  9342. name: string;
  9343. shader: string;
  9344. };
  9345. }
  9346. declare module BABYLON {
  9347. /** @hidden */
  9348. export var instancesDeclaration: {
  9349. name: string;
  9350. shader: string;
  9351. };
  9352. }
  9353. declare module BABYLON {
  9354. /** @hidden */
  9355. export var helperFunctions: {
  9356. name: string;
  9357. shader: string;
  9358. };
  9359. }
  9360. declare module BABYLON {
  9361. /** @hidden */
  9362. export var clipPlaneVertexDeclaration: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module BABYLON {
  9368. /** @hidden */
  9369. export var morphTargetsVertex: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module BABYLON {
  9375. /** @hidden */
  9376. export var instancesVertex: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module BABYLON {
  9382. /** @hidden */
  9383. export var bonesVertex: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module BABYLON {
  9389. /** @hidden */
  9390. export var clipPlaneVertex: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module BABYLON {
  9396. /** @hidden */
  9397. export var shadowMapVertexShader: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module BABYLON {
  9403. /** @hidden */
  9404. export var depthBoxBlurPixelShader: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module BABYLON {
  9410. /**
  9411. * Class representing a ray with position and direction
  9412. */
  9413. export class Ray {
  9414. /** origin point */
  9415. origin: Vector3;
  9416. /** direction */
  9417. direction: Vector3;
  9418. /** length of the ray */
  9419. length: number;
  9420. private static readonly TmpVector3;
  9421. private _tmpRay;
  9422. /**
  9423. * Creates a new ray
  9424. * @param origin origin point
  9425. * @param direction direction
  9426. * @param length length of the ray
  9427. */
  9428. constructor(
  9429. /** origin point */
  9430. origin: Vector3,
  9431. /** direction */
  9432. direction: Vector3,
  9433. /** length of the ray */
  9434. length?: number);
  9435. /**
  9436. * Checks if the ray intersects a box
  9437. * @param minimum bound of the box
  9438. * @param maximum bound of the box
  9439. * @param intersectionTreshold extra extend to be added to the box in all direction
  9440. * @returns if the box was hit
  9441. */
  9442. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9443. /**
  9444. * Checks if the ray intersects a box
  9445. * @param box the bounding box to check
  9446. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9447. * @returns if the box was hit
  9448. */
  9449. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9450. /**
  9451. * If the ray hits a sphere
  9452. * @param sphere the bounding sphere to check
  9453. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9454. * @returns true if it hits the sphere
  9455. */
  9456. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9457. /**
  9458. * If the ray hits a triange
  9459. * @param vertex0 triangle vertex
  9460. * @param vertex1 triangle vertex
  9461. * @param vertex2 triangle vertex
  9462. * @returns intersection information if hit
  9463. */
  9464. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9465. /**
  9466. * Checks if ray intersects a plane
  9467. * @param plane the plane to check
  9468. * @returns the distance away it was hit
  9469. */
  9470. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9471. /**
  9472. * Calculate the intercept of a ray on a given axis
  9473. * @param axis to check 'x' | 'y' | 'z'
  9474. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9475. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9476. */
  9477. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9478. /**
  9479. * Checks if ray intersects a mesh
  9480. * @param mesh the mesh to check
  9481. * @param fastCheck if only the bounding box should checked
  9482. * @returns picking info of the intersecton
  9483. */
  9484. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9485. /**
  9486. * Checks if ray intersects a mesh
  9487. * @param meshes the meshes to check
  9488. * @param fastCheck if only the bounding box should checked
  9489. * @param results array to store result in
  9490. * @returns Array of picking infos
  9491. */
  9492. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9493. private _comparePickingInfo;
  9494. private static smallnum;
  9495. private static rayl;
  9496. /**
  9497. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9498. * @param sega the first point of the segment to test the intersection against
  9499. * @param segb the second point of the segment to test the intersection against
  9500. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9501. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9502. */
  9503. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9504. /**
  9505. * Update the ray from viewport position
  9506. * @param x position
  9507. * @param y y position
  9508. * @param viewportWidth viewport width
  9509. * @param viewportHeight viewport height
  9510. * @param world world matrix
  9511. * @param view view matrix
  9512. * @param projection projection matrix
  9513. * @returns this ray updated
  9514. */
  9515. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9516. /**
  9517. * Creates a ray with origin and direction of 0,0,0
  9518. * @returns the new ray
  9519. */
  9520. static Zero(): Ray;
  9521. /**
  9522. * Creates a new ray from screen space and viewport
  9523. * @param x position
  9524. * @param y y position
  9525. * @param viewportWidth viewport width
  9526. * @param viewportHeight viewport height
  9527. * @param world world matrix
  9528. * @param view view matrix
  9529. * @param projection projection matrix
  9530. * @returns new ray
  9531. */
  9532. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9533. /**
  9534. * 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
  9535. * transformed to the given world matrix.
  9536. * @param origin The origin point
  9537. * @param end The end point
  9538. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9539. * @returns the new ray
  9540. */
  9541. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9542. /**
  9543. * Transforms a ray by a matrix
  9544. * @param ray ray to transform
  9545. * @param matrix matrix to apply
  9546. * @returns the resulting new ray
  9547. */
  9548. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9549. /**
  9550. * Transforms a ray by a matrix
  9551. * @param ray ray to transform
  9552. * @param matrix matrix to apply
  9553. * @param result ray to store result in
  9554. */
  9555. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9556. /**
  9557. * Unproject a ray from screen space to object space
  9558. * @param sourceX defines the screen space x coordinate to use
  9559. * @param sourceY defines the screen space y coordinate to use
  9560. * @param viewportWidth defines the current width of the viewport
  9561. * @param viewportHeight defines the current height of the viewport
  9562. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9563. * @param view defines the view matrix to use
  9564. * @param projection defines the projection matrix to use
  9565. */
  9566. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9567. }
  9568. /**
  9569. * Type used to define predicate used to select faces when a mesh intersection is detected
  9570. */
  9571. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9572. interface Scene {
  9573. /** @hidden */
  9574. _tempPickingRay: Nullable<Ray>;
  9575. /** @hidden */
  9576. _cachedRayForTransform: Ray;
  9577. /** @hidden */
  9578. _pickWithRayInverseMatrix: Matrix;
  9579. /** @hidden */
  9580. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9581. /** @hidden */
  9582. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9583. }
  9584. }
  9585. declare module BABYLON {
  9586. /**
  9587. * Groups all the scene component constants in one place to ease maintenance.
  9588. * @hidden
  9589. */
  9590. export class SceneComponentConstants {
  9591. static readonly NAME_EFFECTLAYER: string;
  9592. static readonly NAME_LAYER: string;
  9593. static readonly NAME_LENSFLARESYSTEM: string;
  9594. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9595. static readonly NAME_PARTICLESYSTEM: string;
  9596. static readonly NAME_GAMEPAD: string;
  9597. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9598. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9599. static readonly NAME_DEPTHRENDERER: string;
  9600. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9601. static readonly NAME_SPRITE: string;
  9602. static readonly NAME_OUTLINERENDERER: string;
  9603. static readonly NAME_PROCEDURALTEXTURE: string;
  9604. static readonly NAME_SHADOWGENERATOR: string;
  9605. static readonly NAME_OCTREE: string;
  9606. static readonly NAME_PHYSICSENGINE: string;
  9607. static readonly NAME_AUDIO: string;
  9608. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9609. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9610. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9611. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9612. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9613. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9614. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9615. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9616. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9617. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9618. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9619. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9620. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9621. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9622. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9623. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9624. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9625. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9626. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9627. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9628. static readonly STEP_AFTERRENDER_AUDIO: number;
  9629. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9630. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9631. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9632. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9633. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9634. static readonly STEP_POINTERMOVE_SPRITE: number;
  9635. static readonly STEP_POINTERDOWN_SPRITE: number;
  9636. static readonly STEP_POINTERUP_SPRITE: number;
  9637. }
  9638. /**
  9639. * This represents a scene component.
  9640. *
  9641. * This is used to decouple the dependency the scene is having on the different workloads like
  9642. * layers, post processes...
  9643. */
  9644. export interface ISceneComponent {
  9645. /**
  9646. * The name of the component. Each component must have a unique name.
  9647. */
  9648. name: string;
  9649. /**
  9650. * The scene the component belongs to.
  9651. */
  9652. scene: Scene;
  9653. /**
  9654. * Register the component to one instance of a scene.
  9655. */
  9656. register(): void;
  9657. /**
  9658. * Rebuilds the elements related to this component in case of
  9659. * context lost for instance.
  9660. */
  9661. rebuild(): void;
  9662. /**
  9663. * Disposes the component and the associated ressources.
  9664. */
  9665. dispose(): void;
  9666. }
  9667. /**
  9668. * This represents a SERIALIZABLE scene component.
  9669. *
  9670. * This extends Scene Component to add Serialization methods on top.
  9671. */
  9672. export interface ISceneSerializableComponent extends ISceneComponent {
  9673. /**
  9674. * Adds all the elements from the container to the scene
  9675. * @param container the container holding the elements
  9676. */
  9677. addFromContainer(container: AbstractScene): void;
  9678. /**
  9679. * Removes all the elements in the container from the scene
  9680. * @param container contains the elements to remove
  9681. * @param dispose if the removed element should be disposed (default: false)
  9682. */
  9683. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9684. /**
  9685. * Serializes the component data to the specified json object
  9686. * @param serializationObject The object to serialize to
  9687. */
  9688. serialize(serializationObject: any): void;
  9689. }
  9690. /**
  9691. * Strong typing of a Mesh related stage step action
  9692. */
  9693. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9694. /**
  9695. * Strong typing of a Evaluate Sub Mesh related stage step action
  9696. */
  9697. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9698. /**
  9699. * Strong typing of a Active Mesh related stage step action
  9700. */
  9701. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9702. /**
  9703. * Strong typing of a Camera related stage step action
  9704. */
  9705. export type CameraStageAction = (camera: Camera) => void;
  9706. /**
  9707. * Strong typing of a Camera Frame buffer related stage step action
  9708. */
  9709. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9710. /**
  9711. * Strong typing of a Render Target related stage step action
  9712. */
  9713. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9714. /**
  9715. * Strong typing of a RenderingGroup related stage step action
  9716. */
  9717. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9718. /**
  9719. * Strong typing of a Mesh Render related stage step action
  9720. */
  9721. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9722. /**
  9723. * Strong typing of a simple stage step action
  9724. */
  9725. export type SimpleStageAction = () => void;
  9726. /**
  9727. * Strong typing of a render target action.
  9728. */
  9729. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9730. /**
  9731. * Strong typing of a pointer move action.
  9732. */
  9733. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9734. /**
  9735. * Strong typing of a pointer up/down action.
  9736. */
  9737. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9738. /**
  9739. * Representation of a stage in the scene (Basically a list of ordered steps)
  9740. * @hidden
  9741. */
  9742. export class Stage<T extends Function> extends Array<{
  9743. index: number;
  9744. component: ISceneComponent;
  9745. action: T;
  9746. }> {
  9747. /**
  9748. * Hide ctor from the rest of the world.
  9749. * @param items The items to add.
  9750. */
  9751. private constructor();
  9752. /**
  9753. * Creates a new Stage.
  9754. * @returns A new instance of a Stage
  9755. */
  9756. static Create<T extends Function>(): Stage<T>;
  9757. /**
  9758. * Registers a step in an ordered way in the targeted stage.
  9759. * @param index Defines the position to register the step in
  9760. * @param component Defines the component attached to the step
  9761. * @param action Defines the action to launch during the step
  9762. */
  9763. registerStep(index: number, component: ISceneComponent, action: T): void;
  9764. /**
  9765. * Clears all the steps from the stage.
  9766. */
  9767. clear(): void;
  9768. }
  9769. }
  9770. declare module BABYLON {
  9771. interface Scene {
  9772. /** @hidden */
  9773. _pointerOverSprite: Nullable<Sprite>;
  9774. /** @hidden */
  9775. _pickedDownSprite: Nullable<Sprite>;
  9776. /** @hidden */
  9777. _tempSpritePickingRay: Nullable<Ray>;
  9778. /**
  9779. * All of the sprite managers added to this scene
  9780. * @see http://doc.babylonjs.com/babylon101/sprites
  9781. */
  9782. spriteManagers: Array<ISpriteManager>;
  9783. /**
  9784. * An event triggered when sprites rendering is about to start
  9785. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9786. */
  9787. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9788. /**
  9789. * An event triggered when sprites rendering is done
  9790. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9791. */
  9792. onAfterSpritesRenderingObservable: Observable<Scene>;
  9793. /** @hidden */
  9794. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9795. /** Launch a ray to try to pick a sprite in the scene
  9796. * @param x position on screen
  9797. * @param y position on screen
  9798. * @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
  9799. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9800. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9801. * @returns a PickingInfo
  9802. */
  9803. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9804. /** Use the given ray to pick a sprite in the scene
  9805. * @param ray The ray (in world space) to use to pick meshes
  9806. * @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
  9807. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9808. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9809. * @returns a PickingInfo
  9810. */
  9811. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9812. /** @hidden */
  9813. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9814. /** Launch a ray to try to pick sprites in the scene
  9815. * @param x position on screen
  9816. * @param y position on screen
  9817. * @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
  9818. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9819. * @returns a PickingInfo array
  9820. */
  9821. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9822. /** Use the given ray to pick sprites in the scene
  9823. * @param ray The ray (in world space) to use to pick meshes
  9824. * @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
  9825. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9826. * @returns a PickingInfo array
  9827. */
  9828. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9829. /**
  9830. * Force the sprite under the pointer
  9831. * @param sprite defines the sprite to use
  9832. */
  9833. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9834. /**
  9835. * Gets the sprite under the pointer
  9836. * @returns a Sprite or null if no sprite is under the pointer
  9837. */
  9838. getPointerOverSprite(): Nullable<Sprite>;
  9839. }
  9840. /**
  9841. * Defines the sprite scene component responsible to manage sprites
  9842. * in a given scene.
  9843. */
  9844. export class SpriteSceneComponent implements ISceneComponent {
  9845. /**
  9846. * The component name helpfull to identify the component in the list of scene components.
  9847. */
  9848. readonly name: string;
  9849. /**
  9850. * The scene the component belongs to.
  9851. */
  9852. scene: Scene;
  9853. /** @hidden */
  9854. private _spritePredicate;
  9855. /**
  9856. * Creates a new instance of the component for the given scene
  9857. * @param scene Defines the scene to register the component in
  9858. */
  9859. constructor(scene: Scene);
  9860. /**
  9861. * Registers the component in a given scene
  9862. */
  9863. register(): void;
  9864. /**
  9865. * Rebuilds the elements related to this component in case of
  9866. * context lost for instance.
  9867. */
  9868. rebuild(): void;
  9869. /**
  9870. * Disposes the component and the associated ressources.
  9871. */
  9872. dispose(): void;
  9873. private _pickSpriteButKeepRay;
  9874. private _pointerMove;
  9875. private _pointerDown;
  9876. private _pointerUp;
  9877. }
  9878. }
  9879. declare module BABYLON {
  9880. /** @hidden */
  9881. export var fogFragmentDeclaration: {
  9882. name: string;
  9883. shader: string;
  9884. };
  9885. }
  9886. declare module BABYLON {
  9887. /** @hidden */
  9888. export var fogFragment: {
  9889. name: string;
  9890. shader: string;
  9891. };
  9892. }
  9893. declare module BABYLON {
  9894. /** @hidden */
  9895. export var spritesPixelShader: {
  9896. name: string;
  9897. shader: string;
  9898. };
  9899. }
  9900. declare module BABYLON {
  9901. /** @hidden */
  9902. export var fogVertexDeclaration: {
  9903. name: string;
  9904. shader: string;
  9905. };
  9906. }
  9907. declare module BABYLON {
  9908. /** @hidden */
  9909. export var spritesVertexShader: {
  9910. name: string;
  9911. shader: string;
  9912. };
  9913. }
  9914. declare module BABYLON {
  9915. /**
  9916. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9917. */
  9918. export interface ISpriteManager extends IDisposable {
  9919. /**
  9920. * Restricts the camera to viewing objects with the same layerMask.
  9921. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9922. */
  9923. layerMask: number;
  9924. /**
  9925. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9926. */
  9927. isPickable: boolean;
  9928. /**
  9929. * Specifies the rendering group id for this mesh (0 by default)
  9930. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9931. */
  9932. renderingGroupId: number;
  9933. /**
  9934. * Defines the list of sprites managed by the manager.
  9935. */
  9936. sprites: Array<Sprite>;
  9937. /**
  9938. * Tests the intersection of a sprite with a specific ray.
  9939. * @param ray The ray we are sending to test the collision
  9940. * @param camera The camera space we are sending rays in
  9941. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9942. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9943. * @returns picking info or null.
  9944. */
  9945. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9946. /**
  9947. * Intersects the sprites with a ray
  9948. * @param ray defines the ray to intersect with
  9949. * @param camera defines the current active camera
  9950. * @param predicate defines a predicate used to select candidate sprites
  9951. * @returns null if no hit or a PickingInfo array
  9952. */
  9953. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9954. /**
  9955. * Renders the list of sprites on screen.
  9956. */
  9957. render(): void;
  9958. }
  9959. /**
  9960. * Class used to manage multiple sprites on the same spritesheet
  9961. * @see http://doc.babylonjs.com/babylon101/sprites
  9962. */
  9963. export class SpriteManager implements ISpriteManager {
  9964. /** defines the manager's name */
  9965. name: string;
  9966. /** Gets the list of sprites */
  9967. sprites: Sprite[];
  9968. /** Gets or sets the rendering group id (0 by default) */
  9969. renderingGroupId: number;
  9970. /** Gets or sets camera layer mask */
  9971. layerMask: number;
  9972. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9973. fogEnabled: boolean;
  9974. /** Gets or sets a boolean indicating if the sprites are pickable */
  9975. isPickable: boolean;
  9976. /** Defines the default width of a cell in the spritesheet */
  9977. cellWidth: number;
  9978. /** Defines the default height of a cell in the spritesheet */
  9979. cellHeight: number;
  9980. /** Associative array from JSON sprite data file */
  9981. private _cellData;
  9982. /** Array of sprite names from JSON sprite data file */
  9983. private _spriteMap;
  9984. /** True when packed cell data from JSON file is ready*/
  9985. private _packedAndReady;
  9986. /**
  9987. * An event triggered when the manager is disposed.
  9988. */
  9989. onDisposeObservable: Observable<SpriteManager>;
  9990. private _onDisposeObserver;
  9991. /**
  9992. * Callback called when the manager is disposed
  9993. */
  9994. set onDispose(callback: () => void);
  9995. private _capacity;
  9996. private _fromPacked;
  9997. private _spriteTexture;
  9998. private _epsilon;
  9999. private _scene;
  10000. private _vertexData;
  10001. private _buffer;
  10002. private _vertexBuffers;
  10003. private _indexBuffer;
  10004. private _effectBase;
  10005. private _effectFog;
  10006. /**
  10007. * Gets or sets the spritesheet texture
  10008. */
  10009. get texture(): Texture;
  10010. set texture(value: Texture);
  10011. private _blendMode;
  10012. /**
  10013. * Blend mode use to render the particle, it can be any of
  10014. * the static Constants.ALPHA_x properties provided in this class.
  10015. * Default value is Constants.ALPHA_COMBINE
  10016. */
  10017. get blendMode(): number;
  10018. set blendMode(blendMode: number);
  10019. /** Disables writing to the depth buffer when rendering the sprites.
  10020. * It can be handy to disable depth writing when using textures without alpha channel
  10021. * and setting some specific blend modes.
  10022. */
  10023. disableDepthWrite: boolean;
  10024. /**
  10025. * Creates a new sprite manager
  10026. * @param name defines the manager's name
  10027. * @param imgUrl defines the sprite sheet url
  10028. * @param capacity defines the maximum allowed number of sprites
  10029. * @param cellSize defines the size of a sprite cell
  10030. * @param scene defines the hosting scene
  10031. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10032. * @param samplingMode defines the smapling mode to use with spritesheet
  10033. * @param fromPacked set to false; do not alter
  10034. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10035. */
  10036. constructor(
  10037. /** defines the manager's name */
  10038. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10039. private _makePacked;
  10040. private _appendSpriteVertex;
  10041. /**
  10042. * Intersects the sprites with a ray
  10043. * @param ray defines the ray to intersect with
  10044. * @param camera defines the current active camera
  10045. * @param predicate defines a predicate used to select candidate sprites
  10046. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10047. * @returns null if no hit or a PickingInfo
  10048. */
  10049. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10050. /**
  10051. * Intersects the sprites with a ray
  10052. * @param ray defines the ray to intersect with
  10053. * @param camera defines the current active camera
  10054. * @param predicate defines a predicate used to select candidate sprites
  10055. * @returns null if no hit or a PickingInfo array
  10056. */
  10057. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10058. /**
  10059. * Render all child sprites
  10060. */
  10061. render(): void;
  10062. /**
  10063. * Release associated resources
  10064. */
  10065. dispose(): void;
  10066. }
  10067. }
  10068. declare module BABYLON {
  10069. /** Interface used by value gradients (color, factor, ...) */
  10070. export interface IValueGradient {
  10071. /**
  10072. * Gets or sets the gradient value (between 0 and 1)
  10073. */
  10074. gradient: number;
  10075. }
  10076. /** Class used to store color4 gradient */
  10077. export class ColorGradient implements IValueGradient {
  10078. /**
  10079. * Gets or sets the gradient value (between 0 and 1)
  10080. */
  10081. gradient: number;
  10082. /**
  10083. * Gets or sets first associated color
  10084. */
  10085. color1: Color4;
  10086. /**
  10087. * Gets or sets second associated color
  10088. */
  10089. color2?: Color4;
  10090. /**
  10091. * Will get a color picked randomly between color1 and color2.
  10092. * If color2 is undefined then color1 will be used
  10093. * @param result defines the target Color4 to store the result in
  10094. */
  10095. getColorToRef(result: Color4): void;
  10096. }
  10097. /** Class used to store color 3 gradient */
  10098. export class Color3Gradient implements IValueGradient {
  10099. /**
  10100. * Gets or sets the gradient value (between 0 and 1)
  10101. */
  10102. gradient: number;
  10103. /**
  10104. * Gets or sets the associated color
  10105. */
  10106. color: Color3;
  10107. }
  10108. /** Class used to store factor gradient */
  10109. export class FactorGradient implements IValueGradient {
  10110. /**
  10111. * Gets or sets the gradient value (between 0 and 1)
  10112. */
  10113. gradient: number;
  10114. /**
  10115. * Gets or sets first associated factor
  10116. */
  10117. factor1: number;
  10118. /**
  10119. * Gets or sets second associated factor
  10120. */
  10121. factor2?: number;
  10122. /**
  10123. * Will get a number picked randomly between factor1 and factor2.
  10124. * If factor2 is undefined then factor1 will be used
  10125. * @returns the picked number
  10126. */
  10127. getFactor(): number;
  10128. }
  10129. /**
  10130. * Helper used to simplify some generic gradient tasks
  10131. */
  10132. export class GradientHelper {
  10133. /**
  10134. * Gets the current gradient from an array of IValueGradient
  10135. * @param ratio defines the current ratio to get
  10136. * @param gradients defines the array of IValueGradient
  10137. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10138. */
  10139. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Interface for the size containing width and height
  10145. */
  10146. export interface ISize {
  10147. /**
  10148. * Width
  10149. */
  10150. width: number;
  10151. /**
  10152. * Heighht
  10153. */
  10154. height: number;
  10155. }
  10156. /**
  10157. * Size containing widht and height
  10158. */
  10159. export class Size implements ISize {
  10160. /**
  10161. * Width
  10162. */
  10163. width: number;
  10164. /**
  10165. * Height
  10166. */
  10167. height: number;
  10168. /**
  10169. * Creates a Size object from the given width and height (floats).
  10170. * @param width width of the new size
  10171. * @param height height of the new size
  10172. */
  10173. constructor(width: number, height: number);
  10174. /**
  10175. * Returns a string with the Size width and height
  10176. * @returns a string with the Size width and height
  10177. */
  10178. toString(): string;
  10179. /**
  10180. * "Size"
  10181. * @returns the string "Size"
  10182. */
  10183. getClassName(): string;
  10184. /**
  10185. * Returns the Size hash code.
  10186. * @returns a hash code for a unique width and height
  10187. */
  10188. getHashCode(): number;
  10189. /**
  10190. * Updates the current size from the given one.
  10191. * @param src the given size
  10192. */
  10193. copyFrom(src: Size): void;
  10194. /**
  10195. * Updates in place the current Size from the given floats.
  10196. * @param width width of the new size
  10197. * @param height height of the new size
  10198. * @returns the updated Size.
  10199. */
  10200. copyFromFloats(width: number, height: number): Size;
  10201. /**
  10202. * Updates in place the current Size from the given floats.
  10203. * @param width width to set
  10204. * @param height height to set
  10205. * @returns the updated Size.
  10206. */
  10207. set(width: number, height: number): Size;
  10208. /**
  10209. * Multiplies the width and height by numbers
  10210. * @param w factor to multiple the width by
  10211. * @param h factor to multiple the height by
  10212. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10213. */
  10214. multiplyByFloats(w: number, h: number): Size;
  10215. /**
  10216. * Clones the size
  10217. * @returns a new Size copied from the given one.
  10218. */
  10219. clone(): Size;
  10220. /**
  10221. * True if the current Size and the given one width and height are strictly equal.
  10222. * @param other the other size to compare against
  10223. * @returns True if the current Size and the given one width and height are strictly equal.
  10224. */
  10225. equals(other: Size): boolean;
  10226. /**
  10227. * The surface of the Size : width * height (float).
  10228. */
  10229. get surface(): number;
  10230. /**
  10231. * Create a new size of zero
  10232. * @returns a new Size set to (0.0, 0.0)
  10233. */
  10234. static Zero(): Size;
  10235. /**
  10236. * Sums the width and height of two sizes
  10237. * @param otherSize size to add to this size
  10238. * @returns a new Size set as the addition result of the current Size and the given one.
  10239. */
  10240. add(otherSize: Size): Size;
  10241. /**
  10242. * Subtracts the width and height of two
  10243. * @param otherSize size to subtract to this size
  10244. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10245. */
  10246. subtract(otherSize: Size): Size;
  10247. /**
  10248. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10249. * @param start starting size to lerp between
  10250. * @param end end size to lerp between
  10251. * @param amount amount to lerp between the start and end values
  10252. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10253. */
  10254. static Lerp(start: Size, end: Size, amount: number): Size;
  10255. }
  10256. }
  10257. declare module BABYLON {
  10258. interface ThinEngine {
  10259. /**
  10260. * Creates a dynamic texture
  10261. * @param width defines the width of the texture
  10262. * @param height defines the height of the texture
  10263. * @param generateMipMaps defines if the engine should generate the mip levels
  10264. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10265. * @returns the dynamic texture inside an InternalTexture
  10266. */
  10267. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10268. /**
  10269. * Update the content of a dynamic texture
  10270. * @param texture defines the texture to update
  10271. * @param canvas defines the canvas containing the source
  10272. * @param invertY defines if data must be stored with Y axis inverted
  10273. * @param premulAlpha defines if alpha is stored as premultiplied
  10274. * @param format defines the format of the data
  10275. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10276. */
  10277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Helper class used to generate a canvas to manipulate images
  10283. */
  10284. export class CanvasGenerator {
  10285. /**
  10286. * Create a new canvas (or offscreen canvas depending on the context)
  10287. * @param width defines the expected width
  10288. * @param height defines the expected height
  10289. * @return a new canvas or offscreen canvas
  10290. */
  10291. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10292. }
  10293. }
  10294. declare module BABYLON {
  10295. /**
  10296. * A class extending Texture allowing drawing on a texture
  10297. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10298. */
  10299. export class DynamicTexture extends Texture {
  10300. private _generateMipMaps;
  10301. private _canvas;
  10302. private _context;
  10303. private _engine;
  10304. /**
  10305. * Creates a DynamicTexture
  10306. * @param name defines the name of the texture
  10307. * @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
  10308. * @param scene defines the scene where you want the texture
  10309. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10310. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10311. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10312. */
  10313. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10314. /**
  10315. * Get the current class name of the texture useful for serialization or dynamic coding.
  10316. * @returns "DynamicTexture"
  10317. */
  10318. getClassName(): string;
  10319. /**
  10320. * Gets the current state of canRescale
  10321. */
  10322. get canRescale(): boolean;
  10323. private _recreate;
  10324. /**
  10325. * Scales the texture
  10326. * @param ratio the scale factor to apply to both width and height
  10327. */
  10328. scale(ratio: number): void;
  10329. /**
  10330. * Resizes the texture
  10331. * @param width the new width
  10332. * @param height the new height
  10333. */
  10334. scaleTo(width: number, height: number): void;
  10335. /**
  10336. * Gets the context of the canvas used by the texture
  10337. * @returns the canvas context of the dynamic texture
  10338. */
  10339. getContext(): CanvasRenderingContext2D;
  10340. /**
  10341. * Clears the texture
  10342. */
  10343. clear(): void;
  10344. /**
  10345. * Updates the texture
  10346. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10347. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10348. */
  10349. update(invertY?: boolean, premulAlpha?: boolean): void;
  10350. /**
  10351. * Draws text onto the texture
  10352. * @param text defines the text to be drawn
  10353. * @param x defines the placement of the text from the left
  10354. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10355. * @param font defines the font to be used with font-style, font-size, font-name
  10356. * @param color defines the color used for the text
  10357. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10358. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10359. * @param update defines whether texture is immediately update (default is true)
  10360. */
  10361. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10362. /**
  10363. * Clones the texture
  10364. * @returns the clone of the texture.
  10365. */
  10366. clone(): DynamicTexture;
  10367. /**
  10368. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10369. * @returns a serialized dynamic texture object
  10370. */
  10371. serialize(): any;
  10372. /** @hidden */
  10373. _rebuild(): void;
  10374. }
  10375. }
  10376. declare module BABYLON {
  10377. interface Engine {
  10378. /**
  10379. * Creates a raw texture
  10380. * @param data defines the data to store in the texture
  10381. * @param width defines the width of the texture
  10382. * @param height defines the height of the texture
  10383. * @param format defines the format of the data
  10384. * @param generateMipMaps defines if the engine should generate the mip levels
  10385. * @param invertY defines if data must be stored with Y axis inverted
  10386. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10387. * @param compression defines the compression used (null by default)
  10388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10389. * @returns the raw texture inside an InternalTexture
  10390. */
  10391. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10392. /**
  10393. * Update a raw texture
  10394. * @param texture defines the texture to update
  10395. * @param data defines the data to store in the texture
  10396. * @param format defines the format of the data
  10397. * @param invertY defines if data must be stored with Y axis inverted
  10398. */
  10399. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10400. /**
  10401. * Update a raw texture
  10402. * @param texture defines the texture to update
  10403. * @param data defines the data to store in the texture
  10404. * @param format defines the format of the data
  10405. * @param invertY defines if data must be stored with Y axis inverted
  10406. * @param compression defines the compression used (null by default)
  10407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10408. */
  10409. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10410. /**
  10411. * Creates a new raw cube texture
  10412. * @param data defines the array of data to use to create each face
  10413. * @param size defines the size of the textures
  10414. * @param format defines the format of the data
  10415. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10416. * @param generateMipMaps defines if the engine should generate the mip levels
  10417. * @param invertY defines if data must be stored with Y axis inverted
  10418. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10419. * @param compression defines the compression used (null by default)
  10420. * @returns the cube texture as an InternalTexture
  10421. */
  10422. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10423. /**
  10424. * Update a raw cube texture
  10425. * @param texture defines the texture to udpdate
  10426. * @param data defines the data to store
  10427. * @param format defines the data format
  10428. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10429. * @param invertY defines if data must be stored with Y axis inverted
  10430. */
  10431. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10432. /**
  10433. * Update a raw cube texture
  10434. * @param texture defines the texture to udpdate
  10435. * @param data defines the data to store
  10436. * @param format defines the data format
  10437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10438. * @param invertY defines if data must be stored with Y axis inverted
  10439. * @param compression defines the compression used (null by default)
  10440. */
  10441. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10442. /**
  10443. * Update a raw cube texture
  10444. * @param texture defines the texture to udpdate
  10445. * @param data defines the data to store
  10446. * @param format defines the data format
  10447. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param compression defines the compression used (null by default)
  10450. * @param level defines which level of the texture to update
  10451. */
  10452. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10453. /**
  10454. * Creates a new raw cube texture from a specified url
  10455. * @param url defines the url where the data is located
  10456. * @param scene defines the current scene
  10457. * @param size defines the size of the textures
  10458. * @param format defines the format of the data
  10459. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10460. * @param noMipmap defines if the engine should avoid generating the mip levels
  10461. * @param callback defines a callback used to extract texture data from loaded data
  10462. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10463. * @param onLoad defines a callback called when texture is loaded
  10464. * @param onError defines a callback called if there is an error
  10465. * @returns the cube texture as an InternalTexture
  10466. */
  10467. 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;
  10468. /**
  10469. * Creates a new raw cube texture from a specified url
  10470. * @param url defines the url where the data is located
  10471. * @param scene defines the current scene
  10472. * @param size defines the size of the textures
  10473. * @param format defines the format of the data
  10474. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10475. * @param noMipmap defines if the engine should avoid generating the mip levels
  10476. * @param callback defines a callback used to extract texture data from loaded data
  10477. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10478. * @param onLoad defines a callback called when texture is loaded
  10479. * @param onError defines a callback called if there is an error
  10480. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10481. * @param invertY defines if data must be stored with Y axis inverted
  10482. * @returns the cube texture as an InternalTexture
  10483. */
  10484. 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;
  10485. /**
  10486. * Creates a new raw 3D texture
  10487. * @param data defines the data used to create the texture
  10488. * @param width defines the width of the texture
  10489. * @param height defines the height of the texture
  10490. * @param depth defines the depth of the texture
  10491. * @param format defines the format of the texture
  10492. * @param generateMipMaps defines if the engine must generate mip levels
  10493. * @param invertY defines if data must be stored with Y axis inverted
  10494. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10495. * @param compression defines the compressed used (can be null)
  10496. * @param textureType defines the compressed used (can be null)
  10497. * @returns a new raw 3D texture (stored in an InternalTexture)
  10498. */
  10499. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10500. /**
  10501. * Update a raw 3D texture
  10502. * @param texture defines the texture to update
  10503. * @param data defines the data to store
  10504. * @param format defines the data format
  10505. * @param invertY defines if data must be stored with Y axis inverted
  10506. */
  10507. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10508. /**
  10509. * Update a raw 3D texture
  10510. * @param texture defines the texture to update
  10511. * @param data defines the data to store
  10512. * @param format defines the data format
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. * @param compression defines the used compression (can be null)
  10515. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10516. */
  10517. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10518. /**
  10519. * Creates a new raw 2D array texture
  10520. * @param data defines the data used to create the texture
  10521. * @param width defines the width of the texture
  10522. * @param height defines the height of the texture
  10523. * @param depth defines the number of layers of the texture
  10524. * @param format defines the format of the texture
  10525. * @param generateMipMaps defines if the engine must generate mip levels
  10526. * @param invertY defines if data must be stored with Y axis inverted
  10527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10528. * @param compression defines the compressed used (can be null)
  10529. * @param textureType defines the compressed used (can be null)
  10530. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10531. */
  10532. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10533. /**
  10534. * Update a raw 2D array texture
  10535. * @param texture defines the texture to update
  10536. * @param data defines the data to store
  10537. * @param format defines the data format
  10538. * @param invertY defines if data must be stored with Y axis inverted
  10539. */
  10540. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10541. /**
  10542. * Update a raw 2D array texture
  10543. * @param texture defines the texture to update
  10544. * @param data defines the data to store
  10545. * @param format defines the data format
  10546. * @param invertY defines if data must be stored with Y axis inverted
  10547. * @param compression defines the used compression (can be null)
  10548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10549. */
  10550. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10551. }
  10552. }
  10553. declare module BABYLON {
  10554. /**
  10555. * Raw texture can help creating a texture directly from an array of data.
  10556. * This can be super useful if you either get the data from an uncompressed source or
  10557. * if you wish to create your texture pixel by pixel.
  10558. */
  10559. export class RawTexture extends Texture {
  10560. /**
  10561. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10562. */
  10563. format: number;
  10564. private _engine;
  10565. /**
  10566. * Instantiates a new RawTexture.
  10567. * Raw texture can help creating a texture directly from an array of data.
  10568. * This can be super useful if you either get the data from an uncompressed source or
  10569. * if you wish to create your texture pixel by pixel.
  10570. * @param data define the array of data to use to create the texture
  10571. * @param width define the width of the texture
  10572. * @param height define the height of the texture
  10573. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10574. * @param scene define the scene the texture belongs to
  10575. * @param generateMipMaps define whether mip maps should be generated or not
  10576. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10577. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10578. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10579. */
  10580. constructor(data: ArrayBufferView, width: number, height: number,
  10581. /**
  10582. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10583. */
  10584. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10585. /**
  10586. * Updates the texture underlying data.
  10587. * @param data Define the new data of the texture
  10588. */
  10589. update(data: ArrayBufferView): void;
  10590. /**
  10591. * Creates a luminance texture from some data.
  10592. * @param data Define the texture data
  10593. * @param width Define the width of the texture
  10594. * @param height Define the height of the texture
  10595. * @param scene Define the scene the texture belongs to
  10596. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10599. * @returns the luminance texture
  10600. */
  10601. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10602. /**
  10603. * Creates a luminance alpha texture from some data.
  10604. * @param data Define the texture data
  10605. * @param width Define the width of the texture
  10606. * @param height Define the height of the texture
  10607. * @param scene Define the scene the texture belongs to
  10608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10611. * @returns the luminance alpha texture
  10612. */
  10613. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10614. /**
  10615. * Creates an alpha texture from some data.
  10616. * @param data Define the texture data
  10617. * @param width Define the width of the texture
  10618. * @param height Define the height of the texture
  10619. * @param scene Define the scene the texture belongs to
  10620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10623. * @returns the alpha texture
  10624. */
  10625. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10626. /**
  10627. * Creates a RGB texture from some data.
  10628. * @param data Define the texture data
  10629. * @param width Define the width of the texture
  10630. * @param height Define the height of the texture
  10631. * @param scene Define the scene the texture belongs to
  10632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10635. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10636. * @returns the RGB alpha texture
  10637. */
  10638. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10639. /**
  10640. * Creates a RGBA texture from some data.
  10641. * @param data Define the texture data
  10642. * @param width Define the width of the texture
  10643. * @param height Define the height of the texture
  10644. * @param scene Define the scene the texture belongs to
  10645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10649. * @returns the RGBA texture
  10650. */
  10651. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10652. /**
  10653. * Creates a R texture from some data.
  10654. * @param data Define the texture data
  10655. * @param width Define the width of the texture
  10656. * @param height Define the height of the texture
  10657. * @param scene Define the scene the texture belongs to
  10658. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10661. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10662. * @returns the R texture
  10663. */
  10664. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10665. }
  10666. }
  10667. declare module BABYLON {
  10668. interface AbstractScene {
  10669. /**
  10670. * The list of procedural textures added to the scene
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10672. */
  10673. proceduralTextures: Array<ProceduralTexture>;
  10674. }
  10675. /**
  10676. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10677. * in a given scene.
  10678. */
  10679. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10680. /**
  10681. * The component name helpfull to identify the component in the list of scene components.
  10682. */
  10683. readonly name: string;
  10684. /**
  10685. * The scene the component belongs to.
  10686. */
  10687. scene: Scene;
  10688. /**
  10689. * Creates a new instance of the component for the given scene
  10690. * @param scene Defines the scene to register the component in
  10691. */
  10692. constructor(scene: Scene);
  10693. /**
  10694. * Registers the component in a given scene
  10695. */
  10696. register(): void;
  10697. /**
  10698. * Rebuilds the elements related to this component in case of
  10699. * context lost for instance.
  10700. */
  10701. rebuild(): void;
  10702. /**
  10703. * Disposes the component and the associated ressources.
  10704. */
  10705. dispose(): void;
  10706. private _beforeClear;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. interface ThinEngine {
  10711. /**
  10712. * Creates a new render target cube texture
  10713. * @param size defines the size of the texture
  10714. * @param options defines the options used to create the texture
  10715. * @returns a new render target cube texture stored in an InternalTexture
  10716. */
  10717. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10718. }
  10719. }
  10720. declare module BABYLON {
  10721. /** @hidden */
  10722. export var proceduralVertexShader: {
  10723. name: string;
  10724. shader: string;
  10725. };
  10726. }
  10727. declare module BABYLON {
  10728. /**
  10729. * 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.
  10730. * This is the base class of any Procedural texture and contains most of the shareable code.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10732. */
  10733. export class ProceduralTexture extends Texture {
  10734. isCube: boolean;
  10735. /**
  10736. * Define if the texture is enabled or not (disabled texture will not render)
  10737. */
  10738. isEnabled: boolean;
  10739. /**
  10740. * Define if the texture must be cleared before rendering (default is true)
  10741. */
  10742. autoClear: boolean;
  10743. /**
  10744. * Callback called when the texture is generated
  10745. */
  10746. onGenerated: () => void;
  10747. /**
  10748. * Event raised when the texture is generated
  10749. */
  10750. onGeneratedObservable: Observable<ProceduralTexture>;
  10751. /** @hidden */
  10752. _generateMipMaps: boolean;
  10753. /** @hidden **/
  10754. _effect: Effect;
  10755. /** @hidden */
  10756. _textures: {
  10757. [key: string]: Texture;
  10758. };
  10759. private _size;
  10760. private _currentRefreshId;
  10761. private _frameId;
  10762. private _refreshRate;
  10763. private _vertexBuffers;
  10764. private _indexBuffer;
  10765. private _uniforms;
  10766. private _samplers;
  10767. private _fragment;
  10768. private _floats;
  10769. private _ints;
  10770. private _floatsArrays;
  10771. private _colors3;
  10772. private _colors4;
  10773. private _vectors2;
  10774. private _vectors3;
  10775. private _matrices;
  10776. private _fallbackTexture;
  10777. private _fallbackTextureUsed;
  10778. private _engine;
  10779. private _cachedDefines;
  10780. private _contentUpdateId;
  10781. private _contentData;
  10782. /**
  10783. * Instantiates a new procedural texture.
  10784. * 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.
  10785. * This is the base class of any Procedural texture and contains most of the shareable code.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10787. * @param name Define the name of the texture
  10788. * @param size Define the size of the texture to create
  10789. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10790. * @param scene Define the scene the texture belongs to
  10791. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10792. * @param generateMipMaps Define if the texture should creates mip maps or not
  10793. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10794. */
  10795. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10796. /**
  10797. * The effect that is created when initializing the post process.
  10798. * @returns The created effect corresponding the the postprocess.
  10799. */
  10800. getEffect(): Effect;
  10801. /**
  10802. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10803. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10804. */
  10805. getContent(): Nullable<ArrayBufferView>;
  10806. private _createIndexBuffer;
  10807. /** @hidden */
  10808. _rebuild(): void;
  10809. /**
  10810. * Resets the texture in order to recreate its associated resources.
  10811. * This can be called in case of context loss
  10812. */
  10813. reset(): void;
  10814. protected _getDefines(): string;
  10815. /**
  10816. * Is the texture ready to be used ? (rendered at least once)
  10817. * @returns true if ready, otherwise, false.
  10818. */
  10819. isReady(): boolean;
  10820. /**
  10821. * Resets the refresh counter of the texture and start bak from scratch.
  10822. * Could be useful to regenerate the texture if it is setup to render only once.
  10823. */
  10824. resetRefreshCounter(): void;
  10825. /**
  10826. * Set the fragment shader to use in order to render the texture.
  10827. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10828. */
  10829. setFragment(fragment: any): void;
  10830. /**
  10831. * Define the refresh rate of the texture or the rendering frequency.
  10832. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10833. */
  10834. get refreshRate(): number;
  10835. set refreshRate(value: number);
  10836. /** @hidden */
  10837. _shouldRender(): boolean;
  10838. /**
  10839. * Get the size the texture is rendering at.
  10840. * @returns the size (texture is always squared)
  10841. */
  10842. getRenderSize(): number;
  10843. /**
  10844. * Resize the texture to new value.
  10845. * @param size Define the new size the texture should have
  10846. * @param generateMipMaps Define whether the new texture should create mip maps
  10847. */
  10848. resize(size: number, generateMipMaps: boolean): void;
  10849. private _checkUniform;
  10850. /**
  10851. * Set a texture in the shader program used to render.
  10852. * @param name Define the name of the uniform samplers as defined in the shader
  10853. * @param texture Define the texture to bind to this sampler
  10854. * @return the texture itself allowing "fluent" like uniform updates
  10855. */
  10856. setTexture(name: string, texture: Texture): ProceduralTexture;
  10857. /**
  10858. * Set a float in the shader.
  10859. * @param name Define the name of the uniform as defined in the shader
  10860. * @param value Define the value to give to the uniform
  10861. * @return the texture itself allowing "fluent" like uniform updates
  10862. */
  10863. setFloat(name: string, value: number): ProceduralTexture;
  10864. /**
  10865. * Set a int in the shader.
  10866. * @param name Define the name of the uniform as defined in the shader
  10867. * @param value Define the value to give to the uniform
  10868. * @return the texture itself allowing "fluent" like uniform updates
  10869. */
  10870. setInt(name: string, value: number): ProceduralTexture;
  10871. /**
  10872. * Set an array of floats in the shader.
  10873. * @param name Define the name of the uniform as defined in the shader
  10874. * @param value Define the value to give to the uniform
  10875. * @return the texture itself allowing "fluent" like uniform updates
  10876. */
  10877. setFloats(name: string, value: number[]): ProceduralTexture;
  10878. /**
  10879. * Set a vec3 in the shader from a Color3.
  10880. * @param name Define the name of the uniform as defined in the shader
  10881. * @param value Define the value to give to the uniform
  10882. * @return the texture itself allowing "fluent" like uniform updates
  10883. */
  10884. setColor3(name: string, value: Color3): ProceduralTexture;
  10885. /**
  10886. * Set a vec4 in the shader from a Color4.
  10887. * @param name Define the name of the uniform as defined in the shader
  10888. * @param value Define the value to give to the uniform
  10889. * @return the texture itself allowing "fluent" like uniform updates
  10890. */
  10891. setColor4(name: string, value: Color4): ProceduralTexture;
  10892. /**
  10893. * Set a vec2 in the shader from a Vector2.
  10894. * @param name Define the name of the uniform as defined in the shader
  10895. * @param value Define the value to give to the uniform
  10896. * @return the texture itself allowing "fluent" like uniform updates
  10897. */
  10898. setVector2(name: string, value: Vector2): ProceduralTexture;
  10899. /**
  10900. * Set a vec3 in the shader from a Vector3.
  10901. * @param name Define the name of the uniform as defined in the shader
  10902. * @param value Define the value to give to the uniform
  10903. * @return the texture itself allowing "fluent" like uniform updates
  10904. */
  10905. setVector3(name: string, value: Vector3): ProceduralTexture;
  10906. /**
  10907. * Set a mat4 in the shader from a MAtrix.
  10908. * @param name Define the name of the uniform as defined in the shader
  10909. * @param value Define the value to give to the uniform
  10910. * @return the texture itself allowing "fluent" like uniform updates
  10911. */
  10912. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10913. /**
  10914. * Render the texture to its associated render target.
  10915. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10916. */
  10917. render(useCameraPostProcess?: boolean): void;
  10918. /**
  10919. * Clone the texture.
  10920. * @returns the cloned texture
  10921. */
  10922. clone(): ProceduralTexture;
  10923. /**
  10924. * Dispose the texture and release its asoociated resources.
  10925. */
  10926. dispose(): void;
  10927. }
  10928. }
  10929. declare module BABYLON {
  10930. /**
  10931. * This represents the base class for particle system in Babylon.
  10932. * 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.
  10933. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10934. * @example https://doc.babylonjs.com/babylon101/particles
  10935. */
  10936. export class BaseParticleSystem {
  10937. /**
  10938. * Source color is added to the destination color without alpha affecting the result
  10939. */
  10940. static BLENDMODE_ONEONE: number;
  10941. /**
  10942. * Blend current color and particle color using particle’s alpha
  10943. */
  10944. static BLENDMODE_STANDARD: number;
  10945. /**
  10946. * Add current color and particle color multiplied by particle’s alpha
  10947. */
  10948. static BLENDMODE_ADD: number;
  10949. /**
  10950. * Multiply current color with particle color
  10951. */
  10952. static BLENDMODE_MULTIPLY: number;
  10953. /**
  10954. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10955. */
  10956. static BLENDMODE_MULTIPLYADD: number;
  10957. /**
  10958. * List of animations used by the particle system.
  10959. */
  10960. animations: Animation[];
  10961. /**
  10962. * The id of the Particle system.
  10963. */
  10964. id: string;
  10965. /**
  10966. * The friendly name of the Particle system.
  10967. */
  10968. name: string;
  10969. /**
  10970. * The rendering group used by the Particle system to chose when to render.
  10971. */
  10972. renderingGroupId: number;
  10973. /**
  10974. * The emitter represents the Mesh or position we are attaching the particle system to.
  10975. */
  10976. emitter: Nullable<AbstractMesh | Vector3>;
  10977. /**
  10978. * The maximum number of particles to emit per frame
  10979. */
  10980. emitRate: number;
  10981. /**
  10982. * If you want to launch only a few particles at once, that can be done, as well.
  10983. */
  10984. manualEmitCount: number;
  10985. /**
  10986. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10987. */
  10988. updateSpeed: number;
  10989. /**
  10990. * The amount of time the particle system is running (depends of the overall update speed).
  10991. */
  10992. targetStopDuration: number;
  10993. /**
  10994. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  10995. */
  10996. disposeOnStop: boolean;
  10997. /**
  10998. * Minimum power of emitting particles.
  10999. */
  11000. minEmitPower: number;
  11001. /**
  11002. * Maximum power of emitting particles.
  11003. */
  11004. maxEmitPower: number;
  11005. /**
  11006. * Minimum life time of emitting particles.
  11007. */
  11008. minLifeTime: number;
  11009. /**
  11010. * Maximum life time of emitting particles.
  11011. */
  11012. maxLifeTime: number;
  11013. /**
  11014. * Minimum Size of emitting particles.
  11015. */
  11016. minSize: number;
  11017. /**
  11018. * Maximum Size of emitting particles.
  11019. */
  11020. maxSize: number;
  11021. /**
  11022. * Minimum scale of emitting particles on X axis.
  11023. */
  11024. minScaleX: number;
  11025. /**
  11026. * Maximum scale of emitting particles on X axis.
  11027. */
  11028. maxScaleX: number;
  11029. /**
  11030. * Minimum scale of emitting particles on Y axis.
  11031. */
  11032. minScaleY: number;
  11033. /**
  11034. * Maximum scale of emitting particles on Y axis.
  11035. */
  11036. maxScaleY: number;
  11037. /**
  11038. * Gets or sets the minimal initial rotation in radians.
  11039. */
  11040. minInitialRotation: number;
  11041. /**
  11042. * Gets or sets the maximal initial rotation in radians.
  11043. */
  11044. maxInitialRotation: number;
  11045. /**
  11046. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11047. */
  11048. minAngularSpeed: number;
  11049. /**
  11050. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11051. */
  11052. maxAngularSpeed: number;
  11053. /**
  11054. * The texture used to render each particle. (this can be a spritesheet)
  11055. */
  11056. particleTexture: Nullable<Texture>;
  11057. /**
  11058. * The layer mask we are rendering the particles through.
  11059. */
  11060. layerMask: number;
  11061. /**
  11062. * This can help using your own shader to render the particle system.
  11063. * The according effect will be created
  11064. */
  11065. customShader: any;
  11066. /**
  11067. * By default particle system starts as soon as they are created. This prevents the
  11068. * automatic start to happen and let you decide when to start emitting particles.
  11069. */
  11070. preventAutoStart: boolean;
  11071. private _noiseTexture;
  11072. /**
  11073. * Gets or sets a texture used to add random noise to particle positions
  11074. */
  11075. get noiseTexture(): Nullable<ProceduralTexture>;
  11076. set noiseTexture(value: Nullable<ProceduralTexture>);
  11077. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11078. noiseStrength: Vector3;
  11079. /**
  11080. * Callback triggered when the particle animation is ending.
  11081. */
  11082. onAnimationEnd: Nullable<() => void>;
  11083. /**
  11084. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11085. */
  11086. blendMode: number;
  11087. /**
  11088. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11089. * to override the particles.
  11090. */
  11091. forceDepthWrite: boolean;
  11092. /** 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 */
  11093. preWarmCycles: number;
  11094. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11095. preWarmStepOffset: number;
  11096. /**
  11097. * 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)
  11098. */
  11099. spriteCellChangeSpeed: number;
  11100. /**
  11101. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11102. */
  11103. startSpriteCellID: number;
  11104. /**
  11105. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11106. */
  11107. endSpriteCellID: number;
  11108. /**
  11109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11110. */
  11111. spriteCellWidth: number;
  11112. /**
  11113. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11114. */
  11115. spriteCellHeight: number;
  11116. /**
  11117. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11118. */
  11119. spriteRandomStartCell: boolean;
  11120. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11121. translationPivot: Vector2;
  11122. /** @hidden */
  11123. protected _isAnimationSheetEnabled: boolean;
  11124. /**
  11125. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11126. */
  11127. beginAnimationOnStart: boolean;
  11128. /**
  11129. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11130. */
  11131. beginAnimationFrom: number;
  11132. /**
  11133. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11134. */
  11135. beginAnimationTo: number;
  11136. /**
  11137. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11138. */
  11139. beginAnimationLoop: boolean;
  11140. /**
  11141. * Gets or sets a world offset applied to all particles
  11142. */
  11143. worldOffset: Vector3;
  11144. /**
  11145. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11146. */
  11147. get isAnimationSheetEnabled(): boolean;
  11148. set isAnimationSheetEnabled(value: boolean);
  11149. /**
  11150. * Get hosting scene
  11151. * @returns the scene
  11152. */
  11153. getScene(): Scene;
  11154. /**
  11155. * You can use gravity if you want to give an orientation to your particles.
  11156. */
  11157. gravity: Vector3;
  11158. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11159. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11160. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11161. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11162. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11163. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11164. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11165. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11166. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11167. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11168. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11169. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11170. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11171. /**
  11172. * Defines the delay in milliseconds before starting the system (0 by default)
  11173. */
  11174. startDelay: number;
  11175. /**
  11176. * Gets the current list of drag gradients.
  11177. * You must use addDragGradient and removeDragGradient to udpate this list
  11178. * @returns the list of drag gradients
  11179. */
  11180. getDragGradients(): Nullable<Array<FactorGradient>>;
  11181. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11182. limitVelocityDamping: number;
  11183. /**
  11184. * Gets the current list of limit velocity gradients.
  11185. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11186. * @returns the list of limit velocity gradients
  11187. */
  11188. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11189. /**
  11190. * Gets the current list of color gradients.
  11191. * You must use addColorGradient and removeColorGradient to udpate this list
  11192. * @returns the list of color gradients
  11193. */
  11194. getColorGradients(): Nullable<Array<ColorGradient>>;
  11195. /**
  11196. * Gets the current list of size gradients.
  11197. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11198. * @returns the list of size gradients
  11199. */
  11200. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11201. /**
  11202. * Gets the current list of color remap gradients.
  11203. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11204. * @returns the list of color remap gradients
  11205. */
  11206. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11207. /**
  11208. * Gets the current list of alpha remap gradients.
  11209. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11210. * @returns the list of alpha remap gradients
  11211. */
  11212. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11213. /**
  11214. * Gets the current list of life time gradients.
  11215. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11216. * @returns the list of life time gradients
  11217. */
  11218. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11219. /**
  11220. * Gets the current list of angular speed gradients.
  11221. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11222. * @returns the list of angular speed gradients
  11223. */
  11224. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11225. /**
  11226. * Gets the current list of velocity gradients.
  11227. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11228. * @returns the list of velocity gradients
  11229. */
  11230. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11231. /**
  11232. * Gets the current list of start size gradients.
  11233. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11234. * @returns the list of start size gradients
  11235. */
  11236. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11237. /**
  11238. * Gets the current list of emit rate gradients.
  11239. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11240. * @returns the list of emit rate gradients
  11241. */
  11242. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11243. /**
  11244. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11245. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11246. */
  11247. get direction1(): Vector3;
  11248. set direction1(value: Vector3);
  11249. /**
  11250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11252. */
  11253. get direction2(): Vector3;
  11254. set direction2(value: Vector3);
  11255. /**
  11256. * 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.
  11257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11258. */
  11259. get minEmitBox(): Vector3;
  11260. set minEmitBox(value: Vector3);
  11261. /**
  11262. * 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.
  11263. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11264. */
  11265. get maxEmitBox(): Vector3;
  11266. set maxEmitBox(value: Vector3);
  11267. /**
  11268. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11269. */
  11270. color1: Color4;
  11271. /**
  11272. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11273. */
  11274. color2: Color4;
  11275. /**
  11276. * Color the particle will have at the end of its lifetime
  11277. */
  11278. colorDead: Color4;
  11279. /**
  11280. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11281. */
  11282. textureMask: Color4;
  11283. /**
  11284. * The particle emitter type defines the emitter used by the particle system.
  11285. * It can be for example box, sphere, or cone...
  11286. */
  11287. particleEmitterType: IParticleEmitterType;
  11288. /** @hidden */
  11289. _isSubEmitter: boolean;
  11290. /**
  11291. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11292. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11293. */
  11294. billboardMode: number;
  11295. protected _isBillboardBased: boolean;
  11296. /**
  11297. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11298. */
  11299. get isBillboardBased(): boolean;
  11300. set isBillboardBased(value: boolean);
  11301. /**
  11302. * The scene the particle system belongs to.
  11303. */
  11304. protected _scene: Scene;
  11305. /**
  11306. * Local cache of defines for image processing.
  11307. */
  11308. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11309. /**
  11310. * Default configuration related to image processing available in the standard Material.
  11311. */
  11312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11313. /**
  11314. * Gets the image processing configuration used either in this material.
  11315. */
  11316. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11317. /**
  11318. * Sets the Default image processing configuration used either in the this material.
  11319. *
  11320. * If sets to null, the scene one is in use.
  11321. */
  11322. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11323. /**
  11324. * Attaches a new image processing configuration to the Standard Material.
  11325. * @param configuration
  11326. */
  11327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11328. /** @hidden */
  11329. protected _reset(): void;
  11330. /** @hidden */
  11331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11332. /**
  11333. * Instantiates a particle system.
  11334. * 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.
  11335. * @param name The name of the particle system
  11336. */
  11337. constructor(name: string);
  11338. /**
  11339. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11342. * @returns the emitter
  11343. */
  11344. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11345. /**
  11346. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11347. * @param radius The radius of the hemisphere to emit from
  11348. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11349. * @returns the emitter
  11350. */
  11351. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11352. /**
  11353. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11354. * @param radius The radius of the sphere to emit from
  11355. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11356. * @returns the emitter
  11357. */
  11358. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11359. /**
  11360. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11361. * @param radius The radius of the sphere to emit from
  11362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11364. * @returns the emitter
  11365. */
  11366. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11367. /**
  11368. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11369. * @param radius The radius of the emission cylinder
  11370. * @param height The height of the emission cylinder
  11371. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11372. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11373. * @returns the emitter
  11374. */
  11375. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11376. /**
  11377. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11378. * @param radius The radius of the cylinder to emit from
  11379. * @param height The height of the emission cylinder
  11380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11383. * @returns the emitter
  11384. */
  11385. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11386. /**
  11387. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11388. * @param radius The radius of the cone to emit from
  11389. * @param angle The base angle of the cone
  11390. * @returns the emitter
  11391. */
  11392. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11393. /**
  11394. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11397. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11398. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11399. * @returns the emitter
  11400. */
  11401. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11402. }
  11403. }
  11404. declare module BABYLON {
  11405. /**
  11406. * Type of sub emitter
  11407. */
  11408. export enum SubEmitterType {
  11409. /**
  11410. * Attached to the particle over it's lifetime
  11411. */
  11412. ATTACHED = 0,
  11413. /**
  11414. * Created when the particle dies
  11415. */
  11416. END = 1
  11417. }
  11418. /**
  11419. * Sub emitter class used to emit particles from an existing particle
  11420. */
  11421. export class SubEmitter {
  11422. /**
  11423. * the particle system to be used by the sub emitter
  11424. */
  11425. particleSystem: ParticleSystem;
  11426. /**
  11427. * Type of the submitter (Default: END)
  11428. */
  11429. type: SubEmitterType;
  11430. /**
  11431. * 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)
  11432. * Note: This only is supported when using an emitter of type Mesh
  11433. */
  11434. inheritDirection: boolean;
  11435. /**
  11436. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11437. */
  11438. inheritedVelocityAmount: number;
  11439. /**
  11440. * Creates a sub emitter
  11441. * @param particleSystem the particle system to be used by the sub emitter
  11442. */
  11443. constructor(
  11444. /**
  11445. * the particle system to be used by the sub emitter
  11446. */
  11447. particleSystem: ParticleSystem);
  11448. /**
  11449. * Clones the sub emitter
  11450. * @returns the cloned sub emitter
  11451. */
  11452. clone(): SubEmitter;
  11453. /**
  11454. * Serialize current object to a JSON object
  11455. * @returns the serialized object
  11456. */
  11457. serialize(): any;
  11458. /** @hidden */
  11459. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11460. /**
  11461. * Creates a new SubEmitter from a serialized JSON version
  11462. * @param serializationObject defines the JSON object to read from
  11463. * @param scene defines the hosting scene
  11464. * @param rootUrl defines the rootUrl for data loading
  11465. * @returns a new SubEmitter
  11466. */
  11467. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11468. /** Release associated resources */
  11469. dispose(): void;
  11470. }
  11471. }
  11472. declare module BABYLON {
  11473. /** @hidden */
  11474. export var imageProcessingDeclaration: {
  11475. name: string;
  11476. shader: string;
  11477. };
  11478. }
  11479. declare module BABYLON {
  11480. /** @hidden */
  11481. export var imageProcessingFunctions: {
  11482. name: string;
  11483. shader: string;
  11484. };
  11485. }
  11486. declare module BABYLON {
  11487. /** @hidden */
  11488. export var particlesPixelShader: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module BABYLON {
  11494. /** @hidden */
  11495. export var particlesVertexShader: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module BABYLON {
  11501. /**
  11502. * This represents a particle system in Babylon.
  11503. * 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.
  11504. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11505. * @example https://doc.babylonjs.com/babylon101/particles
  11506. */
  11507. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11508. /**
  11509. * Billboard mode will only apply to Y axis
  11510. */
  11511. static readonly BILLBOARDMODE_Y: number;
  11512. /**
  11513. * Billboard mode will apply to all axes
  11514. */
  11515. static readonly BILLBOARDMODE_ALL: number;
  11516. /**
  11517. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11518. */
  11519. static readonly BILLBOARDMODE_STRETCHED: number;
  11520. /**
  11521. * This function can be defined to provide custom update for active particles.
  11522. * This function will be called instead of regular update (age, position, color, etc.).
  11523. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11524. */
  11525. updateFunction: (particles: Particle[]) => void;
  11526. private _emitterWorldMatrix;
  11527. /**
  11528. * This function can be defined to specify initial direction for every new particle.
  11529. * It by default use the emitterType defined function
  11530. */
  11531. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11532. /**
  11533. * This function can be defined to specify initial position for every new particle.
  11534. * It by default use the emitterType defined function
  11535. */
  11536. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11537. /**
  11538. * @hidden
  11539. */
  11540. _inheritedVelocityOffset: Vector3;
  11541. /**
  11542. * An event triggered when the system is disposed
  11543. */
  11544. onDisposeObservable: Observable<ParticleSystem>;
  11545. private _onDisposeObserver;
  11546. /**
  11547. * Sets a callback that will be triggered when the system is disposed
  11548. */
  11549. set onDispose(callback: () => void);
  11550. private _particles;
  11551. private _epsilon;
  11552. private _capacity;
  11553. private _stockParticles;
  11554. private _newPartsExcess;
  11555. private _vertexData;
  11556. private _vertexBuffer;
  11557. private _vertexBuffers;
  11558. private _spriteBuffer;
  11559. private _indexBuffer;
  11560. private _effect;
  11561. private _customEffect;
  11562. private _cachedDefines;
  11563. private _scaledColorStep;
  11564. private _colorDiff;
  11565. private _scaledDirection;
  11566. private _scaledGravity;
  11567. private _currentRenderId;
  11568. private _alive;
  11569. private _useInstancing;
  11570. private _started;
  11571. private _stopped;
  11572. private _actualFrame;
  11573. private _scaledUpdateSpeed;
  11574. private _vertexBufferSize;
  11575. /** @hidden */
  11576. _currentEmitRateGradient: Nullable<FactorGradient>;
  11577. /** @hidden */
  11578. _currentEmitRate1: number;
  11579. /** @hidden */
  11580. _currentEmitRate2: number;
  11581. /** @hidden */
  11582. _currentStartSizeGradient: Nullable<FactorGradient>;
  11583. /** @hidden */
  11584. _currentStartSize1: number;
  11585. /** @hidden */
  11586. _currentStartSize2: number;
  11587. private readonly _rawTextureWidth;
  11588. private _rampGradientsTexture;
  11589. private _useRampGradients;
  11590. /** Gets or sets a boolean indicating that ramp gradients must be used
  11591. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11592. */
  11593. get useRampGradients(): boolean;
  11594. set useRampGradients(value: boolean);
  11595. /**
  11596. * 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.
  11597. * 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: [])
  11598. */
  11599. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11600. private _subEmitters;
  11601. /**
  11602. * @hidden
  11603. * If the particle systems emitter should be disposed when the particle system is disposed
  11604. */
  11605. _disposeEmitterOnDispose: boolean;
  11606. /**
  11607. * The current active Sub-systems, this property is used by the root particle system only.
  11608. */
  11609. activeSubSystems: Array<ParticleSystem>;
  11610. /**
  11611. * Specifies if the particles are updated in emitter local space or world space
  11612. */
  11613. isLocal: boolean;
  11614. private _rootParticleSystem;
  11615. /**
  11616. * Gets the current list of active particles
  11617. */
  11618. get particles(): Particle[];
  11619. /**
  11620. * Returns the string "ParticleSystem"
  11621. * @returns a string containing the class name
  11622. */
  11623. getClassName(): string;
  11624. /**
  11625. * Instantiates a particle system.
  11626. * 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.
  11627. * @param name The name of the particle system
  11628. * @param capacity The max number of particles alive at the same time
  11629. * @param scene The scene the particle system belongs to
  11630. * @param customEffect a custom effect used to change the way particles are rendered by default
  11631. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11632. * @param epsilon Offset used to render the particles
  11633. */
  11634. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11635. private _addFactorGradient;
  11636. private _removeFactorGradient;
  11637. /**
  11638. * Adds a new life time gradient
  11639. * @param gradient defines the gradient to use (between 0 and 1)
  11640. * @param factor defines the life time factor to affect to the specified gradient
  11641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11642. * @returns the current particle system
  11643. */
  11644. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11645. /**
  11646. * Remove a specific life time gradient
  11647. * @param gradient defines the gradient to remove
  11648. * @returns the current particle system
  11649. */
  11650. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11651. /**
  11652. * Adds a new size gradient
  11653. * @param gradient defines the gradient to use (between 0 and 1)
  11654. * @param factor defines the size factor to affect to the specified gradient
  11655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11656. * @returns the current particle system
  11657. */
  11658. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11659. /**
  11660. * Remove a specific size gradient
  11661. * @param gradient defines the gradient to remove
  11662. * @returns the current particle system
  11663. */
  11664. removeSizeGradient(gradient: number): IParticleSystem;
  11665. /**
  11666. * Adds a new color remap gradient
  11667. * @param gradient defines the gradient to use (between 0 and 1)
  11668. * @param min defines the color remap minimal range
  11669. * @param max defines the color remap maximal range
  11670. * @returns the current particle system
  11671. */
  11672. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11673. /**
  11674. * Remove a specific color remap gradient
  11675. * @param gradient defines the gradient to remove
  11676. * @returns the current particle system
  11677. */
  11678. removeColorRemapGradient(gradient: number): IParticleSystem;
  11679. /**
  11680. * Adds a new alpha remap gradient
  11681. * @param gradient defines the gradient to use (between 0 and 1)
  11682. * @param min defines the alpha remap minimal range
  11683. * @param max defines the alpha remap maximal range
  11684. * @returns the current particle system
  11685. */
  11686. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11687. /**
  11688. * Remove a specific alpha remap gradient
  11689. * @param gradient defines the gradient to remove
  11690. * @returns the current particle system
  11691. */
  11692. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11693. /**
  11694. * Adds a new angular speed gradient
  11695. * @param gradient defines the gradient to use (between 0 and 1)
  11696. * @param factor defines the angular speed to affect to the specified gradient
  11697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11698. * @returns the current particle system
  11699. */
  11700. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11701. /**
  11702. * Remove a specific angular speed gradient
  11703. * @param gradient defines the gradient to remove
  11704. * @returns the current particle system
  11705. */
  11706. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11707. /**
  11708. * Adds a new velocity gradient
  11709. * @param gradient defines the gradient to use (between 0 and 1)
  11710. * @param factor defines the velocity to affect to the specified gradient
  11711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11712. * @returns the current particle system
  11713. */
  11714. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11715. /**
  11716. * Remove a specific velocity gradient
  11717. * @param gradient defines the gradient to remove
  11718. * @returns the current particle system
  11719. */
  11720. removeVelocityGradient(gradient: number): IParticleSystem;
  11721. /**
  11722. * Adds a new limit velocity gradient
  11723. * @param gradient defines the gradient to use (between 0 and 1)
  11724. * @param factor defines the limit velocity value to affect to the specified gradient
  11725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11726. * @returns the current particle system
  11727. */
  11728. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11729. /**
  11730. * Remove a specific limit velocity gradient
  11731. * @param gradient defines the gradient to remove
  11732. * @returns the current particle system
  11733. */
  11734. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11735. /**
  11736. * Adds a new drag gradient
  11737. * @param gradient defines the gradient to use (between 0 and 1)
  11738. * @param factor defines the drag value to affect to the specified gradient
  11739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11740. * @returns the current particle system
  11741. */
  11742. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11743. /**
  11744. * Remove a specific drag gradient
  11745. * @param gradient defines the gradient to remove
  11746. * @returns the current particle system
  11747. */
  11748. removeDragGradient(gradient: number): IParticleSystem;
  11749. /**
  11750. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11751. * @param gradient defines the gradient to use (between 0 and 1)
  11752. * @param factor defines the emit rate value to affect to the specified gradient
  11753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11754. * @returns the current particle system
  11755. */
  11756. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11757. /**
  11758. * Remove a specific emit rate gradient
  11759. * @param gradient defines the gradient to remove
  11760. * @returns the current particle system
  11761. */
  11762. removeEmitRateGradient(gradient: number): IParticleSystem;
  11763. /**
  11764. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11765. * @param gradient defines the gradient to use (between 0 and 1)
  11766. * @param factor defines the start size value to affect to the specified gradient
  11767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11768. * @returns the current particle system
  11769. */
  11770. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11771. /**
  11772. * Remove a specific start size gradient
  11773. * @param gradient defines the gradient to remove
  11774. * @returns the current particle system
  11775. */
  11776. removeStartSizeGradient(gradient: number): IParticleSystem;
  11777. private _createRampGradientTexture;
  11778. /**
  11779. * Gets the current list of ramp gradients.
  11780. * You must use addRampGradient and removeRampGradient to udpate this list
  11781. * @returns the list of ramp gradients
  11782. */
  11783. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11784. /**
  11785. * Adds a new ramp gradient used to remap particle colors
  11786. * @param gradient defines the gradient to use (between 0 and 1)
  11787. * @param color defines the color to affect to the specified gradient
  11788. * @returns the current particle system
  11789. */
  11790. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11791. /**
  11792. * Remove a specific ramp gradient
  11793. * @param gradient defines the gradient to remove
  11794. * @returns the current particle system
  11795. */
  11796. removeRampGradient(gradient: number): ParticleSystem;
  11797. /**
  11798. * Adds a new color gradient
  11799. * @param gradient defines the gradient to use (between 0 and 1)
  11800. * @param color1 defines the color to affect to the specified gradient
  11801. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11802. * @returns this particle system
  11803. */
  11804. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11805. /**
  11806. * Remove a specific color gradient
  11807. * @param gradient defines the gradient to remove
  11808. * @returns this particle system
  11809. */
  11810. removeColorGradient(gradient: number): IParticleSystem;
  11811. private _fetchR;
  11812. protected _reset(): void;
  11813. private _resetEffect;
  11814. private _createVertexBuffers;
  11815. private _createIndexBuffer;
  11816. /**
  11817. * Gets the maximum number of particles active at the same time.
  11818. * @returns The max number of active particles.
  11819. */
  11820. getCapacity(): number;
  11821. /**
  11822. * Gets whether there are still active particles in the system.
  11823. * @returns True if it is alive, otherwise false.
  11824. */
  11825. isAlive(): boolean;
  11826. /**
  11827. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11828. * @returns True if it has been started, otherwise false.
  11829. */
  11830. isStarted(): boolean;
  11831. private _prepareSubEmitterInternalArray;
  11832. /**
  11833. * Starts the particle system and begins to emit
  11834. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11835. */
  11836. start(delay?: number): void;
  11837. /**
  11838. * Stops the particle system.
  11839. * @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.
  11840. */
  11841. stop(stopSubEmitters?: boolean): void;
  11842. /**
  11843. * Remove all active particles
  11844. */
  11845. reset(): void;
  11846. /**
  11847. * @hidden (for internal use only)
  11848. */
  11849. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11850. /**
  11851. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11852. * Its lifetime will start back at 0.
  11853. */
  11854. recycleParticle: (particle: Particle) => void;
  11855. private _stopSubEmitters;
  11856. private _createParticle;
  11857. private _removeFromRoot;
  11858. private _emitFromParticle;
  11859. private _update;
  11860. /** @hidden */
  11861. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11862. /** @hidden */
  11863. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11864. /** @hidden */
  11865. private _getEffect;
  11866. /**
  11867. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11868. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11869. */
  11870. animate(preWarmOnly?: boolean): void;
  11871. private _appendParticleVertices;
  11872. /**
  11873. * Rebuilds the particle system.
  11874. */
  11875. rebuild(): void;
  11876. /**
  11877. * Is this system ready to be used/rendered
  11878. * @return true if the system is ready
  11879. */
  11880. isReady(): boolean;
  11881. private _render;
  11882. /**
  11883. * Renders the particle system in its current state.
  11884. * @returns the current number of particles
  11885. */
  11886. render(): number;
  11887. /**
  11888. * Disposes the particle system and free the associated resources
  11889. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11890. */
  11891. dispose(disposeTexture?: boolean): void;
  11892. /**
  11893. * Clones the particle system.
  11894. * @param name The name of the cloned object
  11895. * @param newEmitter The new emitter to use
  11896. * @returns the cloned particle system
  11897. */
  11898. clone(name: string, newEmitter: any): ParticleSystem;
  11899. /**
  11900. * Serializes the particle system to a JSON object.
  11901. * @returns the JSON object
  11902. */
  11903. serialize(): any;
  11904. /** @hidden */
  11905. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11906. /** @hidden */
  11907. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11908. /**
  11909. * Parses a JSON object to create a particle system.
  11910. * @param parsedParticleSystem The JSON object to parse
  11911. * @param scene The scene to create the particle system in
  11912. * @param rootUrl The root url to use to load external dependencies like texture
  11913. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11914. * @returns the Parsed particle system
  11915. */
  11916. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11917. }
  11918. }
  11919. declare module BABYLON {
  11920. /**
  11921. * A particle represents one of the element emitted by a particle system.
  11922. * This is mainly define by its coordinates, direction, velocity and age.
  11923. */
  11924. export class Particle {
  11925. /**
  11926. * The particle system the particle belongs to.
  11927. */
  11928. particleSystem: ParticleSystem;
  11929. private static _Count;
  11930. /**
  11931. * Unique ID of the particle
  11932. */
  11933. id: number;
  11934. /**
  11935. * The world position of the particle in the scene.
  11936. */
  11937. position: Vector3;
  11938. /**
  11939. * The world direction of the particle in the scene.
  11940. */
  11941. direction: Vector3;
  11942. /**
  11943. * The color of the particle.
  11944. */
  11945. color: Color4;
  11946. /**
  11947. * The color change of the particle per step.
  11948. */
  11949. colorStep: Color4;
  11950. /**
  11951. * Defines how long will the life of the particle be.
  11952. */
  11953. lifeTime: number;
  11954. /**
  11955. * The current age of the particle.
  11956. */
  11957. age: number;
  11958. /**
  11959. * The current size of the particle.
  11960. */
  11961. size: number;
  11962. /**
  11963. * The current scale of the particle.
  11964. */
  11965. scale: Vector2;
  11966. /**
  11967. * The current angle of the particle.
  11968. */
  11969. angle: number;
  11970. /**
  11971. * Defines how fast is the angle changing.
  11972. */
  11973. angularSpeed: number;
  11974. /**
  11975. * Defines the cell index used by the particle to be rendered from a sprite.
  11976. */
  11977. cellIndex: number;
  11978. /**
  11979. * The information required to support color remapping
  11980. */
  11981. remapData: Vector4;
  11982. /** @hidden */
  11983. _randomCellOffset?: number;
  11984. /** @hidden */
  11985. _initialDirection: Nullable<Vector3>;
  11986. /** @hidden */
  11987. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11988. /** @hidden */
  11989. _initialStartSpriteCellID: number;
  11990. /** @hidden */
  11991. _initialEndSpriteCellID: number;
  11992. /** @hidden */
  11993. _currentColorGradient: Nullable<ColorGradient>;
  11994. /** @hidden */
  11995. _currentColor1: Color4;
  11996. /** @hidden */
  11997. _currentColor2: Color4;
  11998. /** @hidden */
  11999. _currentSizeGradient: Nullable<FactorGradient>;
  12000. /** @hidden */
  12001. _currentSize1: number;
  12002. /** @hidden */
  12003. _currentSize2: number;
  12004. /** @hidden */
  12005. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12006. /** @hidden */
  12007. _currentAngularSpeed1: number;
  12008. /** @hidden */
  12009. _currentAngularSpeed2: number;
  12010. /** @hidden */
  12011. _currentVelocityGradient: Nullable<FactorGradient>;
  12012. /** @hidden */
  12013. _currentVelocity1: number;
  12014. /** @hidden */
  12015. _currentVelocity2: number;
  12016. /** @hidden */
  12017. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12018. /** @hidden */
  12019. _currentLimitVelocity1: number;
  12020. /** @hidden */
  12021. _currentLimitVelocity2: number;
  12022. /** @hidden */
  12023. _currentDragGradient: Nullable<FactorGradient>;
  12024. /** @hidden */
  12025. _currentDrag1: number;
  12026. /** @hidden */
  12027. _currentDrag2: number;
  12028. /** @hidden */
  12029. _randomNoiseCoordinates1: Vector3;
  12030. /** @hidden */
  12031. _randomNoiseCoordinates2: Vector3;
  12032. /** @hidden */
  12033. _localPosition?: Vector3;
  12034. /**
  12035. * Creates a new instance Particle
  12036. * @param particleSystem the particle system the particle belongs to
  12037. */
  12038. constructor(
  12039. /**
  12040. * The particle system the particle belongs to.
  12041. */
  12042. particleSystem: ParticleSystem);
  12043. private updateCellInfoFromSystem;
  12044. /**
  12045. * Defines how the sprite cell index is updated for the particle
  12046. */
  12047. updateCellIndex(): void;
  12048. /** @hidden */
  12049. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12050. /** @hidden */
  12051. _inheritParticleInfoToSubEmitters(): void;
  12052. /** @hidden */
  12053. _reset(): void;
  12054. /**
  12055. * Copy the properties of particle to another one.
  12056. * @param other the particle to copy the information to.
  12057. */
  12058. copyTo(other: Particle): void;
  12059. }
  12060. }
  12061. declare module BABYLON {
  12062. /**
  12063. * Particle emitter represents a volume emitting particles.
  12064. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12065. */
  12066. export interface IParticleEmitterType {
  12067. /**
  12068. * Called by the particle System when the direction is computed for the created particle.
  12069. * @param worldMatrix is the world matrix of the particle system
  12070. * @param directionToUpdate is the direction vector to update with the result
  12071. * @param particle is the particle we are computed the direction for
  12072. * @param isLocal defines if the direction should be set in local space
  12073. */
  12074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12075. /**
  12076. * Called by the particle System when the position is computed for the created particle.
  12077. * @param worldMatrix is the world matrix of the particle system
  12078. * @param positionToUpdate is the position vector to update with the result
  12079. * @param particle is the particle we are computed the position for
  12080. * @param isLocal defines if the position should be set in local space
  12081. */
  12082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12083. /**
  12084. * Clones the current emitter and returns a copy of it
  12085. * @returns the new emitter
  12086. */
  12087. clone(): IParticleEmitterType;
  12088. /**
  12089. * Called by the GPUParticleSystem to setup the update shader
  12090. * @param effect defines the update shader
  12091. */
  12092. applyToShader(effect: Effect): void;
  12093. /**
  12094. * Returns a string to use to update the GPU particles update shader
  12095. * @returns the effect defines string
  12096. */
  12097. getEffectDefines(): string;
  12098. /**
  12099. * Returns a string representing the class name
  12100. * @returns a string containing the class name
  12101. */
  12102. getClassName(): string;
  12103. /**
  12104. * Serializes the particle system to a JSON object.
  12105. * @returns the JSON object
  12106. */
  12107. serialize(): any;
  12108. /**
  12109. * Parse properties from a JSON object
  12110. * @param serializationObject defines the JSON object
  12111. * @param scene defines the hosting scene
  12112. */
  12113. parse(serializationObject: any, scene: Scene): void;
  12114. }
  12115. }
  12116. declare module BABYLON {
  12117. /**
  12118. * Particle emitter emitting particles from the inside of a box.
  12119. * It emits the particles randomly between 2 given directions.
  12120. */
  12121. export class BoxParticleEmitter implements IParticleEmitterType {
  12122. /**
  12123. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12124. */
  12125. direction1: Vector3;
  12126. /**
  12127. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12128. */
  12129. direction2: Vector3;
  12130. /**
  12131. * 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.
  12132. */
  12133. minEmitBox: Vector3;
  12134. /**
  12135. * 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.
  12136. */
  12137. maxEmitBox: Vector3;
  12138. /**
  12139. * Creates a new instance BoxParticleEmitter
  12140. */
  12141. constructor();
  12142. /**
  12143. * Called by the particle System when the direction is computed for the created particle.
  12144. * @param worldMatrix is the world matrix of the particle system
  12145. * @param directionToUpdate is the direction vector to update with the result
  12146. * @param particle is the particle we are computed the direction for
  12147. * @param isLocal defines if the direction should be set in local space
  12148. */
  12149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12150. /**
  12151. * Called by the particle System when the position is computed for the created particle.
  12152. * @param worldMatrix is the world matrix of the particle system
  12153. * @param positionToUpdate is the position vector to update with the result
  12154. * @param particle is the particle we are computed the position for
  12155. * @param isLocal defines if the position should be set in local space
  12156. */
  12157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12158. /**
  12159. * Clones the current emitter and returns a copy of it
  12160. * @returns the new emitter
  12161. */
  12162. clone(): BoxParticleEmitter;
  12163. /**
  12164. * Called by the GPUParticleSystem to setup the update shader
  12165. * @param effect defines the update shader
  12166. */
  12167. applyToShader(effect: Effect): void;
  12168. /**
  12169. * Returns a string to use to update the GPU particles update shader
  12170. * @returns a string containng the defines string
  12171. */
  12172. getEffectDefines(): string;
  12173. /**
  12174. * Returns the string "BoxParticleEmitter"
  12175. * @returns a string containing the class name
  12176. */
  12177. getClassName(): string;
  12178. /**
  12179. * Serializes the particle system to a JSON object.
  12180. * @returns the JSON object
  12181. */
  12182. serialize(): any;
  12183. /**
  12184. * Parse properties from a JSON object
  12185. * @param serializationObject defines the JSON object
  12186. */
  12187. parse(serializationObject: any): void;
  12188. }
  12189. }
  12190. declare module BABYLON {
  12191. /**
  12192. * Particle emitter emitting particles from the inside of a cone.
  12193. * It emits the particles alongside the cone volume from the base to the particle.
  12194. * The emission direction might be randomized.
  12195. */
  12196. export class ConeParticleEmitter implements IParticleEmitterType {
  12197. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12198. directionRandomizer: number;
  12199. private _radius;
  12200. private _angle;
  12201. private _height;
  12202. /**
  12203. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12204. */
  12205. radiusRange: number;
  12206. /**
  12207. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12208. */
  12209. heightRange: number;
  12210. /**
  12211. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12212. */
  12213. emitFromSpawnPointOnly: boolean;
  12214. /**
  12215. * Gets or sets the radius of the emission cone
  12216. */
  12217. get radius(): number;
  12218. set radius(value: number);
  12219. /**
  12220. * Gets or sets the angle of the emission cone
  12221. */
  12222. get angle(): number;
  12223. set angle(value: number);
  12224. private _buildHeight;
  12225. /**
  12226. * Creates a new instance ConeParticleEmitter
  12227. * @param radius the radius of the emission cone (1 by default)
  12228. * @param angle the cone base angle (PI by default)
  12229. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12230. */
  12231. constructor(radius?: number, angle?: number,
  12232. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12233. directionRandomizer?: number);
  12234. /**
  12235. * Called by the particle System when the direction is computed for the created particle.
  12236. * @param worldMatrix is the world matrix of the particle system
  12237. * @param directionToUpdate is the direction vector to update with the result
  12238. * @param particle is the particle we are computed the direction for
  12239. * @param isLocal defines if the direction should be set in local space
  12240. */
  12241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12242. /**
  12243. * Called by the particle System when the position is computed for the created particle.
  12244. * @param worldMatrix is the world matrix of the particle system
  12245. * @param positionToUpdate is the position vector to update with the result
  12246. * @param particle is the particle we are computed the position for
  12247. * @param isLocal defines if the position should be set in local space
  12248. */
  12249. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12250. /**
  12251. * Clones the current emitter and returns a copy of it
  12252. * @returns the new emitter
  12253. */
  12254. clone(): ConeParticleEmitter;
  12255. /**
  12256. * Called by the GPUParticleSystem to setup the update shader
  12257. * @param effect defines the update shader
  12258. */
  12259. applyToShader(effect: Effect): void;
  12260. /**
  12261. * Returns a string to use to update the GPU particles update shader
  12262. * @returns a string containng the defines string
  12263. */
  12264. getEffectDefines(): string;
  12265. /**
  12266. * Returns the string "ConeParticleEmitter"
  12267. * @returns a string containing the class name
  12268. */
  12269. getClassName(): string;
  12270. /**
  12271. * Serializes the particle system to a JSON object.
  12272. * @returns the JSON object
  12273. */
  12274. serialize(): any;
  12275. /**
  12276. * Parse properties from a JSON object
  12277. * @param serializationObject defines the JSON object
  12278. */
  12279. parse(serializationObject: any): void;
  12280. }
  12281. }
  12282. declare module BABYLON {
  12283. /**
  12284. * Particle emitter emitting particles from the inside of a cylinder.
  12285. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12286. */
  12287. export class CylinderParticleEmitter implements IParticleEmitterType {
  12288. /**
  12289. * The radius of the emission cylinder.
  12290. */
  12291. radius: number;
  12292. /**
  12293. * The height of the emission cylinder.
  12294. */
  12295. height: number;
  12296. /**
  12297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12298. */
  12299. radiusRange: number;
  12300. /**
  12301. * How much to randomize the particle direction [0-1].
  12302. */
  12303. directionRandomizer: number;
  12304. /**
  12305. * Creates a new instance CylinderParticleEmitter
  12306. * @param radius the radius of the emission cylinder (1 by default)
  12307. * @param height the height of the emission cylinder (1 by default)
  12308. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12309. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12310. */
  12311. constructor(
  12312. /**
  12313. * The radius of the emission cylinder.
  12314. */
  12315. radius?: number,
  12316. /**
  12317. * The height of the emission cylinder.
  12318. */
  12319. height?: number,
  12320. /**
  12321. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12322. */
  12323. radiusRange?: number,
  12324. /**
  12325. * How much to randomize the particle direction [0-1].
  12326. */
  12327. directionRandomizer?: number);
  12328. /**
  12329. * Called by the particle System when the direction is computed for the created particle.
  12330. * @param worldMatrix is the world matrix of the particle system
  12331. * @param directionToUpdate is the direction vector to update with the result
  12332. * @param particle is the particle we are computed the direction for
  12333. * @param isLocal defines if the direction should be set in local space
  12334. */
  12335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12336. /**
  12337. * Called by the particle System when the position is computed for the created particle.
  12338. * @param worldMatrix is the world matrix of the particle system
  12339. * @param positionToUpdate is the position vector to update with the result
  12340. * @param particle is the particle we are computed the position for
  12341. * @param isLocal defines if the position should be set in local space
  12342. */
  12343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12344. /**
  12345. * Clones the current emitter and returns a copy of it
  12346. * @returns the new emitter
  12347. */
  12348. clone(): CylinderParticleEmitter;
  12349. /**
  12350. * Called by the GPUParticleSystem to setup the update shader
  12351. * @param effect defines the update shader
  12352. */
  12353. applyToShader(effect: Effect): void;
  12354. /**
  12355. * Returns a string to use to update the GPU particles update shader
  12356. * @returns a string containng the defines string
  12357. */
  12358. getEffectDefines(): string;
  12359. /**
  12360. * Returns the string "CylinderParticleEmitter"
  12361. * @returns a string containing the class name
  12362. */
  12363. getClassName(): string;
  12364. /**
  12365. * Serializes the particle system to a JSON object.
  12366. * @returns the JSON object
  12367. */
  12368. serialize(): any;
  12369. /**
  12370. * Parse properties from a JSON object
  12371. * @param serializationObject defines the JSON object
  12372. */
  12373. parse(serializationObject: any): void;
  12374. }
  12375. /**
  12376. * Particle emitter emitting particles from the inside of a cylinder.
  12377. * It emits the particles randomly between two vectors.
  12378. */
  12379. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12380. /**
  12381. * The min limit of the emission direction.
  12382. */
  12383. direction1: Vector3;
  12384. /**
  12385. * The max limit of the emission direction.
  12386. */
  12387. direction2: Vector3;
  12388. /**
  12389. * Creates a new instance CylinderDirectedParticleEmitter
  12390. * @param radius the radius of the emission cylinder (1 by default)
  12391. * @param height the height of the emission cylinder (1 by default)
  12392. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12393. * @param direction1 the min limit of the emission direction (up vector by default)
  12394. * @param direction2 the max limit of the emission direction (up vector by default)
  12395. */
  12396. constructor(radius?: number, height?: number, radiusRange?: number,
  12397. /**
  12398. * The min limit of the emission direction.
  12399. */
  12400. direction1?: Vector3,
  12401. /**
  12402. * The max limit of the emission direction.
  12403. */
  12404. direction2?: Vector3);
  12405. /**
  12406. * Called by the particle System when the direction is computed for the created particle.
  12407. * @param worldMatrix is the world matrix of the particle system
  12408. * @param directionToUpdate is the direction vector to update with the result
  12409. * @param particle is the particle we are computed the direction for
  12410. */
  12411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12412. /**
  12413. * Clones the current emitter and returns a copy of it
  12414. * @returns the new emitter
  12415. */
  12416. clone(): CylinderDirectedParticleEmitter;
  12417. /**
  12418. * Called by the GPUParticleSystem to setup the update shader
  12419. * @param effect defines the update shader
  12420. */
  12421. applyToShader(effect: Effect): void;
  12422. /**
  12423. * Returns a string to use to update the GPU particles update shader
  12424. * @returns a string containng the defines string
  12425. */
  12426. getEffectDefines(): string;
  12427. /**
  12428. * Returns the string "CylinderDirectedParticleEmitter"
  12429. * @returns a string containing the class name
  12430. */
  12431. getClassName(): string;
  12432. /**
  12433. * Serializes the particle system to a JSON object.
  12434. * @returns the JSON object
  12435. */
  12436. serialize(): any;
  12437. /**
  12438. * Parse properties from a JSON object
  12439. * @param serializationObject defines the JSON object
  12440. */
  12441. parse(serializationObject: any): void;
  12442. }
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Particle emitter emitting particles from the inside of a hemisphere.
  12447. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12448. */
  12449. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12450. /**
  12451. * The radius of the emission hemisphere.
  12452. */
  12453. radius: number;
  12454. /**
  12455. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12456. */
  12457. radiusRange: number;
  12458. /**
  12459. * How much to randomize the particle direction [0-1].
  12460. */
  12461. directionRandomizer: number;
  12462. /**
  12463. * Creates a new instance HemisphericParticleEmitter
  12464. * @param radius the radius of the emission hemisphere (1 by default)
  12465. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12466. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12467. */
  12468. constructor(
  12469. /**
  12470. * The radius of the emission hemisphere.
  12471. */
  12472. radius?: number,
  12473. /**
  12474. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12475. */
  12476. radiusRange?: number,
  12477. /**
  12478. * How much to randomize the particle direction [0-1].
  12479. */
  12480. directionRandomizer?: number);
  12481. /**
  12482. * Called by the particle System when the direction is computed for the created particle.
  12483. * @param worldMatrix is the world matrix of the particle system
  12484. * @param directionToUpdate is the direction vector to update with the result
  12485. * @param particle is the particle we are computed the direction for
  12486. * @param isLocal defines if the direction should be set in local space
  12487. */
  12488. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12489. /**
  12490. * Called by the particle System when the position is computed for the created particle.
  12491. * @param worldMatrix is the world matrix of the particle system
  12492. * @param positionToUpdate is the position vector to update with the result
  12493. * @param particle is the particle we are computed the position for
  12494. * @param isLocal defines if the position should be set in local space
  12495. */
  12496. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12497. /**
  12498. * Clones the current emitter and returns a copy of it
  12499. * @returns the new emitter
  12500. */
  12501. clone(): HemisphericParticleEmitter;
  12502. /**
  12503. * Called by the GPUParticleSystem to setup the update shader
  12504. * @param effect defines the update shader
  12505. */
  12506. applyToShader(effect: Effect): void;
  12507. /**
  12508. * Returns a string to use to update the GPU particles update shader
  12509. * @returns a string containng the defines string
  12510. */
  12511. getEffectDefines(): string;
  12512. /**
  12513. * Returns the string "HemisphericParticleEmitter"
  12514. * @returns a string containing the class name
  12515. */
  12516. getClassName(): string;
  12517. /**
  12518. * Serializes the particle system to a JSON object.
  12519. * @returns the JSON object
  12520. */
  12521. serialize(): any;
  12522. /**
  12523. * Parse properties from a JSON object
  12524. * @param serializationObject defines the JSON object
  12525. */
  12526. parse(serializationObject: any): void;
  12527. }
  12528. }
  12529. declare module BABYLON {
  12530. /**
  12531. * Particle emitter emitting particles from a point.
  12532. * It emits the particles randomly between 2 given directions.
  12533. */
  12534. export class PointParticleEmitter implements IParticleEmitterType {
  12535. /**
  12536. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12537. */
  12538. direction1: Vector3;
  12539. /**
  12540. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12541. */
  12542. direction2: Vector3;
  12543. /**
  12544. * Creates a new instance PointParticleEmitter
  12545. */
  12546. constructor();
  12547. /**
  12548. * Called by the particle System when the direction is computed for the created particle.
  12549. * @param worldMatrix is the world matrix of the particle system
  12550. * @param directionToUpdate is the direction vector to update with the result
  12551. * @param particle is the particle we are computed the direction for
  12552. * @param isLocal defines if the direction should be set in local space
  12553. */
  12554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12555. /**
  12556. * Called by the particle System when the position is computed for the created particle.
  12557. * @param worldMatrix is the world matrix of the particle system
  12558. * @param positionToUpdate is the position vector to update with the result
  12559. * @param particle is the particle we are computed the position for
  12560. * @param isLocal defines if the position should be set in local space
  12561. */
  12562. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12563. /**
  12564. * Clones the current emitter and returns a copy of it
  12565. * @returns the new emitter
  12566. */
  12567. clone(): PointParticleEmitter;
  12568. /**
  12569. * Called by the GPUParticleSystem to setup the update shader
  12570. * @param effect defines the update shader
  12571. */
  12572. applyToShader(effect: Effect): void;
  12573. /**
  12574. * Returns a string to use to update the GPU particles update shader
  12575. * @returns a string containng the defines string
  12576. */
  12577. getEffectDefines(): string;
  12578. /**
  12579. * Returns the string "PointParticleEmitter"
  12580. * @returns a string containing the class name
  12581. */
  12582. getClassName(): string;
  12583. /**
  12584. * Serializes the particle system to a JSON object.
  12585. * @returns the JSON object
  12586. */
  12587. serialize(): any;
  12588. /**
  12589. * Parse properties from a JSON object
  12590. * @param serializationObject defines the JSON object
  12591. */
  12592. parse(serializationObject: any): void;
  12593. }
  12594. }
  12595. declare module BABYLON {
  12596. /**
  12597. * Particle emitter emitting particles from the inside of a sphere.
  12598. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12599. */
  12600. export class SphereParticleEmitter implements IParticleEmitterType {
  12601. /**
  12602. * The radius of the emission sphere.
  12603. */
  12604. radius: number;
  12605. /**
  12606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12607. */
  12608. radiusRange: number;
  12609. /**
  12610. * How much to randomize the particle direction [0-1].
  12611. */
  12612. directionRandomizer: number;
  12613. /**
  12614. * Creates a new instance SphereParticleEmitter
  12615. * @param radius the radius of the emission sphere (1 by default)
  12616. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12617. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12618. */
  12619. constructor(
  12620. /**
  12621. * The radius of the emission sphere.
  12622. */
  12623. radius?: number,
  12624. /**
  12625. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12626. */
  12627. radiusRange?: number,
  12628. /**
  12629. * How much to randomize the particle direction [0-1].
  12630. */
  12631. directionRandomizer?: number);
  12632. /**
  12633. * Called by the particle System when the direction is computed for the created particle.
  12634. * @param worldMatrix is the world matrix of the particle system
  12635. * @param directionToUpdate is the direction vector to update with the result
  12636. * @param particle is the particle we are computed the direction for
  12637. * @param isLocal defines if the direction should be set in local space
  12638. */
  12639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12640. /**
  12641. * Called by the particle System when the position is computed for the created particle.
  12642. * @param worldMatrix is the world matrix of the particle system
  12643. * @param positionToUpdate is the position vector to update with the result
  12644. * @param particle is the particle we are computed the position for
  12645. * @param isLocal defines if the position should be set in local space
  12646. */
  12647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12648. /**
  12649. * Clones the current emitter and returns a copy of it
  12650. * @returns the new emitter
  12651. */
  12652. clone(): SphereParticleEmitter;
  12653. /**
  12654. * Called by the GPUParticleSystem to setup the update shader
  12655. * @param effect defines the update shader
  12656. */
  12657. applyToShader(effect: Effect): void;
  12658. /**
  12659. * Returns a string to use to update the GPU particles update shader
  12660. * @returns a string containng the defines string
  12661. */
  12662. getEffectDefines(): string;
  12663. /**
  12664. * Returns the string "SphereParticleEmitter"
  12665. * @returns a string containing the class name
  12666. */
  12667. getClassName(): string;
  12668. /**
  12669. * Serializes the particle system to a JSON object.
  12670. * @returns the JSON object
  12671. */
  12672. serialize(): any;
  12673. /**
  12674. * Parse properties from a JSON object
  12675. * @param serializationObject defines the JSON object
  12676. */
  12677. parse(serializationObject: any): void;
  12678. }
  12679. /**
  12680. * Particle emitter emitting particles from the inside of a sphere.
  12681. * It emits the particles randomly between two vectors.
  12682. */
  12683. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12684. /**
  12685. * The min limit of the emission direction.
  12686. */
  12687. direction1: Vector3;
  12688. /**
  12689. * The max limit of the emission direction.
  12690. */
  12691. direction2: Vector3;
  12692. /**
  12693. * Creates a new instance SphereDirectedParticleEmitter
  12694. * @param radius the radius of the emission sphere (1 by default)
  12695. * @param direction1 the min limit of the emission direction (up vector by default)
  12696. * @param direction2 the max limit of the emission direction (up vector by default)
  12697. */
  12698. constructor(radius?: number,
  12699. /**
  12700. * The min limit of the emission direction.
  12701. */
  12702. direction1?: Vector3,
  12703. /**
  12704. * The max limit of the emission direction.
  12705. */
  12706. direction2?: Vector3);
  12707. /**
  12708. * Called by the particle System when the direction is computed for the created particle.
  12709. * @param worldMatrix is the world matrix of the particle system
  12710. * @param directionToUpdate is the direction vector to update with the result
  12711. * @param particle is the particle we are computed the direction for
  12712. */
  12713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12714. /**
  12715. * Clones the current emitter and returns a copy of it
  12716. * @returns the new emitter
  12717. */
  12718. clone(): SphereDirectedParticleEmitter;
  12719. /**
  12720. * Called by the GPUParticleSystem to setup the update shader
  12721. * @param effect defines the update shader
  12722. */
  12723. applyToShader(effect: Effect): void;
  12724. /**
  12725. * Returns a string to use to update the GPU particles update shader
  12726. * @returns a string containng the defines string
  12727. */
  12728. getEffectDefines(): string;
  12729. /**
  12730. * Returns the string "SphereDirectedParticleEmitter"
  12731. * @returns a string containing the class name
  12732. */
  12733. getClassName(): string;
  12734. /**
  12735. * Serializes the particle system to a JSON object.
  12736. * @returns the JSON object
  12737. */
  12738. serialize(): any;
  12739. /**
  12740. * Parse properties from a JSON object
  12741. * @param serializationObject defines the JSON object
  12742. */
  12743. parse(serializationObject: any): void;
  12744. }
  12745. }
  12746. declare module BABYLON {
  12747. /**
  12748. * Particle emitter emitting particles from a custom list of positions.
  12749. */
  12750. export class CustomParticleEmitter implements IParticleEmitterType {
  12751. /**
  12752. * Gets or sets the position generator that will create the inital position of each particle.
  12753. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12754. */
  12755. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12756. /**
  12757. * Gets or sets the destination generator that will create the final destination of each particle.
  12758. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12759. */
  12760. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12761. /**
  12762. * Creates a new instance CustomParticleEmitter
  12763. */
  12764. constructor();
  12765. /**
  12766. * Called by the particle System when the direction is computed for the created particle.
  12767. * @param worldMatrix is the world matrix of the particle system
  12768. * @param directionToUpdate is the direction vector to update with the result
  12769. * @param particle is the particle we are computed the direction for
  12770. * @param isLocal defines if the direction should be set in local space
  12771. */
  12772. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12773. /**
  12774. * Called by the particle System when the position is computed for the created particle.
  12775. * @param worldMatrix is the world matrix of the particle system
  12776. * @param positionToUpdate is the position vector to update with the result
  12777. * @param particle is the particle we are computed the position for
  12778. * @param isLocal defines if the position should be set in local space
  12779. */
  12780. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12781. /**
  12782. * Clones the current emitter and returns a copy of it
  12783. * @returns the new emitter
  12784. */
  12785. clone(): CustomParticleEmitter;
  12786. /**
  12787. * Called by the GPUParticleSystem to setup the update shader
  12788. * @param effect defines the update shader
  12789. */
  12790. applyToShader(effect: Effect): void;
  12791. /**
  12792. * Returns a string to use to update the GPU particles update shader
  12793. * @returns a string containng the defines string
  12794. */
  12795. getEffectDefines(): string;
  12796. /**
  12797. * Returns the string "PointParticleEmitter"
  12798. * @returns a string containing the class name
  12799. */
  12800. getClassName(): string;
  12801. /**
  12802. * Serializes the particle system to a JSON object.
  12803. * @returns the JSON object
  12804. */
  12805. serialize(): any;
  12806. /**
  12807. * Parse properties from a JSON object
  12808. * @param serializationObject defines the JSON object
  12809. */
  12810. parse(serializationObject: any): void;
  12811. }
  12812. }
  12813. declare module BABYLON {
  12814. /**
  12815. * Particle emitter emitting particles from the inside of a box.
  12816. * It emits the particles randomly between 2 given directions.
  12817. */
  12818. export class MeshParticleEmitter implements IParticleEmitterType {
  12819. /** Defines the mesh to use as source */
  12820. mesh?: AbstractMesh | undefined;
  12821. private _indices;
  12822. private _positions;
  12823. private _normals;
  12824. private _storedNormal;
  12825. /**
  12826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12827. */
  12828. direction1: Vector3;
  12829. /**
  12830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12831. */
  12832. direction2: Vector3;
  12833. /**
  12834. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12835. */
  12836. useMeshNormalsForDirection: boolean;
  12837. /**
  12838. * Creates a new instance MeshParticleEmitter
  12839. * @param mesh defines the mesh to use as source
  12840. */
  12841. constructor(
  12842. /** Defines the mesh to use as source */
  12843. mesh?: AbstractMesh | undefined);
  12844. /**
  12845. * Called by the particle System when the direction is computed for the created particle.
  12846. * @param worldMatrix is the world matrix of the particle system
  12847. * @param directionToUpdate is the direction vector to update with the result
  12848. * @param particle is the particle we are computed the direction for
  12849. * @param isLocal defines if the direction should be set in local space
  12850. */
  12851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12852. /**
  12853. * Called by the particle System when the position is computed for the created particle.
  12854. * @param worldMatrix is the world matrix of the particle system
  12855. * @param positionToUpdate is the position vector to update with the result
  12856. * @param particle is the particle we are computed the position for
  12857. * @param isLocal defines if the position should be set in local space
  12858. */
  12859. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12860. /**
  12861. * Clones the current emitter and returns a copy of it
  12862. * @returns the new emitter
  12863. */
  12864. clone(): MeshParticleEmitter;
  12865. /**
  12866. * Called by the GPUParticleSystem to setup the update shader
  12867. * @param effect defines the update shader
  12868. */
  12869. applyToShader(effect: Effect): void;
  12870. /**
  12871. * Returns a string to use to update the GPU particles update shader
  12872. * @returns a string containng the defines string
  12873. */
  12874. getEffectDefines(): string;
  12875. /**
  12876. * Returns the string "BoxParticleEmitter"
  12877. * @returns a string containing the class name
  12878. */
  12879. getClassName(): string;
  12880. /**
  12881. * Serializes the particle system to a JSON object.
  12882. * @returns the JSON object
  12883. */
  12884. serialize(): any;
  12885. /**
  12886. * Parse properties from a JSON object
  12887. * @param serializationObject defines the JSON object
  12888. * @param scene defines the hosting scene
  12889. */
  12890. parse(serializationObject: any, scene: Scene): void;
  12891. }
  12892. }
  12893. declare module BABYLON {
  12894. /**
  12895. * Interface representing a particle system in Babylon.js.
  12896. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12897. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12898. */
  12899. export interface IParticleSystem {
  12900. /**
  12901. * List of animations used by the particle system.
  12902. */
  12903. animations: Animation[];
  12904. /**
  12905. * The id of the Particle system.
  12906. */
  12907. id: string;
  12908. /**
  12909. * The name of the Particle system.
  12910. */
  12911. name: string;
  12912. /**
  12913. * The emitter represents the Mesh or position we are attaching the particle system to.
  12914. */
  12915. emitter: Nullable<AbstractMesh | Vector3>;
  12916. /**
  12917. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12918. */
  12919. isBillboardBased: boolean;
  12920. /**
  12921. * The rendering group used by the Particle system to chose when to render.
  12922. */
  12923. renderingGroupId: number;
  12924. /**
  12925. * The layer mask we are rendering the particles through.
  12926. */
  12927. layerMask: number;
  12928. /**
  12929. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12930. */
  12931. updateSpeed: number;
  12932. /**
  12933. * The amount of time the particle system is running (depends of the overall update speed).
  12934. */
  12935. targetStopDuration: number;
  12936. /**
  12937. * The texture used to render each particle. (this can be a spritesheet)
  12938. */
  12939. particleTexture: Nullable<Texture>;
  12940. /**
  12941. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12942. */
  12943. blendMode: number;
  12944. /**
  12945. * Minimum life time of emitting particles.
  12946. */
  12947. minLifeTime: number;
  12948. /**
  12949. * Maximum life time of emitting particles.
  12950. */
  12951. maxLifeTime: number;
  12952. /**
  12953. * Minimum Size of emitting particles.
  12954. */
  12955. minSize: number;
  12956. /**
  12957. * Maximum Size of emitting particles.
  12958. */
  12959. maxSize: number;
  12960. /**
  12961. * Minimum scale of emitting particles on X axis.
  12962. */
  12963. minScaleX: number;
  12964. /**
  12965. * Maximum scale of emitting particles on X axis.
  12966. */
  12967. maxScaleX: number;
  12968. /**
  12969. * Minimum scale of emitting particles on Y axis.
  12970. */
  12971. minScaleY: number;
  12972. /**
  12973. * Maximum scale of emitting particles on Y axis.
  12974. */
  12975. maxScaleY: number;
  12976. /**
  12977. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12978. */
  12979. color1: Color4;
  12980. /**
  12981. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12982. */
  12983. color2: Color4;
  12984. /**
  12985. * Color the particle will have at the end of its lifetime.
  12986. */
  12987. colorDead: Color4;
  12988. /**
  12989. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12990. */
  12991. emitRate: number;
  12992. /**
  12993. * You can use gravity if you want to give an orientation to your particles.
  12994. */
  12995. gravity: Vector3;
  12996. /**
  12997. * Minimum power of emitting particles.
  12998. */
  12999. minEmitPower: number;
  13000. /**
  13001. * Maximum power of emitting particles.
  13002. */
  13003. maxEmitPower: number;
  13004. /**
  13005. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13006. */
  13007. minAngularSpeed: number;
  13008. /**
  13009. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13010. */
  13011. maxAngularSpeed: number;
  13012. /**
  13013. * Gets or sets the minimal initial rotation in radians.
  13014. */
  13015. minInitialRotation: number;
  13016. /**
  13017. * Gets or sets the maximal initial rotation in radians.
  13018. */
  13019. maxInitialRotation: number;
  13020. /**
  13021. * The particle emitter type defines the emitter used by the particle system.
  13022. * It can be for example box, sphere, or cone...
  13023. */
  13024. particleEmitterType: Nullable<IParticleEmitterType>;
  13025. /**
  13026. * Defines the delay in milliseconds before starting the system (0 by default)
  13027. */
  13028. startDelay: number;
  13029. /**
  13030. * 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
  13031. */
  13032. preWarmCycles: number;
  13033. /**
  13034. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13035. */
  13036. preWarmStepOffset: number;
  13037. /**
  13038. * 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)
  13039. */
  13040. spriteCellChangeSpeed: number;
  13041. /**
  13042. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13043. */
  13044. startSpriteCellID: number;
  13045. /**
  13046. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13047. */
  13048. endSpriteCellID: number;
  13049. /**
  13050. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13051. */
  13052. spriteCellWidth: number;
  13053. /**
  13054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13055. */
  13056. spriteCellHeight: number;
  13057. /**
  13058. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13059. */
  13060. spriteRandomStartCell: boolean;
  13061. /**
  13062. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13063. */
  13064. isAnimationSheetEnabled: boolean;
  13065. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13066. translationPivot: Vector2;
  13067. /**
  13068. * Gets or sets a texture used to add random noise to particle positions
  13069. */
  13070. noiseTexture: Nullable<BaseTexture>;
  13071. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13072. noiseStrength: Vector3;
  13073. /**
  13074. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13075. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13076. */
  13077. billboardMode: number;
  13078. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13079. limitVelocityDamping: number;
  13080. /**
  13081. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13082. */
  13083. beginAnimationOnStart: boolean;
  13084. /**
  13085. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13086. */
  13087. beginAnimationFrom: number;
  13088. /**
  13089. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13090. */
  13091. beginAnimationTo: number;
  13092. /**
  13093. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13094. */
  13095. beginAnimationLoop: boolean;
  13096. /**
  13097. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13098. */
  13099. disposeOnStop: boolean;
  13100. /**
  13101. * Specifies if the particles are updated in emitter local space or world space
  13102. */
  13103. isLocal: boolean;
  13104. /**
  13105. * Gets the maximum number of particles active at the same time.
  13106. * @returns The max number of active particles.
  13107. */
  13108. getCapacity(): number;
  13109. /**
  13110. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13111. * @returns True if it has been started, otherwise false.
  13112. */
  13113. isStarted(): boolean;
  13114. /**
  13115. * Animates the particle system for this frame.
  13116. */
  13117. animate(): void;
  13118. /**
  13119. * Renders the particle system in its current state.
  13120. * @returns the current number of particles
  13121. */
  13122. render(): number;
  13123. /**
  13124. * Dispose the particle system and frees its associated resources.
  13125. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13126. */
  13127. dispose(disposeTexture?: boolean): void;
  13128. /**
  13129. * Clones the particle system.
  13130. * @param name The name of the cloned object
  13131. * @param newEmitter The new emitter to use
  13132. * @returns the cloned particle system
  13133. */
  13134. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13135. /**
  13136. * Serializes the particle system to a JSON object.
  13137. * @returns the JSON object
  13138. */
  13139. serialize(): any;
  13140. /**
  13141. * Rebuild the particle system
  13142. */
  13143. rebuild(): void;
  13144. /**
  13145. * Starts the particle system and begins to emit
  13146. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13147. */
  13148. start(delay?: number): void;
  13149. /**
  13150. * Stops the particle system.
  13151. */
  13152. stop(): void;
  13153. /**
  13154. * Remove all active particles
  13155. */
  13156. reset(): void;
  13157. /**
  13158. * Is this system ready to be used/rendered
  13159. * @return true if the system is ready
  13160. */
  13161. isReady(): boolean;
  13162. /**
  13163. * Returns the string "ParticleSystem"
  13164. * @returns a string containing the class name
  13165. */
  13166. getClassName(): string;
  13167. /**
  13168. * Adds a new color gradient
  13169. * @param gradient defines the gradient to use (between 0 and 1)
  13170. * @param color1 defines the color to affect to the specified gradient
  13171. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13172. * @returns the current particle system
  13173. */
  13174. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13175. /**
  13176. * Remove a specific color gradient
  13177. * @param gradient defines the gradient to remove
  13178. * @returns the current particle system
  13179. */
  13180. removeColorGradient(gradient: number): IParticleSystem;
  13181. /**
  13182. * Adds a new size gradient
  13183. * @param gradient defines the gradient to use (between 0 and 1)
  13184. * @param factor defines the size factor to affect to the specified gradient
  13185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13186. * @returns the current particle system
  13187. */
  13188. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13189. /**
  13190. * Remove a specific size gradient
  13191. * @param gradient defines the gradient to remove
  13192. * @returns the current particle system
  13193. */
  13194. removeSizeGradient(gradient: number): IParticleSystem;
  13195. /**
  13196. * Gets the current list of color gradients.
  13197. * You must use addColorGradient and removeColorGradient to udpate this list
  13198. * @returns the list of color gradients
  13199. */
  13200. getColorGradients(): Nullable<Array<ColorGradient>>;
  13201. /**
  13202. * Gets the current list of size gradients.
  13203. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13204. * @returns the list of size gradients
  13205. */
  13206. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13207. /**
  13208. * Gets the current list of angular speed gradients.
  13209. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13210. * @returns the list of angular speed gradients
  13211. */
  13212. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13213. /**
  13214. * Adds a new angular speed gradient
  13215. * @param gradient defines the gradient to use (between 0 and 1)
  13216. * @param factor defines the angular speed to affect to the specified gradient
  13217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13218. * @returns the current particle system
  13219. */
  13220. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13221. /**
  13222. * Remove a specific angular speed gradient
  13223. * @param gradient defines the gradient to remove
  13224. * @returns the current particle system
  13225. */
  13226. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13227. /**
  13228. * Gets the current list of velocity gradients.
  13229. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13230. * @returns the list of velocity gradients
  13231. */
  13232. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13233. /**
  13234. * Adds a new velocity gradient
  13235. * @param gradient defines the gradient to use (between 0 and 1)
  13236. * @param factor defines the velocity to affect to the specified gradient
  13237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13238. * @returns the current particle system
  13239. */
  13240. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13241. /**
  13242. * Remove a specific velocity gradient
  13243. * @param gradient defines the gradient to remove
  13244. * @returns the current particle system
  13245. */
  13246. removeVelocityGradient(gradient: number): IParticleSystem;
  13247. /**
  13248. * Gets the current list of limit velocity gradients.
  13249. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13250. * @returns the list of limit velocity gradients
  13251. */
  13252. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13253. /**
  13254. * Adds a new limit velocity gradient
  13255. * @param gradient defines the gradient to use (between 0 and 1)
  13256. * @param factor defines the limit velocity to affect to the specified gradient
  13257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13258. * @returns the current particle system
  13259. */
  13260. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13261. /**
  13262. * Remove a specific limit velocity gradient
  13263. * @param gradient defines the gradient to remove
  13264. * @returns the current particle system
  13265. */
  13266. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13267. /**
  13268. * Adds a new drag gradient
  13269. * @param gradient defines the gradient to use (between 0 and 1)
  13270. * @param factor defines the drag to affect to the specified gradient
  13271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13272. * @returns the current particle system
  13273. */
  13274. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13275. /**
  13276. * Remove a specific drag gradient
  13277. * @param gradient defines the gradient to remove
  13278. * @returns the current particle system
  13279. */
  13280. removeDragGradient(gradient: number): IParticleSystem;
  13281. /**
  13282. * Gets the current list of drag gradients.
  13283. * You must use addDragGradient and removeDragGradient to udpate this list
  13284. * @returns the list of drag gradients
  13285. */
  13286. getDragGradients(): Nullable<Array<FactorGradient>>;
  13287. /**
  13288. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13289. * @param gradient defines the gradient to use (between 0 and 1)
  13290. * @param factor defines the emit rate to affect to the specified gradient
  13291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13292. * @returns the current particle system
  13293. */
  13294. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13295. /**
  13296. * Remove a specific emit rate gradient
  13297. * @param gradient defines the gradient to remove
  13298. * @returns the current particle system
  13299. */
  13300. removeEmitRateGradient(gradient: number): IParticleSystem;
  13301. /**
  13302. * Gets the current list of emit rate gradients.
  13303. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13304. * @returns the list of emit rate gradients
  13305. */
  13306. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13307. /**
  13308. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13309. * @param gradient defines the gradient to use (between 0 and 1)
  13310. * @param factor defines the start size to affect to the specified gradient
  13311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13312. * @returns the current particle system
  13313. */
  13314. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13315. /**
  13316. * Remove a specific start size gradient
  13317. * @param gradient defines the gradient to remove
  13318. * @returns the current particle system
  13319. */
  13320. removeStartSizeGradient(gradient: number): IParticleSystem;
  13321. /**
  13322. * Gets the current list of start size gradients.
  13323. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13324. * @returns the list of start size gradients
  13325. */
  13326. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13327. /**
  13328. * Adds a new life time gradient
  13329. * @param gradient defines the gradient to use (between 0 and 1)
  13330. * @param factor defines the life time factor to affect to the specified gradient
  13331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13332. * @returns the current particle system
  13333. */
  13334. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13335. /**
  13336. * Remove a specific life time gradient
  13337. * @param gradient defines the gradient to remove
  13338. * @returns the current particle system
  13339. */
  13340. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13341. /**
  13342. * Gets the current list of life time gradients.
  13343. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13344. * @returns the list of life time gradients
  13345. */
  13346. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13347. /**
  13348. * Gets the current list of color gradients.
  13349. * You must use addColorGradient and removeColorGradient to udpate this list
  13350. * @returns the list of color gradients
  13351. */
  13352. getColorGradients(): Nullable<Array<ColorGradient>>;
  13353. /**
  13354. * Adds a new ramp gradient used to remap particle colors
  13355. * @param gradient defines the gradient to use (between 0 and 1)
  13356. * @param color defines the color to affect to the specified gradient
  13357. * @returns the current particle system
  13358. */
  13359. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13360. /**
  13361. * Gets the current list of ramp gradients.
  13362. * You must use addRampGradient and removeRampGradient to udpate this list
  13363. * @returns the list of ramp gradients
  13364. */
  13365. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13366. /** Gets or sets a boolean indicating that ramp gradients must be used
  13367. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13368. */
  13369. useRampGradients: boolean;
  13370. /**
  13371. * Adds a new color remap gradient
  13372. * @param gradient defines the gradient to use (between 0 and 1)
  13373. * @param min defines the color remap minimal range
  13374. * @param max defines the color remap maximal range
  13375. * @returns the current particle system
  13376. */
  13377. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13378. /**
  13379. * Gets the current list of color remap gradients.
  13380. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13381. * @returns the list of color remap gradients
  13382. */
  13383. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13384. /**
  13385. * Adds a new alpha remap gradient
  13386. * @param gradient defines the gradient to use (between 0 and 1)
  13387. * @param min defines the alpha remap minimal range
  13388. * @param max defines the alpha remap maximal range
  13389. * @returns the current particle system
  13390. */
  13391. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13392. /**
  13393. * Gets the current list of alpha remap gradients.
  13394. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13395. * @returns the list of alpha remap gradients
  13396. */
  13397. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13398. /**
  13399. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13400. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13401. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13402. * @returns the emitter
  13403. */
  13404. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13405. /**
  13406. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13407. * @param radius The radius of the hemisphere to emit from
  13408. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13409. * @returns the emitter
  13410. */
  13411. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13412. /**
  13413. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13414. * @param radius The radius of the sphere to emit from
  13415. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13416. * @returns the emitter
  13417. */
  13418. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13419. /**
  13420. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13421. * @param radius The radius of the sphere to emit from
  13422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13424. * @returns the emitter
  13425. */
  13426. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13427. /**
  13428. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13429. * @param radius The radius of the emission cylinder
  13430. * @param height The height of the emission cylinder
  13431. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13432. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13433. * @returns the emitter
  13434. */
  13435. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13436. /**
  13437. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13438. * @param radius The radius of the cylinder to emit from
  13439. * @param height The height of the emission cylinder
  13440. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13443. * @returns the emitter
  13444. */
  13445. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13446. /**
  13447. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13448. * @param radius The radius of the cone to emit from
  13449. * @param angle The base angle of the cone
  13450. * @returns the emitter
  13451. */
  13452. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13453. /**
  13454. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13455. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13456. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13457. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13458. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13459. * @returns the emitter
  13460. */
  13461. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13462. /**
  13463. * Get hosting scene
  13464. * @returns the scene
  13465. */
  13466. getScene(): Scene;
  13467. }
  13468. }
  13469. declare module BABYLON {
  13470. /**
  13471. * 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.
  13472. * @see https://doc.babylonjs.com/how_to/transformnode
  13473. */
  13474. export class TransformNode extends Node {
  13475. /**
  13476. * Object will not rotate to face the camera
  13477. */
  13478. static BILLBOARDMODE_NONE: number;
  13479. /**
  13480. * Object will rotate to face the camera but only on the x axis
  13481. */
  13482. static BILLBOARDMODE_X: number;
  13483. /**
  13484. * Object will rotate to face the camera but only on the y axis
  13485. */
  13486. static BILLBOARDMODE_Y: number;
  13487. /**
  13488. * Object will rotate to face the camera but only on the z axis
  13489. */
  13490. static BILLBOARDMODE_Z: number;
  13491. /**
  13492. * Object will rotate to face the camera
  13493. */
  13494. static BILLBOARDMODE_ALL: number;
  13495. /**
  13496. * Object will rotate to face the camera's position instead of orientation
  13497. */
  13498. static BILLBOARDMODE_USE_POSITION: number;
  13499. private _forward;
  13500. private _forwardInverted;
  13501. private _up;
  13502. private _right;
  13503. private _rightInverted;
  13504. private _position;
  13505. private _rotation;
  13506. private _rotationQuaternion;
  13507. protected _scaling: Vector3;
  13508. protected _isDirty: boolean;
  13509. private _transformToBoneReferal;
  13510. private _isAbsoluteSynced;
  13511. private _billboardMode;
  13512. /**
  13513. * Gets or sets the billboard mode. Default is 0.
  13514. *
  13515. * | Value | Type | Description |
  13516. * | --- | --- | --- |
  13517. * | 0 | BILLBOARDMODE_NONE | |
  13518. * | 1 | BILLBOARDMODE_X | |
  13519. * | 2 | BILLBOARDMODE_Y | |
  13520. * | 4 | BILLBOARDMODE_Z | |
  13521. * | 7 | BILLBOARDMODE_ALL | |
  13522. *
  13523. */
  13524. get billboardMode(): number;
  13525. set billboardMode(value: number);
  13526. private _preserveParentRotationForBillboard;
  13527. /**
  13528. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13529. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13530. */
  13531. get preserveParentRotationForBillboard(): boolean;
  13532. set preserveParentRotationForBillboard(value: boolean);
  13533. /**
  13534. * 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
  13535. */
  13536. scalingDeterminant: number;
  13537. private _infiniteDistance;
  13538. /**
  13539. * Gets or sets the distance of the object to max, often used by skybox
  13540. */
  13541. get infiniteDistance(): boolean;
  13542. set infiniteDistance(value: boolean);
  13543. /**
  13544. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13545. * By default the system will update normals to compensate
  13546. */
  13547. ignoreNonUniformScaling: boolean;
  13548. /**
  13549. * 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
  13550. */
  13551. reIntegrateRotationIntoRotationQuaternion: boolean;
  13552. /** @hidden */
  13553. _poseMatrix: Nullable<Matrix>;
  13554. /** @hidden */
  13555. _localMatrix: Matrix;
  13556. private _usePivotMatrix;
  13557. private _absolutePosition;
  13558. private _absoluteScaling;
  13559. private _absoluteRotationQuaternion;
  13560. private _pivotMatrix;
  13561. private _pivotMatrixInverse;
  13562. protected _postMultiplyPivotMatrix: boolean;
  13563. protected _isWorldMatrixFrozen: boolean;
  13564. /** @hidden */
  13565. _indexInSceneTransformNodesArray: number;
  13566. /**
  13567. * An event triggered after the world matrix is updated
  13568. */
  13569. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13570. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13571. /**
  13572. * Gets a string identifying the name of the class
  13573. * @returns "TransformNode" string
  13574. */
  13575. getClassName(): string;
  13576. /**
  13577. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13578. */
  13579. get position(): Vector3;
  13580. set position(newPosition: Vector3);
  13581. /**
  13582. * 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)).
  13583. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13584. */
  13585. get rotation(): Vector3;
  13586. set rotation(newRotation: Vector3);
  13587. /**
  13588. * 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)).
  13589. */
  13590. get scaling(): Vector3;
  13591. set scaling(newScaling: Vector3);
  13592. /**
  13593. * 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).
  13594. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13595. */
  13596. get rotationQuaternion(): Nullable<Quaternion>;
  13597. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13598. /**
  13599. * The forward direction of that transform in world space.
  13600. */
  13601. get forward(): Vector3;
  13602. /**
  13603. * The up direction of that transform in world space.
  13604. */
  13605. get up(): Vector3;
  13606. /**
  13607. * The right direction of that transform in world space.
  13608. */
  13609. get right(): Vector3;
  13610. /**
  13611. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13612. * @param matrix the matrix to copy the pose from
  13613. * @returns this TransformNode.
  13614. */
  13615. updatePoseMatrix(matrix: Matrix): TransformNode;
  13616. /**
  13617. * Returns the mesh Pose matrix.
  13618. * @returns the pose matrix
  13619. */
  13620. getPoseMatrix(): Matrix;
  13621. /** @hidden */
  13622. _isSynchronized(): boolean;
  13623. /** @hidden */
  13624. _initCache(): void;
  13625. /**
  13626. * Flag the transform node as dirty (Forcing it to update everything)
  13627. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13628. * @returns this transform node
  13629. */
  13630. markAsDirty(property: string): TransformNode;
  13631. /**
  13632. * Returns the current mesh absolute position.
  13633. * Returns a Vector3.
  13634. */
  13635. get absolutePosition(): Vector3;
  13636. /**
  13637. * Returns the current mesh absolute scaling.
  13638. * Returns a Vector3.
  13639. */
  13640. get absoluteScaling(): Vector3;
  13641. /**
  13642. * Returns the current mesh absolute rotation.
  13643. * Returns a Quaternion.
  13644. */
  13645. get absoluteRotationQuaternion(): Quaternion;
  13646. /**
  13647. * Sets a new matrix to apply before all other transformation
  13648. * @param matrix defines the transform matrix
  13649. * @returns the current TransformNode
  13650. */
  13651. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13652. /**
  13653. * Sets a new pivot matrix to the current node
  13654. * @param matrix defines the new pivot matrix to use
  13655. * @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
  13656. * @returns the current TransformNode
  13657. */
  13658. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13659. /**
  13660. * Returns the mesh pivot matrix.
  13661. * Default : Identity.
  13662. * @returns the matrix
  13663. */
  13664. getPivotMatrix(): Matrix;
  13665. /**
  13666. * Instantiate (when possible) or clone that node with its hierarchy
  13667. * @param newParent defines the new parent to use for the instance (or clone)
  13668. * @param options defines options to configure how copy is done
  13669. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13670. * @returns an instance (or a clone) of the current node with its hiearchy
  13671. */
  13672. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13673. doNotInstantiate: boolean;
  13674. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13675. /**
  13676. * Prevents the World matrix to be computed any longer
  13677. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13678. * @returns the TransformNode.
  13679. */
  13680. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13681. /**
  13682. * Allows back the World matrix computation.
  13683. * @returns the TransformNode.
  13684. */
  13685. unfreezeWorldMatrix(): this;
  13686. /**
  13687. * True if the World matrix has been frozen.
  13688. */
  13689. get isWorldMatrixFrozen(): boolean;
  13690. /**
  13691. * Retuns the mesh absolute position in the World.
  13692. * @returns a Vector3.
  13693. */
  13694. getAbsolutePosition(): Vector3;
  13695. /**
  13696. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13697. * @param absolutePosition the absolute position to set
  13698. * @returns the TransformNode.
  13699. */
  13700. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13701. /**
  13702. * Sets the mesh position in its local space.
  13703. * @param vector3 the position to set in localspace
  13704. * @returns the TransformNode.
  13705. */
  13706. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13707. /**
  13708. * Returns the mesh position in the local space from the current World matrix values.
  13709. * @returns a new Vector3.
  13710. */
  13711. getPositionExpressedInLocalSpace(): Vector3;
  13712. /**
  13713. * Translates the mesh along the passed Vector3 in its local space.
  13714. * @param vector3 the distance to translate in localspace
  13715. * @returns the TransformNode.
  13716. */
  13717. locallyTranslate(vector3: Vector3): TransformNode;
  13718. private static _lookAtVectorCache;
  13719. /**
  13720. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13721. * @param targetPoint the position (must be in same space as current mesh) to look at
  13722. * @param yawCor optional yaw (y-axis) correction in radians
  13723. * @param pitchCor optional pitch (x-axis) correction in radians
  13724. * @param rollCor optional roll (z-axis) correction in radians
  13725. * @param space the choosen space of the target
  13726. * @returns the TransformNode.
  13727. */
  13728. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13729. /**
  13730. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13731. * This Vector3 is expressed in the World space.
  13732. * @param localAxis axis to rotate
  13733. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13734. */
  13735. getDirection(localAxis: Vector3): Vector3;
  13736. /**
  13737. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13738. * localAxis is expressed in the mesh local space.
  13739. * result is computed in the Wordl space from the mesh World matrix.
  13740. * @param localAxis axis to rotate
  13741. * @param result the resulting transformnode
  13742. * @returns this TransformNode.
  13743. */
  13744. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13745. /**
  13746. * Sets this transform node rotation to the given local axis.
  13747. * @param localAxis the axis in local space
  13748. * @param yawCor optional yaw (y-axis) correction in radians
  13749. * @param pitchCor optional pitch (x-axis) correction in radians
  13750. * @param rollCor optional roll (z-axis) correction in radians
  13751. * @returns this TransformNode
  13752. */
  13753. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13754. /**
  13755. * Sets a new pivot point to the current node
  13756. * @param point defines the new pivot point to use
  13757. * @param space defines if the point is in world or local space (local by default)
  13758. * @returns the current TransformNode
  13759. */
  13760. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13761. /**
  13762. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13763. * @returns the pivot point
  13764. */
  13765. getPivotPoint(): Vector3;
  13766. /**
  13767. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13768. * @param result the vector3 to store the result
  13769. * @returns this TransformNode.
  13770. */
  13771. getPivotPointToRef(result: Vector3): TransformNode;
  13772. /**
  13773. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13774. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13775. */
  13776. getAbsolutePivotPoint(): Vector3;
  13777. /**
  13778. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13779. * @param result vector3 to store the result
  13780. * @returns this TransformNode.
  13781. */
  13782. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13783. /**
  13784. * Defines the passed node as the parent of the current node.
  13785. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13786. * @see https://doc.babylonjs.com/how_to/parenting
  13787. * @param node the node ot set as the parent
  13788. * @returns this TransformNode.
  13789. */
  13790. setParent(node: Nullable<Node>): TransformNode;
  13791. private _nonUniformScaling;
  13792. /**
  13793. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13794. */
  13795. get nonUniformScaling(): boolean;
  13796. /** @hidden */
  13797. _updateNonUniformScalingState(value: boolean): boolean;
  13798. /**
  13799. * Attach the current TransformNode to another TransformNode associated with a bone
  13800. * @param bone Bone affecting the TransformNode
  13801. * @param affectedTransformNode TransformNode associated with the bone
  13802. * @returns this object
  13803. */
  13804. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13805. /**
  13806. * Detach the transform node if its associated with a bone
  13807. * @returns this object
  13808. */
  13809. detachFromBone(): TransformNode;
  13810. private static _rotationAxisCache;
  13811. /**
  13812. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13813. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13814. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13815. * The passed axis is also normalized.
  13816. * @param axis the axis to rotate around
  13817. * @param amount the amount to rotate in radians
  13818. * @param space Space to rotate in (Default: local)
  13819. * @returns the TransformNode.
  13820. */
  13821. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13822. /**
  13823. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13824. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13825. * The passed axis is also normalized. .
  13826. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13827. * @param point the point to rotate around
  13828. * @param axis the axis to rotate around
  13829. * @param amount the amount to rotate in radians
  13830. * @returns the TransformNode
  13831. */
  13832. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13833. /**
  13834. * Translates the mesh along the axis vector for the passed distance in the given space.
  13835. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13836. * @param axis the axis to translate in
  13837. * @param distance the distance to translate
  13838. * @param space Space to rotate in (Default: local)
  13839. * @returns the TransformNode.
  13840. */
  13841. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13842. /**
  13843. * Adds a rotation step to the mesh current rotation.
  13844. * x, y, z are Euler angles expressed in radians.
  13845. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13846. * This means this rotation is made in the mesh local space only.
  13847. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13848. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13849. * ```javascript
  13850. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13851. * ```
  13852. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13853. * 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.
  13854. * @param x Rotation to add
  13855. * @param y Rotation to add
  13856. * @param z Rotation to add
  13857. * @returns the TransformNode.
  13858. */
  13859. addRotation(x: number, y: number, z: number): TransformNode;
  13860. /**
  13861. * @hidden
  13862. */
  13863. protected _getEffectiveParent(): Nullable<Node>;
  13864. /**
  13865. * Computes the world matrix of the node
  13866. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13867. * @returns the world matrix
  13868. */
  13869. computeWorldMatrix(force?: boolean): Matrix;
  13870. /**
  13871. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13872. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13873. */
  13874. resetLocalMatrix(independentOfChildren?: boolean): void;
  13875. protected _afterComputeWorldMatrix(): void;
  13876. /**
  13877. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13878. * @param func callback function to add
  13879. *
  13880. * @returns the TransformNode.
  13881. */
  13882. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13883. /**
  13884. * Removes a registered callback function.
  13885. * @param func callback function to remove
  13886. * @returns the TransformNode.
  13887. */
  13888. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13889. /**
  13890. * Gets the position of the current mesh in camera space
  13891. * @param camera defines the camera to use
  13892. * @returns a position
  13893. */
  13894. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13895. /**
  13896. * Returns the distance from the mesh to the active camera
  13897. * @param camera defines the camera to use
  13898. * @returns the distance
  13899. */
  13900. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13901. /**
  13902. * Clone the current transform node
  13903. * @param name Name of the new clone
  13904. * @param newParent New parent for the clone
  13905. * @param doNotCloneChildren Do not clone children hierarchy
  13906. * @returns the new transform node
  13907. */
  13908. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13909. /**
  13910. * Serializes the objects information.
  13911. * @param currentSerializationObject defines the object to serialize in
  13912. * @returns the serialized object
  13913. */
  13914. serialize(currentSerializationObject?: any): any;
  13915. /**
  13916. * Returns a new TransformNode object parsed from the source provided.
  13917. * @param parsedTransformNode is the source.
  13918. * @param scene the scne the object belongs to
  13919. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13920. * @returns a new TransformNode object parsed from the source provided.
  13921. */
  13922. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13923. /**
  13924. * Get all child-transformNodes of this node
  13925. * @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
  13926. * @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
  13927. * @returns an array of TransformNode
  13928. */
  13929. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13930. /**
  13931. * Releases resources associated with this transform node.
  13932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13934. */
  13935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13936. /**
  13937. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13938. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13939. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13940. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13941. * @returns the current mesh
  13942. */
  13943. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13944. private _syncAbsoluteScalingAndRotation;
  13945. }
  13946. }
  13947. declare module BABYLON {
  13948. /**
  13949. * Class used to override all child animations of a given target
  13950. */
  13951. export class AnimationPropertiesOverride {
  13952. /**
  13953. * Gets or sets a value indicating if animation blending must be used
  13954. */
  13955. enableBlending: boolean;
  13956. /**
  13957. * Gets or sets the blending speed to use when enableBlending is true
  13958. */
  13959. blendingSpeed: number;
  13960. /**
  13961. * Gets or sets the default loop mode to use
  13962. */
  13963. loopMode: number;
  13964. }
  13965. }
  13966. declare module BABYLON {
  13967. /**
  13968. * Class used to store bone information
  13969. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13970. */
  13971. export class Bone extends Node {
  13972. /**
  13973. * defines the bone name
  13974. */
  13975. name: string;
  13976. private static _tmpVecs;
  13977. private static _tmpQuat;
  13978. private static _tmpMats;
  13979. /**
  13980. * Gets the list of child bones
  13981. */
  13982. children: Bone[];
  13983. /** Gets the animations associated with this bone */
  13984. animations: Animation[];
  13985. /**
  13986. * Gets or sets bone length
  13987. */
  13988. length: number;
  13989. /**
  13990. * @hidden Internal only
  13991. * Set this value to map this bone to a different index in the transform matrices
  13992. * Set this value to -1 to exclude the bone from the transform matrices
  13993. */
  13994. _index: Nullable<number>;
  13995. private _skeleton;
  13996. private _localMatrix;
  13997. private _restPose;
  13998. private _baseMatrix;
  13999. private _absoluteTransform;
  14000. private _invertedAbsoluteTransform;
  14001. private _parent;
  14002. private _scalingDeterminant;
  14003. private _worldTransform;
  14004. private _localScaling;
  14005. private _localRotation;
  14006. private _localPosition;
  14007. private _needToDecompose;
  14008. private _needToCompose;
  14009. /** @hidden */
  14010. _linkedTransformNode: Nullable<TransformNode>;
  14011. /** @hidden */
  14012. _waitingTransformNodeId: Nullable<string>;
  14013. /** @hidden */
  14014. get _matrix(): Matrix;
  14015. /** @hidden */
  14016. set _matrix(value: Matrix);
  14017. /**
  14018. * Create a new bone
  14019. * @param name defines the bone name
  14020. * @param skeleton defines the parent skeleton
  14021. * @param parentBone defines the parent (can be null if the bone is the root)
  14022. * @param localMatrix defines the local matrix
  14023. * @param restPose defines the rest pose matrix
  14024. * @param baseMatrix defines the base matrix
  14025. * @param index defines index of the bone in the hiearchy
  14026. */
  14027. constructor(
  14028. /**
  14029. * defines the bone name
  14030. */
  14031. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14032. /**
  14033. * Gets the current object class name.
  14034. * @return the class name
  14035. */
  14036. getClassName(): string;
  14037. /**
  14038. * Gets the parent skeleton
  14039. * @returns a skeleton
  14040. */
  14041. getSkeleton(): Skeleton;
  14042. /**
  14043. * Gets parent bone
  14044. * @returns a bone or null if the bone is the root of the bone hierarchy
  14045. */
  14046. getParent(): Nullable<Bone>;
  14047. /**
  14048. * Returns an array containing the root bones
  14049. * @returns an array containing the root bones
  14050. */
  14051. getChildren(): Array<Bone>;
  14052. /**
  14053. * Gets the node index in matrix array generated for rendering
  14054. * @returns the node index
  14055. */
  14056. getIndex(): number;
  14057. /**
  14058. * Sets the parent bone
  14059. * @param parent defines the parent (can be null if the bone is the root)
  14060. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14061. */
  14062. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14063. /**
  14064. * Gets the local matrix
  14065. * @returns a matrix
  14066. */
  14067. getLocalMatrix(): Matrix;
  14068. /**
  14069. * Gets the base matrix (initial matrix which remains unchanged)
  14070. * @returns a matrix
  14071. */
  14072. getBaseMatrix(): Matrix;
  14073. /**
  14074. * Gets the rest pose matrix
  14075. * @returns a matrix
  14076. */
  14077. getRestPose(): Matrix;
  14078. /**
  14079. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14080. */
  14081. getWorldMatrix(): Matrix;
  14082. /**
  14083. * Sets the local matrix to rest pose matrix
  14084. */
  14085. returnToRest(): void;
  14086. /**
  14087. * Gets the inverse of the absolute transform matrix.
  14088. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14089. * @returns a matrix
  14090. */
  14091. getInvertedAbsoluteTransform(): Matrix;
  14092. /**
  14093. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14094. * @returns a matrix
  14095. */
  14096. getAbsoluteTransform(): Matrix;
  14097. /**
  14098. * Links with the given transform node.
  14099. * The local matrix of this bone is copied from the transform node every frame.
  14100. * @param transformNode defines the transform node to link to
  14101. */
  14102. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14103. /**
  14104. * Gets the node used to drive the bone's transformation
  14105. * @returns a transform node or null
  14106. */
  14107. getTransformNode(): Nullable<TransformNode>;
  14108. /** Gets or sets current position (in local space) */
  14109. get position(): Vector3;
  14110. set position(newPosition: Vector3);
  14111. /** Gets or sets current rotation (in local space) */
  14112. get rotation(): Vector3;
  14113. set rotation(newRotation: Vector3);
  14114. /** Gets or sets current rotation quaternion (in local space) */
  14115. get rotationQuaternion(): Quaternion;
  14116. set rotationQuaternion(newRotation: Quaternion);
  14117. /** Gets or sets current scaling (in local space) */
  14118. get scaling(): Vector3;
  14119. set scaling(newScaling: Vector3);
  14120. /**
  14121. * Gets the animation properties override
  14122. */
  14123. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14124. private _decompose;
  14125. private _compose;
  14126. /**
  14127. * Update the base and local matrices
  14128. * @param matrix defines the new base or local matrix
  14129. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14130. * @param updateLocalMatrix defines if the local matrix should be updated
  14131. */
  14132. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14133. /** @hidden */
  14134. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14135. /**
  14136. * Flag the bone as dirty (Forcing it to update everything)
  14137. */
  14138. markAsDirty(): void;
  14139. /** @hidden */
  14140. _markAsDirtyAndCompose(): void;
  14141. private _markAsDirtyAndDecompose;
  14142. /**
  14143. * Translate the bone in local or world space
  14144. * @param vec The amount to translate the bone
  14145. * @param space The space that the translation is in
  14146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14147. */
  14148. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14149. /**
  14150. * Set the postion of the bone in local or world space
  14151. * @param position The position to set the bone
  14152. * @param space The space that the position is in
  14153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14154. */
  14155. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14156. /**
  14157. * Set the absolute position of the bone (world space)
  14158. * @param position The position to set the bone
  14159. * @param mesh The mesh that this bone is attached to
  14160. */
  14161. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14162. /**
  14163. * Scale the bone on the x, y and z axes (in local space)
  14164. * @param x The amount to scale the bone on the x axis
  14165. * @param y The amount to scale the bone on the y axis
  14166. * @param z The amount to scale the bone on the z axis
  14167. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14168. */
  14169. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14170. /**
  14171. * Set the bone scaling in local space
  14172. * @param scale defines the scaling vector
  14173. */
  14174. setScale(scale: Vector3): void;
  14175. /**
  14176. * Gets the current scaling in local space
  14177. * @returns the current scaling vector
  14178. */
  14179. getScale(): Vector3;
  14180. /**
  14181. * Gets the current scaling in local space and stores it in a target vector
  14182. * @param result defines the target vector
  14183. */
  14184. getScaleToRef(result: Vector3): void;
  14185. /**
  14186. * Set the yaw, pitch, and roll of the bone in local or world space
  14187. * @param yaw The rotation of the bone on the y axis
  14188. * @param pitch The rotation of the bone on the x axis
  14189. * @param roll The rotation of the bone on the z axis
  14190. * @param space The space that the axes of rotation are in
  14191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14192. */
  14193. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14194. /**
  14195. * Add a rotation to the bone on an axis in local or world space
  14196. * @param axis The axis to rotate the bone on
  14197. * @param amount The amount to rotate the bone
  14198. * @param space The space that the axis is in
  14199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14200. */
  14201. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14202. /**
  14203. * Set the rotation of the bone to a particular axis angle in local or world space
  14204. * @param axis The axis to rotate the bone on
  14205. * @param angle The angle that the bone should be rotated to
  14206. * @param space The space that the axis is in
  14207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14208. */
  14209. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14210. /**
  14211. * Set the euler rotation of the bone in local of world space
  14212. * @param rotation The euler rotation that the bone should be set to
  14213. * @param space The space that the rotation is in
  14214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14215. */
  14216. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14217. /**
  14218. * Set the quaternion rotation of the bone in local of world space
  14219. * @param quat The quaternion rotation that the bone should be set to
  14220. * @param space The space that the rotation is in
  14221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14222. */
  14223. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14224. /**
  14225. * Set the rotation matrix of the bone in local of world space
  14226. * @param rotMat The rotation matrix that the bone should be set to
  14227. * @param space The space that the rotation is in
  14228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14229. */
  14230. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14231. private _rotateWithMatrix;
  14232. private _getNegativeRotationToRef;
  14233. /**
  14234. * Get the position of the bone in local or world space
  14235. * @param space The space that the returned position is in
  14236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14237. * @returns The position of the bone
  14238. */
  14239. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14240. /**
  14241. * Copy the position of the bone to a vector3 in local or world space
  14242. * @param space The space that the returned position is in
  14243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14244. * @param result The vector3 to copy the position to
  14245. */
  14246. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14247. /**
  14248. * Get the absolute position of the bone (world space)
  14249. * @param mesh The mesh that this bone is attached to
  14250. * @returns The absolute position of the bone
  14251. */
  14252. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14253. /**
  14254. * Copy the absolute position of the bone (world space) to the result param
  14255. * @param mesh The mesh that this bone is attached to
  14256. * @param result The vector3 to copy the absolute position to
  14257. */
  14258. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14259. /**
  14260. * Compute the absolute transforms of this bone and its children
  14261. */
  14262. computeAbsoluteTransforms(): void;
  14263. /**
  14264. * Get the world direction from an axis that is in the local space of the bone
  14265. * @param localAxis The local direction that is used to compute the world direction
  14266. * @param mesh The mesh that this bone is attached to
  14267. * @returns The world direction
  14268. */
  14269. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14270. /**
  14271. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14272. * @param localAxis The local direction that is used to compute the world direction
  14273. * @param mesh The mesh that this bone is attached to
  14274. * @param result The vector3 that the world direction will be copied to
  14275. */
  14276. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14277. /**
  14278. * Get the euler rotation of the bone in local or world space
  14279. * @param space The space that the rotation should be in
  14280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14281. * @returns The euler rotation
  14282. */
  14283. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14284. /**
  14285. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14286. * @param space The space that the rotation should be in
  14287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14288. * @param result The vector3 that the rotation should be copied to
  14289. */
  14290. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14291. /**
  14292. * Get the quaternion rotation of the bone in either local or world space
  14293. * @param space The space that the rotation should be in
  14294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14295. * @returns The quaternion rotation
  14296. */
  14297. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14298. /**
  14299. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14300. * @param space The space that the rotation should be in
  14301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14302. * @param result The quaternion that the rotation should be copied to
  14303. */
  14304. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14305. /**
  14306. * Get the rotation matrix of the bone in local or world space
  14307. * @param space The space that the rotation should be in
  14308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14309. * @returns The rotation matrix
  14310. */
  14311. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14312. /**
  14313. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14314. * @param space The space that the rotation should be in
  14315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14316. * @param result The quaternion that the rotation should be copied to
  14317. */
  14318. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14319. /**
  14320. * Get the world position of a point that is in the local space of the bone
  14321. * @param position The local position
  14322. * @param mesh The mesh that this bone is attached to
  14323. * @returns The world position
  14324. */
  14325. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14326. /**
  14327. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14328. * @param position The local position
  14329. * @param mesh The mesh that this bone is attached to
  14330. * @param result The vector3 that the world position should be copied to
  14331. */
  14332. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14333. /**
  14334. * Get the local position of a point that is in world space
  14335. * @param position The world position
  14336. * @param mesh The mesh that this bone is attached to
  14337. * @returns The local position
  14338. */
  14339. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14340. /**
  14341. * Get the local position of a point that is in world space and copy it to the result param
  14342. * @param position The world position
  14343. * @param mesh The mesh that this bone is attached to
  14344. * @param result The vector3 that the local position should be copied to
  14345. */
  14346. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14347. }
  14348. }
  14349. declare module BABYLON {
  14350. /**
  14351. * Defines a runtime animation
  14352. */
  14353. export class RuntimeAnimation {
  14354. private _events;
  14355. /**
  14356. * The current frame of the runtime animation
  14357. */
  14358. private _currentFrame;
  14359. /**
  14360. * The animation used by the runtime animation
  14361. */
  14362. private _animation;
  14363. /**
  14364. * The target of the runtime animation
  14365. */
  14366. private _target;
  14367. /**
  14368. * The initiating animatable
  14369. */
  14370. private _host;
  14371. /**
  14372. * The original value of the runtime animation
  14373. */
  14374. private _originalValue;
  14375. /**
  14376. * The original blend value of the runtime animation
  14377. */
  14378. private _originalBlendValue;
  14379. /**
  14380. * The offsets cache of the runtime animation
  14381. */
  14382. private _offsetsCache;
  14383. /**
  14384. * The high limits cache of the runtime animation
  14385. */
  14386. private _highLimitsCache;
  14387. /**
  14388. * Specifies if the runtime animation has been stopped
  14389. */
  14390. private _stopped;
  14391. /**
  14392. * The blending factor of the runtime animation
  14393. */
  14394. private _blendingFactor;
  14395. /**
  14396. * The BabylonJS scene
  14397. */
  14398. private _scene;
  14399. /**
  14400. * The current value of the runtime animation
  14401. */
  14402. private _currentValue;
  14403. /** @hidden */
  14404. _animationState: _IAnimationState;
  14405. /**
  14406. * The active target of the runtime animation
  14407. */
  14408. private _activeTargets;
  14409. private _currentActiveTarget;
  14410. private _directTarget;
  14411. /**
  14412. * The target path of the runtime animation
  14413. */
  14414. private _targetPath;
  14415. /**
  14416. * The weight of the runtime animation
  14417. */
  14418. private _weight;
  14419. /**
  14420. * The ratio offset of the runtime animation
  14421. */
  14422. private _ratioOffset;
  14423. /**
  14424. * The previous delay of the runtime animation
  14425. */
  14426. private _previousDelay;
  14427. /**
  14428. * The previous ratio of the runtime animation
  14429. */
  14430. private _previousRatio;
  14431. private _enableBlending;
  14432. private _keys;
  14433. private _minFrame;
  14434. private _maxFrame;
  14435. private _minValue;
  14436. private _maxValue;
  14437. private _targetIsArray;
  14438. /**
  14439. * Gets the current frame of the runtime animation
  14440. */
  14441. get currentFrame(): number;
  14442. /**
  14443. * Gets the weight of the runtime animation
  14444. */
  14445. get weight(): number;
  14446. /**
  14447. * Gets the current value of the runtime animation
  14448. */
  14449. get currentValue(): any;
  14450. /**
  14451. * Gets the target path of the runtime animation
  14452. */
  14453. get targetPath(): string;
  14454. /**
  14455. * Gets the actual target of the runtime animation
  14456. */
  14457. get target(): any;
  14458. /** @hidden */
  14459. _onLoop: () => void;
  14460. /**
  14461. * Create a new RuntimeAnimation object
  14462. * @param target defines the target of the animation
  14463. * @param animation defines the source animation object
  14464. * @param scene defines the hosting scene
  14465. * @param host defines the initiating Animatable
  14466. */
  14467. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14468. private _preparePath;
  14469. /**
  14470. * Gets the animation from the runtime animation
  14471. */
  14472. get animation(): Animation;
  14473. /**
  14474. * Resets the runtime animation to the beginning
  14475. * @param restoreOriginal defines whether to restore the target property to the original value
  14476. */
  14477. reset(restoreOriginal?: boolean): void;
  14478. /**
  14479. * Specifies if the runtime animation is stopped
  14480. * @returns Boolean specifying if the runtime animation is stopped
  14481. */
  14482. isStopped(): boolean;
  14483. /**
  14484. * Disposes of the runtime animation
  14485. */
  14486. dispose(): void;
  14487. /**
  14488. * Apply the interpolated value to the target
  14489. * @param currentValue defines the value computed by the animation
  14490. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14491. */
  14492. setValue(currentValue: any, weight: number): void;
  14493. private _getOriginalValues;
  14494. private _setValue;
  14495. /**
  14496. * Gets the loop pmode of the runtime animation
  14497. * @returns Loop Mode
  14498. */
  14499. private _getCorrectLoopMode;
  14500. /**
  14501. * Move the current animation to a given frame
  14502. * @param frame defines the frame to move to
  14503. */
  14504. goToFrame(frame: number): void;
  14505. /**
  14506. * @hidden Internal use only
  14507. */
  14508. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14509. /**
  14510. * Execute the current animation
  14511. * @param delay defines the delay to add to the current frame
  14512. * @param from defines the lower bound of the animation range
  14513. * @param to defines the upper bound of the animation range
  14514. * @param loop defines if the current animation must loop
  14515. * @param speedRatio defines the current speed ratio
  14516. * @param weight defines the weight of the animation (default is -1 so no weight)
  14517. * @param onLoop optional callback called when animation loops
  14518. * @returns a boolean indicating if the animation is running
  14519. */
  14520. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14521. }
  14522. }
  14523. declare module BABYLON {
  14524. /**
  14525. * Class used to store an actual running animation
  14526. */
  14527. export class Animatable {
  14528. /** defines the target object */
  14529. target: any;
  14530. /** defines the starting frame number (default is 0) */
  14531. fromFrame: number;
  14532. /** defines the ending frame number (default is 100) */
  14533. toFrame: number;
  14534. /** defines if the animation must loop (default is false) */
  14535. loopAnimation: boolean;
  14536. /** defines a callback to call when animation ends if it is not looping */
  14537. onAnimationEnd?: (() => void) | null | undefined;
  14538. /** defines a callback to call when animation loops */
  14539. onAnimationLoop?: (() => void) | null | undefined;
  14540. private _localDelayOffset;
  14541. private _pausedDelay;
  14542. private _runtimeAnimations;
  14543. private _paused;
  14544. private _scene;
  14545. private _speedRatio;
  14546. private _weight;
  14547. private _syncRoot;
  14548. /**
  14549. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14550. * This will only apply for non looping animation (default is true)
  14551. */
  14552. disposeOnEnd: boolean;
  14553. /**
  14554. * Gets a boolean indicating if the animation has started
  14555. */
  14556. animationStarted: boolean;
  14557. /**
  14558. * Observer raised when the animation ends
  14559. */
  14560. onAnimationEndObservable: Observable<Animatable>;
  14561. /**
  14562. * Observer raised when the animation loops
  14563. */
  14564. onAnimationLoopObservable: Observable<Animatable>;
  14565. /**
  14566. * Gets the root Animatable used to synchronize and normalize animations
  14567. */
  14568. get syncRoot(): Nullable<Animatable>;
  14569. /**
  14570. * Gets the current frame of the first RuntimeAnimation
  14571. * Used to synchronize Animatables
  14572. */
  14573. get masterFrame(): number;
  14574. /**
  14575. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14576. */
  14577. get weight(): number;
  14578. set weight(value: number);
  14579. /**
  14580. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14581. */
  14582. get speedRatio(): number;
  14583. set speedRatio(value: number);
  14584. /**
  14585. * Creates a new Animatable
  14586. * @param scene defines the hosting scene
  14587. * @param target defines the target object
  14588. * @param fromFrame defines the starting frame number (default is 0)
  14589. * @param toFrame defines the ending frame number (default is 100)
  14590. * @param loopAnimation defines if the animation must loop (default is false)
  14591. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14592. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14593. * @param animations defines a group of animation to add to the new Animatable
  14594. * @param onAnimationLoop defines a callback to call when animation loops
  14595. */
  14596. constructor(scene: Scene,
  14597. /** defines the target object */
  14598. target: any,
  14599. /** defines the starting frame number (default is 0) */
  14600. fromFrame?: number,
  14601. /** defines the ending frame number (default is 100) */
  14602. toFrame?: number,
  14603. /** defines if the animation must loop (default is false) */
  14604. loopAnimation?: boolean, speedRatio?: number,
  14605. /** defines a callback to call when animation ends if it is not looping */
  14606. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14607. /** defines a callback to call when animation loops */
  14608. onAnimationLoop?: (() => void) | null | undefined);
  14609. /**
  14610. * Synchronize and normalize current Animatable with a source Animatable
  14611. * This is useful when using animation weights and when animations are not of the same length
  14612. * @param root defines the root Animatable to synchronize with
  14613. * @returns the current Animatable
  14614. */
  14615. syncWith(root: Animatable): Animatable;
  14616. /**
  14617. * Gets the list of runtime animations
  14618. * @returns an array of RuntimeAnimation
  14619. */
  14620. getAnimations(): RuntimeAnimation[];
  14621. /**
  14622. * Adds more animations to the current animatable
  14623. * @param target defines the target of the animations
  14624. * @param animations defines the new animations to add
  14625. */
  14626. appendAnimations(target: any, animations: Animation[]): void;
  14627. /**
  14628. * Gets the source animation for a specific property
  14629. * @param property defines the propertyu to look for
  14630. * @returns null or the source animation for the given property
  14631. */
  14632. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14633. /**
  14634. * Gets the runtime animation for a specific property
  14635. * @param property defines the propertyu to look for
  14636. * @returns null or the runtime animation for the given property
  14637. */
  14638. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14639. /**
  14640. * Resets the animatable to its original state
  14641. */
  14642. reset(): void;
  14643. /**
  14644. * Allows the animatable to blend with current running animations
  14645. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14646. * @param blendingSpeed defines the blending speed to use
  14647. */
  14648. enableBlending(blendingSpeed: number): void;
  14649. /**
  14650. * Disable animation blending
  14651. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14652. */
  14653. disableBlending(): void;
  14654. /**
  14655. * Jump directly to a given frame
  14656. * @param frame defines the frame to jump to
  14657. */
  14658. goToFrame(frame: number): void;
  14659. /**
  14660. * Pause the animation
  14661. */
  14662. pause(): void;
  14663. /**
  14664. * Restart the animation
  14665. */
  14666. restart(): void;
  14667. private _raiseOnAnimationEnd;
  14668. /**
  14669. * Stop and delete the current animation
  14670. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14671. * @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)
  14672. */
  14673. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14674. /**
  14675. * Wait asynchronously for the animation to end
  14676. * @returns a promise which will be fullfilled when the animation ends
  14677. */
  14678. waitAsync(): Promise<Animatable>;
  14679. /** @hidden */
  14680. _animate(delay: number): boolean;
  14681. }
  14682. interface Scene {
  14683. /** @hidden */
  14684. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14685. /** @hidden */
  14686. _processLateAnimationBindingsForMatrices(holder: {
  14687. totalWeight: number;
  14688. animations: RuntimeAnimation[];
  14689. originalValue: Matrix;
  14690. }): any;
  14691. /** @hidden */
  14692. _processLateAnimationBindingsForQuaternions(holder: {
  14693. totalWeight: number;
  14694. animations: RuntimeAnimation[];
  14695. originalValue: Quaternion;
  14696. }, refQuaternion: Quaternion): Quaternion;
  14697. /** @hidden */
  14698. _processLateAnimationBindings(): void;
  14699. /**
  14700. * Will start the animation sequence of a given target
  14701. * @param target defines the target
  14702. * @param from defines from which frame should animation start
  14703. * @param to defines until which frame should animation run.
  14704. * @param weight defines the weight to apply to the animation (1.0 by default)
  14705. * @param loop defines if the animation loops
  14706. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14707. * @param onAnimationEnd defines the function to be executed when the animation ends
  14708. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14709. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14710. * @param onAnimationLoop defines the callback to call when an animation loops
  14711. * @returns the animatable object created for this animation
  14712. */
  14713. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14714. /**
  14715. * Will start the animation sequence of a given target
  14716. * @param target defines the target
  14717. * @param from defines from which frame should animation start
  14718. * @param to defines until which frame should animation run.
  14719. * @param loop defines if the animation loops
  14720. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14721. * @param onAnimationEnd defines the function to be executed when the animation ends
  14722. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14723. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14724. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14725. * @param onAnimationLoop defines the callback to call when an animation loops
  14726. * @returns the animatable object created for this animation
  14727. */
  14728. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14729. /**
  14730. * Will start the animation sequence of a given target and its hierarchy
  14731. * @param target defines the target
  14732. * @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.
  14733. * @param from defines from which frame should animation start
  14734. * @param to defines until which frame should animation run.
  14735. * @param loop defines if the animation loops
  14736. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14737. * @param onAnimationEnd defines the function to be executed when the animation ends
  14738. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14739. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14740. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14741. * @param onAnimationLoop defines the callback to call when an animation loops
  14742. * @returns the list of created animatables
  14743. */
  14744. 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[];
  14745. /**
  14746. * Begin a new animation on a given node
  14747. * @param target defines the target where the animation will take place
  14748. * @param animations defines the list of animations to start
  14749. * @param from defines the initial value
  14750. * @param to defines the final value
  14751. * @param loop defines if you want animation to loop (off by default)
  14752. * @param speedRatio defines the speed ratio to apply to all animations
  14753. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14754. * @param onAnimationLoop defines the callback to call when an animation loops
  14755. * @returns the list of created animatables
  14756. */
  14757. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14758. /**
  14759. * Begin a new animation on a given node and its hierarchy
  14760. * @param target defines the root node where the animation will take place
  14761. * @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.
  14762. * @param animations defines the list of animations to start
  14763. * @param from defines the initial value
  14764. * @param to defines the final value
  14765. * @param loop defines if you want animation to loop (off by default)
  14766. * @param speedRatio defines the speed ratio to apply to all animations
  14767. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14768. * @param onAnimationLoop defines the callback to call when an animation loops
  14769. * @returns the list of animatables created for all nodes
  14770. */
  14771. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14772. /**
  14773. * Gets the animatable associated with a specific target
  14774. * @param target defines the target of the animatable
  14775. * @returns the required animatable if found
  14776. */
  14777. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14778. /**
  14779. * Gets all animatables associated with a given target
  14780. * @param target defines the target to look animatables for
  14781. * @returns an array of Animatables
  14782. */
  14783. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14784. /**
  14785. * Stops and removes all animations that have been applied to the scene
  14786. */
  14787. stopAllAnimations(): void;
  14788. /**
  14789. * Gets the current delta time used by animation engine
  14790. */
  14791. deltaTime: number;
  14792. }
  14793. interface Bone {
  14794. /**
  14795. * Copy an animation range from another bone
  14796. * @param source defines the source bone
  14797. * @param rangeName defines the range name to copy
  14798. * @param frameOffset defines the frame offset
  14799. * @param rescaleAsRequired defines if rescaling must be applied if required
  14800. * @param skelDimensionsRatio defines the scaling ratio
  14801. * @returns true if operation was successful
  14802. */
  14803. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14804. }
  14805. }
  14806. declare module BABYLON {
  14807. /**
  14808. * Class used to handle skinning animations
  14809. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14810. */
  14811. export class Skeleton implements IAnimatable {
  14812. /** defines the skeleton name */
  14813. name: string;
  14814. /** defines the skeleton Id */
  14815. id: string;
  14816. /**
  14817. * Defines the list of child bones
  14818. */
  14819. bones: Bone[];
  14820. /**
  14821. * Defines an estimate of the dimension of the skeleton at rest
  14822. */
  14823. dimensionsAtRest: Vector3;
  14824. /**
  14825. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14826. */
  14827. needInitialSkinMatrix: boolean;
  14828. /**
  14829. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14830. */
  14831. overrideMesh: Nullable<AbstractMesh>;
  14832. /**
  14833. * Gets the list of animations attached to this skeleton
  14834. */
  14835. animations: Array<Animation>;
  14836. private _scene;
  14837. private _isDirty;
  14838. private _transformMatrices;
  14839. private _transformMatrixTexture;
  14840. private _meshesWithPoseMatrix;
  14841. private _animatables;
  14842. private _identity;
  14843. private _synchronizedWithMesh;
  14844. private _ranges;
  14845. private _lastAbsoluteTransformsUpdateId;
  14846. private _canUseTextureForBones;
  14847. private _uniqueId;
  14848. /** @hidden */
  14849. _numBonesWithLinkedTransformNode: number;
  14850. /** @hidden */
  14851. _hasWaitingData: Nullable<boolean>;
  14852. /**
  14853. * Specifies if the skeleton should be serialized
  14854. */
  14855. doNotSerialize: boolean;
  14856. private _useTextureToStoreBoneMatrices;
  14857. /**
  14858. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14859. * Please note that this option is not available if the hardware does not support it
  14860. */
  14861. get useTextureToStoreBoneMatrices(): boolean;
  14862. set useTextureToStoreBoneMatrices(value: boolean);
  14863. private _animationPropertiesOverride;
  14864. /**
  14865. * Gets or sets the animation properties override
  14866. */
  14867. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14868. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14869. /**
  14870. * List of inspectable custom properties (used by the Inspector)
  14871. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14872. */
  14873. inspectableCustomProperties: IInspectable[];
  14874. /**
  14875. * An observable triggered before computing the skeleton's matrices
  14876. */
  14877. onBeforeComputeObservable: Observable<Skeleton>;
  14878. /**
  14879. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14880. */
  14881. get isUsingTextureForMatrices(): boolean;
  14882. /**
  14883. * Gets the unique ID of this skeleton
  14884. */
  14885. get uniqueId(): number;
  14886. /**
  14887. * Creates a new skeleton
  14888. * @param name defines the skeleton name
  14889. * @param id defines the skeleton Id
  14890. * @param scene defines the hosting scene
  14891. */
  14892. constructor(
  14893. /** defines the skeleton name */
  14894. name: string,
  14895. /** defines the skeleton Id */
  14896. id: string, scene: Scene);
  14897. /**
  14898. * Gets the current object class name.
  14899. * @return the class name
  14900. */
  14901. getClassName(): string;
  14902. /**
  14903. * Returns an array containing the root bones
  14904. * @returns an array containing the root bones
  14905. */
  14906. getChildren(): Array<Bone>;
  14907. /**
  14908. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14909. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14910. * @returns a Float32Array containing matrices data
  14911. */
  14912. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14913. /**
  14914. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14915. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14916. * @returns a raw texture containing the data
  14917. */
  14918. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14919. /**
  14920. * Gets the current hosting scene
  14921. * @returns a scene object
  14922. */
  14923. getScene(): Scene;
  14924. /**
  14925. * Gets a string representing the current skeleton data
  14926. * @param fullDetails defines a boolean indicating if we want a verbose version
  14927. * @returns a string representing the current skeleton data
  14928. */
  14929. toString(fullDetails?: boolean): string;
  14930. /**
  14931. * Get bone's index searching by name
  14932. * @param name defines bone's name to search for
  14933. * @return the indice of the bone. Returns -1 if not found
  14934. */
  14935. getBoneIndexByName(name: string): number;
  14936. /**
  14937. * Creater a new animation range
  14938. * @param name defines the name of the range
  14939. * @param from defines the start key
  14940. * @param to defines the end key
  14941. */
  14942. createAnimationRange(name: string, from: number, to: number): void;
  14943. /**
  14944. * Delete a specific animation range
  14945. * @param name defines the name of the range
  14946. * @param deleteFrames defines if frames must be removed as well
  14947. */
  14948. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14949. /**
  14950. * Gets a specific animation range
  14951. * @param name defines the name of the range to look for
  14952. * @returns the requested animation range or null if not found
  14953. */
  14954. getAnimationRange(name: string): Nullable<AnimationRange>;
  14955. /**
  14956. * Gets the list of all animation ranges defined on this skeleton
  14957. * @returns an array
  14958. */
  14959. getAnimationRanges(): Nullable<AnimationRange>[];
  14960. /**
  14961. * Copy animation range from a source skeleton.
  14962. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14963. * @param source defines the source skeleton
  14964. * @param name defines the name of the range to copy
  14965. * @param rescaleAsRequired defines if rescaling must be applied if required
  14966. * @returns true if operation was successful
  14967. */
  14968. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14969. /**
  14970. * Forces the skeleton to go to rest pose
  14971. */
  14972. returnToRest(): void;
  14973. private _getHighestAnimationFrame;
  14974. /**
  14975. * Begin a specific animation range
  14976. * @param name defines the name of the range to start
  14977. * @param loop defines if looping must be turned on (false by default)
  14978. * @param speedRatio defines the speed ratio to apply (1 by default)
  14979. * @param onAnimationEnd defines a callback which will be called when animation will end
  14980. * @returns a new animatable
  14981. */
  14982. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14983. /** @hidden */
  14984. _markAsDirty(): void;
  14985. /** @hidden */
  14986. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14987. /** @hidden */
  14988. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14989. private _computeTransformMatrices;
  14990. /**
  14991. * Build all resources required to render a skeleton
  14992. */
  14993. prepare(): void;
  14994. /**
  14995. * Gets the list of animatables currently running for this skeleton
  14996. * @returns an array of animatables
  14997. */
  14998. getAnimatables(): IAnimatable[];
  14999. /**
  15000. * Clone the current skeleton
  15001. * @param name defines the name of the new skeleton
  15002. * @param id defines the id of the new skeleton
  15003. * @returns the new skeleton
  15004. */
  15005. clone(name: string, id?: string): Skeleton;
  15006. /**
  15007. * Enable animation blending for this skeleton
  15008. * @param blendingSpeed defines the blending speed to apply
  15009. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15010. */
  15011. enableBlending(blendingSpeed?: number): void;
  15012. /**
  15013. * Releases all resources associated with the current skeleton
  15014. */
  15015. dispose(): void;
  15016. /**
  15017. * Serialize the skeleton in a JSON object
  15018. * @returns a JSON object
  15019. */
  15020. serialize(): any;
  15021. /**
  15022. * Creates a new skeleton from serialized data
  15023. * @param parsedSkeleton defines the serialized data
  15024. * @param scene defines the hosting scene
  15025. * @returns a new skeleton
  15026. */
  15027. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15028. /**
  15029. * Compute all node absolute transforms
  15030. * @param forceUpdate defines if computation must be done even if cache is up to date
  15031. */
  15032. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15033. /**
  15034. * Gets the root pose matrix
  15035. * @returns a matrix
  15036. */
  15037. getPoseMatrix(): Nullable<Matrix>;
  15038. /**
  15039. * Sorts bones per internal index
  15040. */
  15041. sortBones(): void;
  15042. private _sortBones;
  15043. }
  15044. }
  15045. declare module BABYLON {
  15046. /**
  15047. * Creates an instance based on a source mesh.
  15048. */
  15049. export class InstancedMesh extends AbstractMesh {
  15050. private _sourceMesh;
  15051. private _currentLOD;
  15052. /** @hidden */
  15053. _indexInSourceMeshInstanceArray: number;
  15054. constructor(name: string, source: Mesh);
  15055. /**
  15056. * Returns the string "InstancedMesh".
  15057. */
  15058. getClassName(): string;
  15059. /** Gets the list of lights affecting that mesh */
  15060. get lightSources(): Light[];
  15061. _resyncLightSources(): void;
  15062. _resyncLightSource(light: Light): void;
  15063. _removeLightSource(light: Light, dispose: boolean): void;
  15064. /**
  15065. * If the source mesh receives shadows
  15066. */
  15067. get receiveShadows(): boolean;
  15068. /**
  15069. * The material of the source mesh
  15070. */
  15071. get material(): Nullable<Material>;
  15072. /**
  15073. * Visibility of the source mesh
  15074. */
  15075. get visibility(): number;
  15076. /**
  15077. * Skeleton of the source mesh
  15078. */
  15079. get skeleton(): Nullable<Skeleton>;
  15080. /**
  15081. * Rendering ground id of the source mesh
  15082. */
  15083. get renderingGroupId(): number;
  15084. set renderingGroupId(value: number);
  15085. /**
  15086. * Returns the total number of vertices (integer).
  15087. */
  15088. getTotalVertices(): number;
  15089. /**
  15090. * Returns a positive integer : the total number of indices in this mesh geometry.
  15091. * @returns the numner of indices or zero if the mesh has no geometry.
  15092. */
  15093. getTotalIndices(): number;
  15094. /**
  15095. * The source mesh of the instance
  15096. */
  15097. get sourceMesh(): Mesh;
  15098. /**
  15099. * Is this node ready to be used/rendered
  15100. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15101. * @return {boolean} is it ready
  15102. */
  15103. isReady(completeCheck?: boolean): boolean;
  15104. /**
  15105. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15106. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15107. * @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.
  15108. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15109. */
  15110. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15111. /**
  15112. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15113. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15114. * The `data` are either a numeric array either a Float32Array.
  15115. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15116. * 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).
  15117. * Note that a new underlying VertexBuffer object is created each call.
  15118. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15119. *
  15120. * Possible `kind` values :
  15121. * - VertexBuffer.PositionKind
  15122. * - VertexBuffer.UVKind
  15123. * - VertexBuffer.UV2Kind
  15124. * - VertexBuffer.UV3Kind
  15125. * - VertexBuffer.UV4Kind
  15126. * - VertexBuffer.UV5Kind
  15127. * - VertexBuffer.UV6Kind
  15128. * - VertexBuffer.ColorKind
  15129. * - VertexBuffer.MatricesIndicesKind
  15130. * - VertexBuffer.MatricesIndicesExtraKind
  15131. * - VertexBuffer.MatricesWeightsKind
  15132. * - VertexBuffer.MatricesWeightsExtraKind
  15133. *
  15134. * Returns the Mesh.
  15135. */
  15136. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15137. /**
  15138. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15139. * If the mesh has no geometry, it is simply returned as it is.
  15140. * The `data` are either a numeric array either a Float32Array.
  15141. * No new underlying VertexBuffer object is created.
  15142. * 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.
  15143. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15144. *
  15145. * Possible `kind` values :
  15146. * - VertexBuffer.PositionKind
  15147. * - VertexBuffer.UVKind
  15148. * - VertexBuffer.UV2Kind
  15149. * - VertexBuffer.UV3Kind
  15150. * - VertexBuffer.UV4Kind
  15151. * - VertexBuffer.UV5Kind
  15152. * - VertexBuffer.UV6Kind
  15153. * - VertexBuffer.ColorKind
  15154. * - VertexBuffer.MatricesIndicesKind
  15155. * - VertexBuffer.MatricesIndicesExtraKind
  15156. * - VertexBuffer.MatricesWeightsKind
  15157. * - VertexBuffer.MatricesWeightsExtraKind
  15158. *
  15159. * Returns the Mesh.
  15160. */
  15161. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15162. /**
  15163. * Sets the mesh indices.
  15164. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15165. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15166. * This method creates a new index buffer each call.
  15167. * Returns the Mesh.
  15168. */
  15169. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15170. /**
  15171. * Boolean : True if the mesh owns the requested kind of data.
  15172. */
  15173. isVerticesDataPresent(kind: string): boolean;
  15174. /**
  15175. * Returns an array of indices (IndicesArray).
  15176. */
  15177. getIndices(): Nullable<IndicesArray>;
  15178. get _positions(): Nullable<Vector3[]>;
  15179. /**
  15180. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15181. * This means the mesh underlying bounding box and sphere are recomputed.
  15182. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15183. * @returns the current mesh
  15184. */
  15185. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15186. /** @hidden */
  15187. _preActivate(): InstancedMesh;
  15188. /** @hidden */
  15189. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15190. /** @hidden */
  15191. _postActivate(): void;
  15192. getWorldMatrix(): Matrix;
  15193. get isAnInstance(): boolean;
  15194. /**
  15195. * Returns the current associated LOD AbstractMesh.
  15196. */
  15197. getLOD(camera: Camera): AbstractMesh;
  15198. /** @hidden */
  15199. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15200. /** @hidden */
  15201. _syncSubMeshes(): InstancedMesh;
  15202. /** @hidden */
  15203. _generatePointsArray(): boolean;
  15204. /**
  15205. * Creates a new InstancedMesh from the current mesh.
  15206. * - name (string) : the cloned mesh name
  15207. * - newParent (optional Node) : the optional Node to parent the clone to.
  15208. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15209. *
  15210. * Returns the clone.
  15211. */
  15212. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15213. /**
  15214. * Disposes the InstancedMesh.
  15215. * Returns nothing.
  15216. */
  15217. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15218. }
  15219. interface Mesh {
  15220. /**
  15221. * Register a custom buffer that will be instanced
  15222. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15223. * @param kind defines the buffer kind
  15224. * @param stride defines the stride in floats
  15225. */
  15226. registerInstancedBuffer(kind: string, stride: number): void;
  15227. /** @hidden */
  15228. _userInstancedBuffersStorage: {
  15229. data: {
  15230. [key: string]: Float32Array;
  15231. };
  15232. sizes: {
  15233. [key: string]: number;
  15234. };
  15235. vertexBuffers: {
  15236. [key: string]: Nullable<VertexBuffer>;
  15237. };
  15238. strides: {
  15239. [key: string]: number;
  15240. };
  15241. };
  15242. }
  15243. interface AbstractMesh {
  15244. /**
  15245. * Object used to store instanced buffers defined by user
  15246. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15247. */
  15248. instancedBuffers: {
  15249. [key: string]: any;
  15250. };
  15251. }
  15252. }
  15253. declare module BABYLON {
  15254. /**
  15255. * Defines the options associated with the creation of a shader material.
  15256. */
  15257. export interface IShaderMaterialOptions {
  15258. /**
  15259. * Does the material work in alpha blend mode
  15260. */
  15261. needAlphaBlending: boolean;
  15262. /**
  15263. * Does the material work in alpha test mode
  15264. */
  15265. needAlphaTesting: boolean;
  15266. /**
  15267. * The list of attribute names used in the shader
  15268. */
  15269. attributes: string[];
  15270. /**
  15271. * The list of unifrom names used in the shader
  15272. */
  15273. uniforms: string[];
  15274. /**
  15275. * The list of UBO names used in the shader
  15276. */
  15277. uniformBuffers: string[];
  15278. /**
  15279. * The list of sampler names used in the shader
  15280. */
  15281. samplers: string[];
  15282. /**
  15283. * The list of defines used in the shader
  15284. */
  15285. defines: string[];
  15286. }
  15287. /**
  15288. * 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.
  15289. *
  15290. * This returned material effects how the mesh will look based on the code in the shaders.
  15291. *
  15292. * @see http://doc.babylonjs.com/how_to/shader_material
  15293. */
  15294. export class ShaderMaterial extends Material {
  15295. private _shaderPath;
  15296. private _options;
  15297. private _textures;
  15298. private _textureArrays;
  15299. private _floats;
  15300. private _ints;
  15301. private _floatsArrays;
  15302. private _colors3;
  15303. private _colors3Arrays;
  15304. private _colors4;
  15305. private _colors4Arrays;
  15306. private _vectors2;
  15307. private _vectors3;
  15308. private _vectors4;
  15309. private _matrices;
  15310. private _matrixArrays;
  15311. private _matrices3x3;
  15312. private _matrices2x2;
  15313. private _vectors2Arrays;
  15314. private _vectors3Arrays;
  15315. private _vectors4Arrays;
  15316. private _cachedWorldViewMatrix;
  15317. private _cachedWorldViewProjectionMatrix;
  15318. private _renderId;
  15319. private _multiview;
  15320. /**
  15321. * Instantiate a new shader material.
  15322. * 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.
  15323. * This returned material effects how the mesh will look based on the code in the shaders.
  15324. * @see http://doc.babylonjs.com/how_to/shader_material
  15325. * @param name Define the name of the material in the scene
  15326. * @param scene Define the scene the material belongs to
  15327. * @param shaderPath Defines the route to the shader code in one of three ways:
  15328. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15329. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15330. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15331. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15332. * @param options Define the options used to create the shader
  15333. */
  15334. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15335. /**
  15336. * Gets the shader path used to define the shader code
  15337. * It can be modified to trigger a new compilation
  15338. */
  15339. get shaderPath(): any;
  15340. /**
  15341. * Sets the shader path used to define the shader code
  15342. * It can be modified to trigger a new compilation
  15343. */
  15344. set shaderPath(shaderPath: any);
  15345. /**
  15346. * Gets the options used to compile the shader.
  15347. * They can be modified to trigger a new compilation
  15348. */
  15349. get options(): IShaderMaterialOptions;
  15350. /**
  15351. * Gets the current class name of the material e.g. "ShaderMaterial"
  15352. * Mainly use in serialization.
  15353. * @returns the class name
  15354. */
  15355. getClassName(): string;
  15356. /**
  15357. * Specifies if the material will require alpha blending
  15358. * @returns a boolean specifying if alpha blending is needed
  15359. */
  15360. needAlphaBlending(): boolean;
  15361. /**
  15362. * Specifies if this material should be rendered in alpha test mode
  15363. * @returns a boolean specifying if an alpha test is needed.
  15364. */
  15365. needAlphaTesting(): boolean;
  15366. private _checkUniform;
  15367. /**
  15368. * Set a texture in the shader.
  15369. * @param name Define the name of the uniform samplers as defined in the shader
  15370. * @param texture Define the texture to bind to this sampler
  15371. * @return the material itself allowing "fluent" like uniform updates
  15372. */
  15373. setTexture(name: string, texture: Texture): ShaderMaterial;
  15374. /**
  15375. * Set a texture array in the shader.
  15376. * @param name Define the name of the uniform sampler array as defined in the shader
  15377. * @param textures Define the list of textures to bind to this sampler
  15378. * @return the material itself allowing "fluent" like uniform updates
  15379. */
  15380. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15381. /**
  15382. * Set a float in the shader.
  15383. * @param name Define the name of the uniform as defined in the shader
  15384. * @param value Define the value to give to the uniform
  15385. * @return the material itself allowing "fluent" like uniform updates
  15386. */
  15387. setFloat(name: string, value: number): ShaderMaterial;
  15388. /**
  15389. * Set a int in the shader.
  15390. * @param name Define the name of the uniform as defined in the shader
  15391. * @param value Define the value to give to the uniform
  15392. * @return the material itself allowing "fluent" like uniform updates
  15393. */
  15394. setInt(name: string, value: number): ShaderMaterial;
  15395. /**
  15396. * Set an array of floats in the shader.
  15397. * @param name Define the name of the uniform as defined in the shader
  15398. * @param value Define the value to give to the uniform
  15399. * @return the material itself allowing "fluent" like uniform updates
  15400. */
  15401. setFloats(name: string, value: number[]): ShaderMaterial;
  15402. /**
  15403. * Set a vec3 in the shader from a Color3.
  15404. * @param name Define the name of the uniform as defined in the shader
  15405. * @param value Define the value to give to the uniform
  15406. * @return the material itself allowing "fluent" like uniform updates
  15407. */
  15408. setColor3(name: string, value: Color3): ShaderMaterial;
  15409. /**
  15410. * Set a vec3 array in the shader from a Color3 array.
  15411. * @param name Define the name of the uniform as defined in the shader
  15412. * @param value Define the value to give to the uniform
  15413. * @return the material itself allowing "fluent" like uniform updates
  15414. */
  15415. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15416. /**
  15417. * Set a vec4 in the shader from a Color4.
  15418. * @param name Define the name of the uniform as defined in the shader
  15419. * @param value Define the value to give to the uniform
  15420. * @return the material itself allowing "fluent" like uniform updates
  15421. */
  15422. setColor4(name: string, value: Color4): ShaderMaterial;
  15423. /**
  15424. * Set a vec4 array in the shader from a Color4 array.
  15425. * @param name Define the name of the uniform as defined in the shader
  15426. * @param value Define the value to give to the uniform
  15427. * @return the material itself allowing "fluent" like uniform updates
  15428. */
  15429. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15430. /**
  15431. * Set a vec2 in the shader from a Vector2.
  15432. * @param name Define the name of the uniform as defined in the shader
  15433. * @param value Define the value to give to the uniform
  15434. * @return the material itself allowing "fluent" like uniform updates
  15435. */
  15436. setVector2(name: string, value: Vector2): ShaderMaterial;
  15437. /**
  15438. * Set a vec3 in the shader from a Vector3.
  15439. * @param name Define the name of the uniform as defined in the shader
  15440. * @param value Define the value to give to the uniform
  15441. * @return the material itself allowing "fluent" like uniform updates
  15442. */
  15443. setVector3(name: string, value: Vector3): ShaderMaterial;
  15444. /**
  15445. * Set a vec4 in the shader from a Vector4.
  15446. * @param name Define the name of the uniform as defined in the shader
  15447. * @param value Define the value to give to the uniform
  15448. * @return the material itself allowing "fluent" like uniform updates
  15449. */
  15450. setVector4(name: string, value: Vector4): ShaderMaterial;
  15451. /**
  15452. * Set a mat4 in the shader from a Matrix.
  15453. * @param name Define the name of the uniform as defined in the shader
  15454. * @param value Define the value to give to the uniform
  15455. * @return the material itself allowing "fluent" like uniform updates
  15456. */
  15457. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15458. /**
  15459. * Set a float32Array in the shader from a matrix array.
  15460. * @param name Define the name of the uniform as defined in the shader
  15461. * @param value Define the value to give to the uniform
  15462. * @return the material itself allowing "fluent" like uniform updates
  15463. */
  15464. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15465. /**
  15466. * Set a mat3 in the shader from a Float32Array.
  15467. * @param name Define the name of the uniform as defined in the shader
  15468. * @param value Define the value to give to the uniform
  15469. * @return the material itself allowing "fluent" like uniform updates
  15470. */
  15471. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15472. /**
  15473. * Set a mat2 in the shader from a Float32Array.
  15474. * @param name Define the name of the uniform as defined in the shader
  15475. * @param value Define the value to give to the uniform
  15476. * @return the material itself allowing "fluent" like uniform updates
  15477. */
  15478. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15479. /**
  15480. * Set a vec2 array in the shader from a number array.
  15481. * @param name Define the name of the uniform as defined in the shader
  15482. * @param value Define the value to give to the uniform
  15483. * @return the material itself allowing "fluent" like uniform updates
  15484. */
  15485. setArray2(name: string, value: number[]): ShaderMaterial;
  15486. /**
  15487. * Set a vec3 array in the shader from a number array.
  15488. * @param name Define the name of the uniform as defined in the shader
  15489. * @param value Define the value to give to the uniform
  15490. * @return the material itself allowing "fluent" like uniform updates
  15491. */
  15492. setArray3(name: string, value: number[]): ShaderMaterial;
  15493. /**
  15494. * Set a vec4 array in the shader from a number array.
  15495. * @param name Define the name of the uniform as defined in the shader
  15496. * @param value Define the value to give to the uniform
  15497. * @return the material itself allowing "fluent" like uniform updates
  15498. */
  15499. setArray4(name: string, value: number[]): ShaderMaterial;
  15500. private _checkCache;
  15501. /**
  15502. * Specifies that the submesh is ready to be used
  15503. * @param mesh defines the mesh to check
  15504. * @param subMesh defines which submesh to check
  15505. * @param useInstances specifies that instances should be used
  15506. * @returns a boolean indicating that the submesh is ready or not
  15507. */
  15508. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15509. /**
  15510. * Checks if the material is ready to render the requested mesh
  15511. * @param mesh Define the mesh to render
  15512. * @param useInstances Define whether or not the material is used with instances
  15513. * @returns true if ready, otherwise false
  15514. */
  15515. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15516. /**
  15517. * Binds the world matrix to the material
  15518. * @param world defines the world transformation matrix
  15519. */
  15520. bindOnlyWorldMatrix(world: Matrix): void;
  15521. /**
  15522. * Binds the material to the mesh
  15523. * @param world defines the world transformation matrix
  15524. * @param mesh defines the mesh to bind the material to
  15525. */
  15526. bind(world: Matrix, mesh?: Mesh): void;
  15527. /**
  15528. * Gets the active textures from the material
  15529. * @returns an array of textures
  15530. */
  15531. getActiveTextures(): BaseTexture[];
  15532. /**
  15533. * Specifies if the material uses a texture
  15534. * @param texture defines the texture to check against the material
  15535. * @returns a boolean specifying if the material uses the texture
  15536. */
  15537. hasTexture(texture: BaseTexture): boolean;
  15538. /**
  15539. * Makes a duplicate of the material, and gives it a new name
  15540. * @param name defines the new name for the duplicated material
  15541. * @returns the cloned material
  15542. */
  15543. clone(name: string): ShaderMaterial;
  15544. /**
  15545. * Disposes the material
  15546. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15547. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15548. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15549. */
  15550. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15551. /**
  15552. * Serializes this material in a JSON representation
  15553. * @returns the serialized material object
  15554. */
  15555. serialize(): any;
  15556. /**
  15557. * Creates a shader material from parsed shader material data
  15558. * @param source defines the JSON represnetation of the material
  15559. * @param scene defines the hosting scene
  15560. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15561. * @returns a new material
  15562. */
  15563. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15564. }
  15565. }
  15566. declare module BABYLON {
  15567. /** @hidden */
  15568. export var colorPixelShader: {
  15569. name: string;
  15570. shader: string;
  15571. };
  15572. }
  15573. declare module BABYLON {
  15574. /** @hidden */
  15575. export var colorVertexShader: {
  15576. name: string;
  15577. shader: string;
  15578. };
  15579. }
  15580. declare module BABYLON {
  15581. /**
  15582. * Line mesh
  15583. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15584. */
  15585. export class LinesMesh extends Mesh {
  15586. /**
  15587. * If vertex color should be applied to the mesh
  15588. */
  15589. readonly useVertexColor?: boolean | undefined;
  15590. /**
  15591. * If vertex alpha should be applied to the mesh
  15592. */
  15593. readonly useVertexAlpha?: boolean | undefined;
  15594. /**
  15595. * Color of the line (Default: White)
  15596. */
  15597. color: Color3;
  15598. /**
  15599. * Alpha of the line (Default: 1)
  15600. */
  15601. alpha: number;
  15602. /**
  15603. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15604. * This margin is expressed in world space coordinates, so its value may vary.
  15605. * Default value is 0.1
  15606. */
  15607. intersectionThreshold: number;
  15608. private _colorShader;
  15609. private color4;
  15610. /**
  15611. * Creates a new LinesMesh
  15612. * @param name defines the name
  15613. * @param scene defines the hosting scene
  15614. * @param parent defines the parent mesh if any
  15615. * @param source defines the optional source LinesMesh used to clone data from
  15616. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15617. * When false, achieved by calling a clone(), also passing False.
  15618. * This will make creation of children, recursive.
  15619. * @param useVertexColor defines if this LinesMesh supports vertex color
  15620. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15621. */
  15622. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15623. /**
  15624. * If vertex color should be applied to the mesh
  15625. */
  15626. useVertexColor?: boolean | undefined,
  15627. /**
  15628. * If vertex alpha should be applied to the mesh
  15629. */
  15630. useVertexAlpha?: boolean | undefined);
  15631. private _addClipPlaneDefine;
  15632. private _removeClipPlaneDefine;
  15633. isReady(): boolean;
  15634. /**
  15635. * Returns the string "LineMesh"
  15636. */
  15637. getClassName(): string;
  15638. /**
  15639. * @hidden
  15640. */
  15641. get material(): Material;
  15642. /**
  15643. * @hidden
  15644. */
  15645. set material(value: Material);
  15646. /**
  15647. * @hidden
  15648. */
  15649. get checkCollisions(): boolean;
  15650. /** @hidden */
  15651. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15652. /** @hidden */
  15653. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15654. /**
  15655. * Disposes of the line mesh
  15656. * @param doNotRecurse If children should be disposed
  15657. */
  15658. dispose(doNotRecurse?: boolean): void;
  15659. /**
  15660. * Returns a new LineMesh object cloned from the current one.
  15661. */
  15662. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15663. /**
  15664. * Creates a new InstancedLinesMesh object from the mesh model.
  15665. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15666. * @param name defines the name of the new instance
  15667. * @returns a new InstancedLinesMesh
  15668. */
  15669. createInstance(name: string): InstancedLinesMesh;
  15670. }
  15671. /**
  15672. * Creates an instance based on a source LinesMesh
  15673. */
  15674. export class InstancedLinesMesh extends InstancedMesh {
  15675. /**
  15676. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15677. * This margin is expressed in world space coordinates, so its value may vary.
  15678. * Initilized with the intersectionThreshold value of the source LinesMesh
  15679. */
  15680. intersectionThreshold: number;
  15681. constructor(name: string, source: LinesMesh);
  15682. /**
  15683. * Returns the string "InstancedLinesMesh".
  15684. */
  15685. getClassName(): string;
  15686. }
  15687. }
  15688. declare module BABYLON {
  15689. /** @hidden */
  15690. export var linePixelShader: {
  15691. name: string;
  15692. shader: string;
  15693. };
  15694. }
  15695. declare module BABYLON {
  15696. /** @hidden */
  15697. export var lineVertexShader: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module BABYLON {
  15703. interface AbstractMesh {
  15704. /**
  15705. * Gets the edgesRenderer associated with the mesh
  15706. */
  15707. edgesRenderer: Nullable<EdgesRenderer>;
  15708. }
  15709. interface LinesMesh {
  15710. /**
  15711. * Enables the edge rendering mode on the mesh.
  15712. * This mode makes the mesh edges visible
  15713. * @param epsilon defines the maximal distance between two angles to detect a face
  15714. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15715. * @returns the currentAbstractMesh
  15716. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15717. */
  15718. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15719. }
  15720. interface InstancedLinesMesh {
  15721. /**
  15722. * Enables the edge rendering mode on the mesh.
  15723. * This mode makes the mesh edges visible
  15724. * @param epsilon defines the maximal distance between two angles to detect a face
  15725. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15726. * @returns the current InstancedLinesMesh
  15727. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15728. */
  15729. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15730. }
  15731. /**
  15732. * Defines the minimum contract an Edges renderer should follow.
  15733. */
  15734. export interface IEdgesRenderer extends IDisposable {
  15735. /**
  15736. * Gets or sets a boolean indicating if the edgesRenderer is active
  15737. */
  15738. isEnabled: boolean;
  15739. /**
  15740. * Renders the edges of the attached mesh,
  15741. */
  15742. render(): void;
  15743. /**
  15744. * Checks wether or not the edges renderer is ready to render.
  15745. * @return true if ready, otherwise false.
  15746. */
  15747. isReady(): boolean;
  15748. }
  15749. /**
  15750. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15751. */
  15752. export class EdgesRenderer implements IEdgesRenderer {
  15753. /**
  15754. * Define the size of the edges with an orthographic camera
  15755. */
  15756. edgesWidthScalerForOrthographic: number;
  15757. /**
  15758. * Define the size of the edges with a perspective camera
  15759. */
  15760. edgesWidthScalerForPerspective: number;
  15761. protected _source: AbstractMesh;
  15762. protected _linesPositions: number[];
  15763. protected _linesNormals: number[];
  15764. protected _linesIndices: number[];
  15765. protected _epsilon: number;
  15766. protected _indicesCount: number;
  15767. protected _lineShader: ShaderMaterial;
  15768. protected _ib: DataBuffer;
  15769. protected _buffers: {
  15770. [key: string]: Nullable<VertexBuffer>;
  15771. };
  15772. protected _checkVerticesInsteadOfIndices: boolean;
  15773. private _meshRebuildObserver;
  15774. private _meshDisposeObserver;
  15775. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15776. isEnabled: boolean;
  15777. /**
  15778. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15779. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15780. * @param source Mesh used to create edges
  15781. * @param epsilon sum of angles in adjacency to check for edge
  15782. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15783. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15784. */
  15785. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15786. protected _prepareRessources(): void;
  15787. /** @hidden */
  15788. _rebuild(): void;
  15789. /**
  15790. * Releases the required resources for the edges renderer
  15791. */
  15792. dispose(): void;
  15793. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15794. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15795. /**
  15796. * Checks if the pair of p0 and p1 is en edge
  15797. * @param faceIndex
  15798. * @param edge
  15799. * @param faceNormals
  15800. * @param p0
  15801. * @param p1
  15802. * @private
  15803. */
  15804. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15805. /**
  15806. * push line into the position, normal and index buffer
  15807. * @protected
  15808. */
  15809. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15810. /**
  15811. * Generates lines edges from adjacencjes
  15812. * @private
  15813. */
  15814. _generateEdgesLines(): void;
  15815. /**
  15816. * Checks wether or not the edges renderer is ready to render.
  15817. * @return true if ready, otherwise false.
  15818. */
  15819. isReady(): boolean;
  15820. /**
  15821. * Renders the edges of the attached mesh,
  15822. */
  15823. render(): void;
  15824. }
  15825. /**
  15826. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15827. */
  15828. export class LineEdgesRenderer extends EdgesRenderer {
  15829. /**
  15830. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15831. * @param source LineMesh used to generate edges
  15832. * @param epsilon not important (specified angle for edge detection)
  15833. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15834. */
  15835. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15836. /**
  15837. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15838. */
  15839. _generateEdgesLines(): void;
  15840. }
  15841. }
  15842. declare module BABYLON {
  15843. /**
  15844. * This represents the object necessary to create a rendering group.
  15845. * This is exclusively used and created by the rendering manager.
  15846. * To modify the behavior, you use the available helpers in your scene or meshes.
  15847. * @hidden
  15848. */
  15849. export class RenderingGroup {
  15850. index: number;
  15851. private static _zeroVector;
  15852. private _scene;
  15853. private _opaqueSubMeshes;
  15854. private _transparentSubMeshes;
  15855. private _alphaTestSubMeshes;
  15856. private _depthOnlySubMeshes;
  15857. private _particleSystems;
  15858. private _spriteManagers;
  15859. private _opaqueSortCompareFn;
  15860. private _alphaTestSortCompareFn;
  15861. private _transparentSortCompareFn;
  15862. private _renderOpaque;
  15863. private _renderAlphaTest;
  15864. private _renderTransparent;
  15865. /** @hidden */
  15866. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15867. onBeforeTransparentRendering: () => void;
  15868. /**
  15869. * Set the opaque sort comparison function.
  15870. * If null the sub meshes will be render in the order they were created
  15871. */
  15872. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15873. /**
  15874. * Set the alpha test sort comparison function.
  15875. * If null the sub meshes will be render in the order they were created
  15876. */
  15877. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15878. /**
  15879. * Set the transparent sort comparison function.
  15880. * If null the sub meshes will be render in the order they were created
  15881. */
  15882. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15883. /**
  15884. * Creates a new rendering group.
  15885. * @param index The rendering group index
  15886. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15887. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15888. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15889. */
  15890. 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>);
  15891. /**
  15892. * Render all the sub meshes contained in the group.
  15893. * @param customRenderFunction Used to override the default render behaviour of the group.
  15894. * @returns true if rendered some submeshes.
  15895. */
  15896. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15897. /**
  15898. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15899. * @param subMeshes The submeshes to render
  15900. */
  15901. private renderOpaqueSorted;
  15902. /**
  15903. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15904. * @param subMeshes The submeshes to render
  15905. */
  15906. private renderAlphaTestSorted;
  15907. /**
  15908. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15909. * @param subMeshes The submeshes to render
  15910. */
  15911. private renderTransparentSorted;
  15912. /**
  15913. * Renders the submeshes in a specified order.
  15914. * @param subMeshes The submeshes to sort before render
  15915. * @param sortCompareFn The comparison function use to sort
  15916. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15917. * @param transparent Specifies to activate blending if true
  15918. */
  15919. private static renderSorted;
  15920. /**
  15921. * Renders the submeshes in the order they were dispatched (no sort applied).
  15922. * @param subMeshes The submeshes to render
  15923. */
  15924. private static renderUnsorted;
  15925. /**
  15926. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15927. * are rendered back to front if in the same alpha index.
  15928. *
  15929. * @param a The first submesh
  15930. * @param b The second submesh
  15931. * @returns The result of the comparison
  15932. */
  15933. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15934. /**
  15935. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15936. * are rendered back to front.
  15937. *
  15938. * @param a The first submesh
  15939. * @param b The second submesh
  15940. * @returns The result of the comparison
  15941. */
  15942. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15943. /**
  15944. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15945. * are rendered front to back (prevent overdraw).
  15946. *
  15947. * @param a The first submesh
  15948. * @param b The second submesh
  15949. * @returns The result of the comparison
  15950. */
  15951. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15952. /**
  15953. * Resets the different lists of submeshes to prepare a new frame.
  15954. */
  15955. prepare(): void;
  15956. dispose(): void;
  15957. /**
  15958. * Inserts the submesh in its correct queue depending on its material.
  15959. * @param subMesh The submesh to dispatch
  15960. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15961. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15962. */
  15963. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15964. dispatchSprites(spriteManager: ISpriteManager): void;
  15965. dispatchParticles(particleSystem: IParticleSystem): void;
  15966. private _renderParticles;
  15967. private _renderSprites;
  15968. }
  15969. }
  15970. declare module BABYLON {
  15971. /**
  15972. * Interface describing the different options available in the rendering manager
  15973. * regarding Auto Clear between groups.
  15974. */
  15975. export interface IRenderingManagerAutoClearSetup {
  15976. /**
  15977. * Defines whether or not autoclear is enable.
  15978. */
  15979. autoClear: boolean;
  15980. /**
  15981. * Defines whether or not to autoclear the depth buffer.
  15982. */
  15983. depth: boolean;
  15984. /**
  15985. * Defines whether or not to autoclear the stencil buffer.
  15986. */
  15987. stencil: boolean;
  15988. }
  15989. /**
  15990. * This class is used by the onRenderingGroupObservable
  15991. */
  15992. export class RenderingGroupInfo {
  15993. /**
  15994. * The Scene that being rendered
  15995. */
  15996. scene: Scene;
  15997. /**
  15998. * The camera currently used for the rendering pass
  15999. */
  16000. camera: Nullable<Camera>;
  16001. /**
  16002. * The ID of the renderingGroup being processed
  16003. */
  16004. renderingGroupId: number;
  16005. }
  16006. /**
  16007. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16008. * It is enable to manage the different groups as well as the different necessary sort functions.
  16009. * This should not be used directly aside of the few static configurations
  16010. */
  16011. export class RenderingManager {
  16012. /**
  16013. * The max id used for rendering groups (not included)
  16014. */
  16015. static MAX_RENDERINGGROUPS: number;
  16016. /**
  16017. * The min id used for rendering groups (included)
  16018. */
  16019. static MIN_RENDERINGGROUPS: number;
  16020. /**
  16021. * Used to globally prevent autoclearing scenes.
  16022. */
  16023. static AUTOCLEAR: boolean;
  16024. /**
  16025. * @hidden
  16026. */
  16027. _useSceneAutoClearSetup: boolean;
  16028. private _scene;
  16029. private _renderingGroups;
  16030. private _depthStencilBufferAlreadyCleaned;
  16031. private _autoClearDepthStencil;
  16032. private _customOpaqueSortCompareFn;
  16033. private _customAlphaTestSortCompareFn;
  16034. private _customTransparentSortCompareFn;
  16035. private _renderingGroupInfo;
  16036. /**
  16037. * Instantiates a new rendering group for a particular scene
  16038. * @param scene Defines the scene the groups belongs to
  16039. */
  16040. constructor(scene: Scene);
  16041. private _clearDepthStencilBuffer;
  16042. /**
  16043. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16044. * @hidden
  16045. */
  16046. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16047. /**
  16048. * Resets the different information of the group to prepare a new frame
  16049. * @hidden
  16050. */
  16051. reset(): void;
  16052. /**
  16053. * Dispose and release the group and its associated resources.
  16054. * @hidden
  16055. */
  16056. dispose(): void;
  16057. /**
  16058. * Clear the info related to rendering groups preventing retention points during dispose.
  16059. */
  16060. freeRenderingGroups(): void;
  16061. private _prepareRenderingGroup;
  16062. /**
  16063. * Add a sprite manager to the rendering manager in order to render it this frame.
  16064. * @param spriteManager Define the sprite manager to render
  16065. */
  16066. dispatchSprites(spriteManager: ISpriteManager): void;
  16067. /**
  16068. * Add a particle system to the rendering manager in order to render it this frame.
  16069. * @param particleSystem Define the particle system to render
  16070. */
  16071. dispatchParticles(particleSystem: IParticleSystem): void;
  16072. /**
  16073. * Add a submesh to the manager in order to render it this frame
  16074. * @param subMesh The submesh to dispatch
  16075. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16076. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16077. */
  16078. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16079. /**
  16080. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16081. * This allowed control for front to back rendering or reversly depending of the special needs.
  16082. *
  16083. * @param renderingGroupId The rendering group id corresponding to its index
  16084. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16085. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16086. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16087. */
  16088. 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;
  16089. /**
  16090. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16091. *
  16092. * @param renderingGroupId The rendering group id corresponding to its index
  16093. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16094. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16095. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16096. */
  16097. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16098. /**
  16099. * Gets the current auto clear configuration for one rendering group of the rendering
  16100. * manager.
  16101. * @param index the rendering group index to get the information for
  16102. * @returns The auto clear setup for the requested rendering group
  16103. */
  16104. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16105. }
  16106. }
  16107. declare module BABYLON {
  16108. /**
  16109. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16110. */
  16111. export interface ICustomShaderOptions {
  16112. /**
  16113. * Gets or sets the custom shader name to use
  16114. */
  16115. shaderName: string;
  16116. /**
  16117. * The list of attribute names used in the shader
  16118. */
  16119. attributes?: string[];
  16120. /**
  16121. * The list of unifrom names used in the shader
  16122. */
  16123. uniforms?: string[];
  16124. /**
  16125. * The list of sampler names used in the shader
  16126. */
  16127. samplers?: string[];
  16128. /**
  16129. * The list of defines used in the shader
  16130. */
  16131. defines?: string[];
  16132. }
  16133. /**
  16134. * Interface to implement to create a shadow generator compatible with BJS.
  16135. */
  16136. export interface IShadowGenerator {
  16137. /**
  16138. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16139. * @returns The render target texture if present otherwise, null
  16140. */
  16141. getShadowMap(): Nullable<RenderTargetTexture>;
  16142. /**
  16143. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16144. * @param subMesh The submesh we want to render in the shadow map
  16145. * @param useInstances Defines wether will draw in the map using instances
  16146. * @returns true if ready otherwise, false
  16147. */
  16148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16149. /**
  16150. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16151. * @param defines Defines of the material we want to update
  16152. * @param lightIndex Index of the light in the enabled light list of the material
  16153. */
  16154. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16155. /**
  16156. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16157. * defined in the generator but impacting the effect).
  16158. * It implies the unifroms available on the materials are the standard BJS ones.
  16159. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16160. * @param effect The effect we are binfing the information for
  16161. */
  16162. bindShadowLight(lightIndex: string, effect: Effect): void;
  16163. /**
  16164. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16165. * (eq to shadow prjection matrix * light transform matrix)
  16166. * @returns The transform matrix used to create the shadow map
  16167. */
  16168. getTransformMatrix(): Matrix;
  16169. /**
  16170. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16171. * Cube and 2D textures for instance.
  16172. */
  16173. recreateShadowMap(): void;
  16174. /**
  16175. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16176. * @param onCompiled Callback triggered at the and of the effects compilation
  16177. * @param options Sets of optional options forcing the compilation with different modes
  16178. */
  16179. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16180. useInstances: boolean;
  16181. }>): void;
  16182. /**
  16183. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16184. * @param options Sets of optional options forcing the compilation with different modes
  16185. * @returns A promise that resolves when the compilation completes
  16186. */
  16187. forceCompilationAsync(options?: Partial<{
  16188. useInstances: boolean;
  16189. }>): Promise<void>;
  16190. /**
  16191. * Serializes the shadow generator setup to a json object.
  16192. * @returns The serialized JSON object
  16193. */
  16194. serialize(): any;
  16195. /**
  16196. * Disposes the Shadow map and related Textures and effects.
  16197. */
  16198. dispose(): void;
  16199. }
  16200. /**
  16201. * Default implementation IShadowGenerator.
  16202. * This is the main object responsible of generating shadows in the framework.
  16203. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16204. */
  16205. export class ShadowGenerator implements IShadowGenerator {
  16206. /**
  16207. * Name of the shadow generator class
  16208. */
  16209. static CLASSNAME: string;
  16210. /**
  16211. * Shadow generator mode None: no filtering applied.
  16212. */
  16213. static readonly FILTER_NONE: number;
  16214. /**
  16215. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16216. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16217. */
  16218. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16219. /**
  16220. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16221. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16222. */
  16223. static readonly FILTER_POISSONSAMPLING: number;
  16224. /**
  16225. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16226. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16227. */
  16228. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16229. /**
  16230. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16231. * edge artifacts on steep falloff.
  16232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16233. */
  16234. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16235. /**
  16236. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16237. * edge artifacts on steep falloff.
  16238. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16239. */
  16240. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16241. /**
  16242. * Shadow generator mode PCF: Percentage Closer Filtering
  16243. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16244. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16245. */
  16246. static readonly FILTER_PCF: number;
  16247. /**
  16248. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16249. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16250. * Contact Hardening
  16251. */
  16252. static readonly FILTER_PCSS: number;
  16253. /**
  16254. * Reserved for PCF and PCSS
  16255. * Highest Quality.
  16256. *
  16257. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16258. *
  16259. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16260. */
  16261. static readonly QUALITY_HIGH: number;
  16262. /**
  16263. * Reserved for PCF and PCSS
  16264. * Good tradeoff for quality/perf cross devices
  16265. *
  16266. * Execute PCF on a 3*3 kernel.
  16267. *
  16268. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16269. */
  16270. static readonly QUALITY_MEDIUM: number;
  16271. /**
  16272. * Reserved for PCF and PCSS
  16273. * The lowest quality but the fastest.
  16274. *
  16275. * Execute PCF on a 1*1 kernel.
  16276. *
  16277. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16278. */
  16279. static readonly QUALITY_LOW: number;
  16280. /** Gets or sets the custom shader name to use */
  16281. customShaderOptions: ICustomShaderOptions;
  16282. /**
  16283. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16284. */
  16285. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16286. /**
  16287. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16288. */
  16289. onAfterShadowMapRenderObservable: Observable<Effect>;
  16290. /**
  16291. * Observable triggered before a mesh is rendered in the shadow map.
  16292. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16293. */
  16294. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16295. /**
  16296. * Observable triggered after a mesh is rendered in the shadow map.
  16297. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16298. */
  16299. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16300. protected _bias: number;
  16301. /**
  16302. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16303. */
  16304. get bias(): number;
  16305. /**
  16306. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16307. */
  16308. set bias(bias: number);
  16309. protected _normalBias: number;
  16310. /**
  16311. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16312. */
  16313. get normalBias(): number;
  16314. /**
  16315. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16316. */
  16317. set normalBias(normalBias: number);
  16318. protected _blurBoxOffset: number;
  16319. /**
  16320. * Gets the blur box offset: offset applied during the blur pass.
  16321. * Only useful if useKernelBlur = false
  16322. */
  16323. get blurBoxOffset(): number;
  16324. /**
  16325. * Sets the blur box offset: offset applied during the blur pass.
  16326. * Only useful if useKernelBlur = false
  16327. */
  16328. set blurBoxOffset(value: number);
  16329. protected _blurScale: number;
  16330. /**
  16331. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16332. * 2 means half of the size.
  16333. */
  16334. get blurScale(): number;
  16335. /**
  16336. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16337. * 2 means half of the size.
  16338. */
  16339. set blurScale(value: number);
  16340. protected _blurKernel: number;
  16341. /**
  16342. * Gets the blur kernel: kernel size of the blur pass.
  16343. * Only useful if useKernelBlur = true
  16344. */
  16345. get blurKernel(): number;
  16346. /**
  16347. * Sets the blur kernel: kernel size of the blur pass.
  16348. * Only useful if useKernelBlur = true
  16349. */
  16350. set blurKernel(value: number);
  16351. protected _useKernelBlur: boolean;
  16352. /**
  16353. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16354. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16355. */
  16356. get useKernelBlur(): boolean;
  16357. /**
  16358. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16359. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16360. */
  16361. set useKernelBlur(value: boolean);
  16362. protected _depthScale: number;
  16363. /**
  16364. * Gets the depth scale used in ESM mode.
  16365. */
  16366. get depthScale(): number;
  16367. /**
  16368. * Sets the depth scale used in ESM mode.
  16369. * This can override the scale stored on the light.
  16370. */
  16371. set depthScale(value: number);
  16372. protected _validateFilter(filter: number): number;
  16373. protected _filter: number;
  16374. /**
  16375. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16376. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16377. */
  16378. get filter(): number;
  16379. /**
  16380. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16381. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16382. */
  16383. set filter(value: number);
  16384. /**
  16385. * Gets if the current filter is set to Poisson Sampling.
  16386. */
  16387. get usePoissonSampling(): boolean;
  16388. /**
  16389. * Sets the current filter to Poisson Sampling.
  16390. */
  16391. set usePoissonSampling(value: boolean);
  16392. /**
  16393. * Gets if the current filter is set to ESM.
  16394. */
  16395. get useExponentialShadowMap(): boolean;
  16396. /**
  16397. * Sets the current filter is to ESM.
  16398. */
  16399. set useExponentialShadowMap(value: boolean);
  16400. /**
  16401. * Gets if the current filter is set to filtered ESM.
  16402. */
  16403. get useBlurExponentialShadowMap(): boolean;
  16404. /**
  16405. * Gets if the current filter is set to filtered ESM.
  16406. */
  16407. set useBlurExponentialShadowMap(value: boolean);
  16408. /**
  16409. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16410. * exponential to prevent steep falloff artifacts).
  16411. */
  16412. get useCloseExponentialShadowMap(): boolean;
  16413. /**
  16414. * Sets the current filter to "close ESM" (using the inverse of the
  16415. * exponential to prevent steep falloff artifacts).
  16416. */
  16417. set useCloseExponentialShadowMap(value: boolean);
  16418. /**
  16419. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16420. * exponential to prevent steep falloff artifacts).
  16421. */
  16422. get useBlurCloseExponentialShadowMap(): boolean;
  16423. /**
  16424. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16425. * exponential to prevent steep falloff artifacts).
  16426. */
  16427. set useBlurCloseExponentialShadowMap(value: boolean);
  16428. /**
  16429. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16430. */
  16431. get usePercentageCloserFiltering(): boolean;
  16432. /**
  16433. * Sets the current filter to "PCF" (percentage closer filtering).
  16434. */
  16435. set usePercentageCloserFiltering(value: boolean);
  16436. protected _filteringQuality: number;
  16437. /**
  16438. * Gets the PCF or PCSS Quality.
  16439. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16440. */
  16441. get filteringQuality(): number;
  16442. /**
  16443. * Sets the PCF or PCSS Quality.
  16444. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16445. */
  16446. set filteringQuality(filteringQuality: number);
  16447. /**
  16448. * Gets if the current filter is set to "PCSS" (contact hardening).
  16449. */
  16450. get useContactHardeningShadow(): boolean;
  16451. /**
  16452. * Sets the current filter to "PCSS" (contact hardening).
  16453. */
  16454. set useContactHardeningShadow(value: boolean);
  16455. protected _contactHardeningLightSizeUVRatio: number;
  16456. /**
  16457. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16458. * Using a ratio helps keeping shape stability independently of the map size.
  16459. *
  16460. * It does not account for the light projection as it was having too much
  16461. * instability during the light setup or during light position changes.
  16462. *
  16463. * Only valid if useContactHardeningShadow is true.
  16464. */
  16465. get contactHardeningLightSizeUVRatio(): number;
  16466. /**
  16467. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16468. * Using a ratio helps keeping shape stability independently of the map size.
  16469. *
  16470. * It does not account for the light projection as it was having too much
  16471. * instability during the light setup or during light position changes.
  16472. *
  16473. * Only valid if useContactHardeningShadow is true.
  16474. */
  16475. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16476. protected _darkness: number;
  16477. /** Gets or sets the actual darkness of a shadow */
  16478. get darkness(): number;
  16479. set darkness(value: number);
  16480. /**
  16481. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16482. * 0 means strongest and 1 would means no shadow.
  16483. * @returns the darkness.
  16484. */
  16485. getDarkness(): number;
  16486. /**
  16487. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16488. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16489. * @returns the shadow generator allowing fluent coding.
  16490. */
  16491. setDarkness(darkness: number): ShadowGenerator;
  16492. protected _transparencyShadow: boolean;
  16493. /** Gets or sets the ability to have transparent shadow */
  16494. get transparencyShadow(): boolean;
  16495. set transparencyShadow(value: boolean);
  16496. /**
  16497. * Sets the ability to have transparent shadow (boolean).
  16498. * @param transparent True if transparent else False
  16499. * @returns the shadow generator allowing fluent coding
  16500. */
  16501. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16502. protected _shadowMap: Nullable<RenderTargetTexture>;
  16503. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16504. /**
  16505. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16506. * @returns The render target texture if present otherwise, null
  16507. */
  16508. getShadowMap(): Nullable<RenderTargetTexture>;
  16509. /**
  16510. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16511. * @returns The render target texture if the shadow map is present otherwise, null
  16512. */
  16513. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16514. /**
  16515. * Gets the class name of that object
  16516. * @returns "ShadowGenerator"
  16517. */
  16518. getClassName(): string;
  16519. /**
  16520. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16521. * @param mesh Mesh to add
  16522. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16523. * @returns the Shadow Generator itself
  16524. */
  16525. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16526. /**
  16527. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16528. * @param mesh Mesh to remove
  16529. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16530. * @returns the Shadow Generator itself
  16531. */
  16532. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16533. /**
  16534. * Controls the extent to which the shadows fade out at the edge of the frustum
  16535. */
  16536. frustumEdgeFalloff: number;
  16537. protected _light: IShadowLight;
  16538. /**
  16539. * Returns the associated light object.
  16540. * @returns the light generating the shadow
  16541. */
  16542. getLight(): IShadowLight;
  16543. /**
  16544. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16545. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16546. * It might on the other hand introduce peter panning.
  16547. */
  16548. forceBackFacesOnly: boolean;
  16549. protected _scene: Scene;
  16550. protected _lightDirection: Vector3;
  16551. protected _effect: Effect;
  16552. protected _viewMatrix: Matrix;
  16553. protected _projectionMatrix: Matrix;
  16554. protected _transformMatrix: Matrix;
  16555. protected _cachedPosition: Vector3;
  16556. protected _cachedDirection: Vector3;
  16557. protected _cachedDefines: string;
  16558. protected _currentRenderID: number;
  16559. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16560. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16561. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16562. protected _blurPostProcesses: PostProcess[];
  16563. protected _mapSize: number;
  16564. protected _currentFaceIndex: number;
  16565. protected _currentFaceIndexCache: number;
  16566. protected _textureType: number;
  16567. protected _defaultTextureMatrix: Matrix;
  16568. protected _storedUniqueId: Nullable<number>;
  16569. /** @hidden */
  16570. static _SceneComponentInitialization: (scene: Scene) => void;
  16571. /**
  16572. * Creates a ShadowGenerator object.
  16573. * A ShadowGenerator is the required tool to use the shadows.
  16574. * Each light casting shadows needs to use its own ShadowGenerator.
  16575. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16576. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16577. * @param light The light object generating the shadows.
  16578. * @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.
  16579. */
  16580. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16581. protected _initializeGenerator(): void;
  16582. protected _createTargetRenderTexture(): void;
  16583. protected _initializeShadowMap(): void;
  16584. protected _initializeBlurRTTAndPostProcesses(): void;
  16585. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16586. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16587. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16588. protected _applyFilterValues(): void;
  16589. /**
  16590. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16591. * @param onCompiled Callback triggered at the and of the effects compilation
  16592. * @param options Sets of optional options forcing the compilation with different modes
  16593. */
  16594. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16595. useInstances: boolean;
  16596. }>): void;
  16597. /**
  16598. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16599. * @param options Sets of optional options forcing the compilation with different modes
  16600. * @returns A promise that resolves when the compilation completes
  16601. */
  16602. forceCompilationAsync(options?: Partial<{
  16603. useInstances: boolean;
  16604. }>): Promise<void>;
  16605. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16606. /**
  16607. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16608. * @param subMesh The submesh we want to render in the shadow map
  16609. * @param useInstances Defines wether will draw in the map using instances
  16610. * @returns true if ready otherwise, false
  16611. */
  16612. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16613. /**
  16614. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16615. * @param defines Defines of the material we want to update
  16616. * @param lightIndex Index of the light in the enabled light list of the material
  16617. */
  16618. prepareDefines(defines: any, lightIndex: number): void;
  16619. /**
  16620. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16621. * defined in the generator but impacting the effect).
  16622. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16623. * @param effect The effect we are binfing the information for
  16624. */
  16625. bindShadowLight(lightIndex: string, effect: Effect): void;
  16626. /**
  16627. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16628. * (eq to shadow prjection matrix * light transform matrix)
  16629. * @returns The transform matrix used to create the shadow map
  16630. */
  16631. getTransformMatrix(): Matrix;
  16632. /**
  16633. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16634. * Cube and 2D textures for instance.
  16635. */
  16636. recreateShadowMap(): void;
  16637. protected _disposeBlurPostProcesses(): void;
  16638. protected _disposeRTTandPostProcesses(): void;
  16639. /**
  16640. * Disposes the ShadowGenerator.
  16641. * Returns nothing.
  16642. */
  16643. dispose(): void;
  16644. /**
  16645. * Serializes the shadow generator setup to a json object.
  16646. * @returns The serialized JSON object
  16647. */
  16648. serialize(): any;
  16649. /**
  16650. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16651. * @param parsedShadowGenerator The JSON object to parse
  16652. * @param scene The scene to create the shadow map for
  16653. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16654. * @returns The parsed shadow generator
  16655. */
  16656. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16657. }
  16658. }
  16659. declare module BABYLON {
  16660. /**
  16661. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16662. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16663. * 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.
  16664. */
  16665. export abstract class Light extends Node {
  16666. /**
  16667. * Falloff Default: light is falling off following the material specification:
  16668. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16669. */
  16670. static readonly FALLOFF_DEFAULT: number;
  16671. /**
  16672. * Falloff Physical: light is falling off following the inverse squared distance law.
  16673. */
  16674. static readonly FALLOFF_PHYSICAL: number;
  16675. /**
  16676. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16677. * to enhance interoperability with other engines.
  16678. */
  16679. static readonly FALLOFF_GLTF: number;
  16680. /**
  16681. * Falloff Standard: light is falling off like in the standard material
  16682. * to enhance interoperability with other materials.
  16683. */
  16684. static readonly FALLOFF_STANDARD: number;
  16685. /**
  16686. * If every light affecting the material is in this lightmapMode,
  16687. * material.lightmapTexture adds or multiplies
  16688. * (depends on material.useLightmapAsShadowmap)
  16689. * after every other light calculations.
  16690. */
  16691. static readonly LIGHTMAP_DEFAULT: number;
  16692. /**
  16693. * material.lightmapTexture as only diffuse lighting from this light
  16694. * adds only specular lighting from this light
  16695. * adds dynamic shadows
  16696. */
  16697. static readonly LIGHTMAP_SPECULAR: number;
  16698. /**
  16699. * material.lightmapTexture as only lighting
  16700. * no light calculation from this light
  16701. * only adds dynamic shadows from this light
  16702. */
  16703. static readonly LIGHTMAP_SHADOWSONLY: number;
  16704. /**
  16705. * Each light type uses the default quantity according to its type:
  16706. * point/spot lights use luminous intensity
  16707. * directional lights use illuminance
  16708. */
  16709. static readonly INTENSITYMODE_AUTOMATIC: number;
  16710. /**
  16711. * lumen (lm)
  16712. */
  16713. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16714. /**
  16715. * candela (lm/sr)
  16716. */
  16717. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16718. /**
  16719. * lux (lm/m^2)
  16720. */
  16721. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16722. /**
  16723. * nit (cd/m^2)
  16724. */
  16725. static readonly INTENSITYMODE_LUMINANCE: number;
  16726. /**
  16727. * Light type const id of the point light.
  16728. */
  16729. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16730. /**
  16731. * Light type const id of the directional light.
  16732. */
  16733. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16734. /**
  16735. * Light type const id of the spot light.
  16736. */
  16737. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16738. /**
  16739. * Light type const id of the hemispheric light.
  16740. */
  16741. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16742. /**
  16743. * Diffuse gives the basic color to an object.
  16744. */
  16745. diffuse: Color3;
  16746. /**
  16747. * Specular produces a highlight color on an object.
  16748. * Note: This is note affecting PBR materials.
  16749. */
  16750. specular: Color3;
  16751. /**
  16752. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16753. * falling off base on range or angle.
  16754. * This can be set to any values in Light.FALLOFF_x.
  16755. *
  16756. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16757. * other types of materials.
  16758. */
  16759. falloffType: number;
  16760. /**
  16761. * Strength of the light.
  16762. * Note: By default it is define in the framework own unit.
  16763. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16764. */
  16765. intensity: number;
  16766. private _range;
  16767. protected _inverseSquaredRange: number;
  16768. /**
  16769. * Defines how far from the source the light is impacting in scene units.
  16770. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16771. */
  16772. get range(): number;
  16773. /**
  16774. * Defines how far from the source the light is impacting in scene units.
  16775. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16776. */
  16777. set range(value: number);
  16778. /**
  16779. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16780. * of light.
  16781. */
  16782. private _photometricScale;
  16783. private _intensityMode;
  16784. /**
  16785. * Gets the photometric scale used to interpret the intensity.
  16786. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16787. */
  16788. get intensityMode(): number;
  16789. /**
  16790. * Sets the photometric scale used to interpret the intensity.
  16791. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16792. */
  16793. set intensityMode(value: number);
  16794. private _radius;
  16795. /**
  16796. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16797. */
  16798. get radius(): number;
  16799. /**
  16800. * sets the light radius used by PBR Materials to simulate soft area lights.
  16801. */
  16802. set radius(value: number);
  16803. private _renderPriority;
  16804. /**
  16805. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16806. * exceeding the number allowed of the materials.
  16807. */
  16808. renderPriority: number;
  16809. private _shadowEnabled;
  16810. /**
  16811. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16812. * the current shadow generator.
  16813. */
  16814. get shadowEnabled(): boolean;
  16815. /**
  16816. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16817. * the current shadow generator.
  16818. */
  16819. set shadowEnabled(value: boolean);
  16820. private _includedOnlyMeshes;
  16821. /**
  16822. * Gets the only meshes impacted by this light.
  16823. */
  16824. get includedOnlyMeshes(): AbstractMesh[];
  16825. /**
  16826. * Sets the only meshes impacted by this light.
  16827. */
  16828. set includedOnlyMeshes(value: AbstractMesh[]);
  16829. private _excludedMeshes;
  16830. /**
  16831. * Gets the meshes not impacted by this light.
  16832. */
  16833. get excludedMeshes(): AbstractMesh[];
  16834. /**
  16835. * Sets the meshes not impacted by this light.
  16836. */
  16837. set excludedMeshes(value: AbstractMesh[]);
  16838. private _excludeWithLayerMask;
  16839. /**
  16840. * Gets the layer id use to find what meshes are not impacted by the light.
  16841. * Inactive if 0
  16842. */
  16843. get excludeWithLayerMask(): number;
  16844. /**
  16845. * Sets the layer id use to find what meshes are not impacted by the light.
  16846. * Inactive if 0
  16847. */
  16848. set excludeWithLayerMask(value: number);
  16849. private _includeOnlyWithLayerMask;
  16850. /**
  16851. * Gets the layer id use to find what meshes are impacted by the light.
  16852. * Inactive if 0
  16853. */
  16854. get includeOnlyWithLayerMask(): number;
  16855. /**
  16856. * Sets the layer id use to find what meshes are impacted by the light.
  16857. * Inactive if 0
  16858. */
  16859. set includeOnlyWithLayerMask(value: number);
  16860. private _lightmapMode;
  16861. /**
  16862. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16863. */
  16864. get lightmapMode(): number;
  16865. /**
  16866. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16867. */
  16868. set lightmapMode(value: number);
  16869. /**
  16870. * Shadow generator associted to the light.
  16871. * @hidden Internal use only.
  16872. */
  16873. _shadowGenerator: Nullable<IShadowGenerator>;
  16874. /**
  16875. * @hidden Internal use only.
  16876. */
  16877. _excludedMeshesIds: string[];
  16878. /**
  16879. * @hidden Internal use only.
  16880. */
  16881. _includedOnlyMeshesIds: string[];
  16882. /**
  16883. * The current light unifom buffer.
  16884. * @hidden Internal use only.
  16885. */
  16886. _uniformBuffer: UniformBuffer;
  16887. /** @hidden */
  16888. _renderId: number;
  16889. /**
  16890. * Creates a Light object in the scene.
  16891. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16892. * @param name The firendly name of the light
  16893. * @param scene The scene the light belongs too
  16894. */
  16895. constructor(name: string, scene: Scene);
  16896. protected abstract _buildUniformLayout(): void;
  16897. /**
  16898. * Sets the passed Effect "effect" with the Light information.
  16899. * @param effect The effect to update
  16900. * @param lightIndex The index of the light in the effect to update
  16901. * @returns The light
  16902. */
  16903. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16904. /**
  16905. * Sets the passed Effect "effect" with the Light textures.
  16906. * @param effect The effect to update
  16907. * @param lightIndex The index of the light in the effect to update
  16908. * @returns The light
  16909. */
  16910. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16911. /**
  16912. * Binds the lights information from the scene to the effect for the given mesh.
  16913. * @param lightIndex Light index
  16914. * @param scene The scene where the light belongs to
  16915. * @param effect The effect we are binding the data to
  16916. * @param useSpecular Defines if specular is supported
  16917. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16918. */
  16919. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16920. /**
  16921. * Sets the passed Effect "effect" with the Light information.
  16922. * @param effect The effect to update
  16923. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16924. * @returns The light
  16925. */
  16926. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16927. /**
  16928. * Returns the string "Light".
  16929. * @returns the class name
  16930. */
  16931. getClassName(): string;
  16932. /** @hidden */
  16933. readonly _isLight: boolean;
  16934. /**
  16935. * Converts the light information to a readable string for debug purpose.
  16936. * @param fullDetails Supports for multiple levels of logging within scene loading
  16937. * @returns the human readable light info
  16938. */
  16939. toString(fullDetails?: boolean): string;
  16940. /** @hidden */
  16941. protected _syncParentEnabledState(): void;
  16942. /**
  16943. * Set the enabled state of this node.
  16944. * @param value - the new enabled state
  16945. */
  16946. setEnabled(value: boolean): void;
  16947. /**
  16948. * Returns the Light associated shadow generator if any.
  16949. * @return the associated shadow generator.
  16950. */
  16951. getShadowGenerator(): Nullable<IShadowGenerator>;
  16952. /**
  16953. * Returns a Vector3, the absolute light position in the World.
  16954. * @returns the world space position of the light
  16955. */
  16956. getAbsolutePosition(): Vector3;
  16957. /**
  16958. * Specifies if the light will affect the passed mesh.
  16959. * @param mesh The mesh to test against the light
  16960. * @return true the mesh is affected otherwise, false.
  16961. */
  16962. canAffectMesh(mesh: AbstractMesh): boolean;
  16963. /**
  16964. * Sort function to order lights for rendering.
  16965. * @param a First Light object to compare to second.
  16966. * @param b Second Light object to compare first.
  16967. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16968. */
  16969. static CompareLightsPriority(a: Light, b: Light): number;
  16970. /**
  16971. * Releases resources associated with this node.
  16972. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16973. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16974. */
  16975. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16976. /**
  16977. * Returns the light type ID (integer).
  16978. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16979. */
  16980. getTypeID(): number;
  16981. /**
  16982. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16983. * @returns the scaled intensity in intensity mode unit
  16984. */
  16985. getScaledIntensity(): number;
  16986. /**
  16987. * Returns a new Light object, named "name", from the current one.
  16988. * @param name The name of the cloned light
  16989. * @returns the new created light
  16990. */
  16991. clone(name: string): Nullable<Light>;
  16992. /**
  16993. * Serializes the current light into a Serialization object.
  16994. * @returns the serialized object.
  16995. */
  16996. serialize(): any;
  16997. /**
  16998. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16999. * This new light is named "name" and added to the passed scene.
  17000. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17001. * @param name The friendly name of the light
  17002. * @param scene The scene the new light will belong to
  17003. * @returns the constructor function
  17004. */
  17005. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17006. /**
  17007. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17008. * @param parsedLight The JSON representation of the light
  17009. * @param scene The scene to create the parsed light in
  17010. * @returns the created light after parsing
  17011. */
  17012. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17013. private _hookArrayForExcluded;
  17014. private _hookArrayForIncludedOnly;
  17015. private _resyncMeshes;
  17016. /**
  17017. * Forces the meshes to update their light related information in their rendering used effects
  17018. * @hidden Internal Use Only
  17019. */
  17020. _markMeshesAsLightDirty(): void;
  17021. /**
  17022. * Recomputes the cached photometric scale if needed.
  17023. */
  17024. private _computePhotometricScale;
  17025. /**
  17026. * Returns the Photometric Scale according to the light type and intensity mode.
  17027. */
  17028. private _getPhotometricScale;
  17029. /**
  17030. * Reorder the light in the scene according to their defined priority.
  17031. * @hidden Internal Use Only
  17032. */
  17033. _reorderLightsInScene(): void;
  17034. /**
  17035. * Prepares the list of defines specific to the light type.
  17036. * @param defines the list of defines
  17037. * @param lightIndex defines the index of the light for the effect
  17038. */
  17039. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17040. }
  17041. }
  17042. declare module BABYLON {
  17043. /**
  17044. * Interface used to define Action
  17045. */
  17046. export interface IAction {
  17047. /**
  17048. * Trigger for the action
  17049. */
  17050. trigger: number;
  17051. /** Options of the trigger */
  17052. triggerOptions: any;
  17053. /**
  17054. * Gets the trigger parameters
  17055. * @returns the trigger parameters
  17056. */
  17057. getTriggerParameter(): any;
  17058. /**
  17059. * Internal only - executes current action event
  17060. * @hidden
  17061. */
  17062. _executeCurrent(evt?: ActionEvent): void;
  17063. /**
  17064. * Serialize placeholder for child classes
  17065. * @param parent of child
  17066. * @returns the serialized object
  17067. */
  17068. serialize(parent: any): any;
  17069. /**
  17070. * Internal only
  17071. * @hidden
  17072. */
  17073. _prepare(): void;
  17074. /**
  17075. * Internal only - manager for action
  17076. * @hidden
  17077. */
  17078. _actionManager: AbstractActionManager;
  17079. /**
  17080. * Adds action to chain of actions, may be a DoNothingAction
  17081. * @param action defines the next action to execute
  17082. * @returns The action passed in
  17083. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17084. */
  17085. then(action: IAction): IAction;
  17086. }
  17087. /**
  17088. * The action to be carried out following a trigger
  17089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17090. */
  17091. export class Action implements IAction {
  17092. /** the trigger, with or without parameters, for the action */
  17093. triggerOptions: any;
  17094. /**
  17095. * Trigger for the action
  17096. */
  17097. trigger: number;
  17098. /**
  17099. * Internal only - manager for action
  17100. * @hidden
  17101. */
  17102. _actionManager: ActionManager;
  17103. private _nextActiveAction;
  17104. private _child;
  17105. private _condition?;
  17106. private _triggerParameter;
  17107. /**
  17108. * An event triggered prior to action being executed.
  17109. */
  17110. onBeforeExecuteObservable: Observable<Action>;
  17111. /**
  17112. * Creates a new Action
  17113. * @param triggerOptions the trigger, with or without parameters, for the action
  17114. * @param condition an optional determinant of action
  17115. */
  17116. constructor(
  17117. /** the trigger, with or without parameters, for the action */
  17118. triggerOptions: any, condition?: Condition);
  17119. /**
  17120. * Internal only
  17121. * @hidden
  17122. */
  17123. _prepare(): void;
  17124. /**
  17125. * Gets the trigger parameters
  17126. * @returns the trigger parameters
  17127. */
  17128. getTriggerParameter(): any;
  17129. /**
  17130. * Internal only - executes current action event
  17131. * @hidden
  17132. */
  17133. _executeCurrent(evt?: ActionEvent): void;
  17134. /**
  17135. * Execute placeholder for child classes
  17136. * @param evt optional action event
  17137. */
  17138. execute(evt?: ActionEvent): void;
  17139. /**
  17140. * Skips to next active action
  17141. */
  17142. skipToNextActiveAction(): void;
  17143. /**
  17144. * Adds action to chain of actions, may be a DoNothingAction
  17145. * @param action defines the next action to execute
  17146. * @returns The action passed in
  17147. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17148. */
  17149. then(action: Action): Action;
  17150. /**
  17151. * Internal only
  17152. * @hidden
  17153. */
  17154. _getProperty(propertyPath: string): string;
  17155. /**
  17156. * Internal only
  17157. * @hidden
  17158. */
  17159. _getEffectiveTarget(target: any, propertyPath: string): any;
  17160. /**
  17161. * Serialize placeholder for child classes
  17162. * @param parent of child
  17163. * @returns the serialized object
  17164. */
  17165. serialize(parent: any): any;
  17166. /**
  17167. * Internal only called by serialize
  17168. * @hidden
  17169. */
  17170. protected _serialize(serializedAction: any, parent?: any): any;
  17171. /**
  17172. * Internal only
  17173. * @hidden
  17174. */
  17175. static _SerializeValueAsString: (value: any) => string;
  17176. /**
  17177. * Internal only
  17178. * @hidden
  17179. */
  17180. static _GetTargetProperty: (target: Node | Scene) => {
  17181. name: string;
  17182. targetType: string;
  17183. value: string;
  17184. };
  17185. }
  17186. }
  17187. declare module BABYLON {
  17188. /**
  17189. * A Condition applied to an Action
  17190. */
  17191. export class Condition {
  17192. /**
  17193. * Internal only - manager for action
  17194. * @hidden
  17195. */
  17196. _actionManager: ActionManager;
  17197. /**
  17198. * Internal only
  17199. * @hidden
  17200. */
  17201. _evaluationId: number;
  17202. /**
  17203. * Internal only
  17204. * @hidden
  17205. */
  17206. _currentResult: boolean;
  17207. /**
  17208. * Creates a new Condition
  17209. * @param actionManager the manager of the action the condition is applied to
  17210. */
  17211. constructor(actionManager: ActionManager);
  17212. /**
  17213. * Check if the current condition is valid
  17214. * @returns a boolean
  17215. */
  17216. isValid(): boolean;
  17217. /**
  17218. * Internal only
  17219. * @hidden
  17220. */
  17221. _getProperty(propertyPath: string): string;
  17222. /**
  17223. * Internal only
  17224. * @hidden
  17225. */
  17226. _getEffectiveTarget(target: any, propertyPath: string): any;
  17227. /**
  17228. * Serialize placeholder for child classes
  17229. * @returns the serialized object
  17230. */
  17231. serialize(): any;
  17232. /**
  17233. * Internal only
  17234. * @hidden
  17235. */
  17236. protected _serialize(serializedCondition: any): any;
  17237. }
  17238. /**
  17239. * Defines specific conditional operators as extensions of Condition
  17240. */
  17241. export class ValueCondition extends Condition {
  17242. /** path to specify the property of the target the conditional operator uses */
  17243. propertyPath: string;
  17244. /** the value compared by the conditional operator against the current value of the property */
  17245. value: any;
  17246. /** the conditional operator, default ValueCondition.IsEqual */
  17247. operator: number;
  17248. /**
  17249. * Internal only
  17250. * @hidden
  17251. */
  17252. private static _IsEqual;
  17253. /**
  17254. * Internal only
  17255. * @hidden
  17256. */
  17257. private static _IsDifferent;
  17258. /**
  17259. * Internal only
  17260. * @hidden
  17261. */
  17262. private static _IsGreater;
  17263. /**
  17264. * Internal only
  17265. * @hidden
  17266. */
  17267. private static _IsLesser;
  17268. /**
  17269. * returns the number for IsEqual
  17270. */
  17271. static get IsEqual(): number;
  17272. /**
  17273. * Returns the number for IsDifferent
  17274. */
  17275. static get IsDifferent(): number;
  17276. /**
  17277. * Returns the number for IsGreater
  17278. */
  17279. static get IsGreater(): number;
  17280. /**
  17281. * Returns the number for IsLesser
  17282. */
  17283. static get IsLesser(): number;
  17284. /**
  17285. * Internal only The action manager for the condition
  17286. * @hidden
  17287. */
  17288. _actionManager: ActionManager;
  17289. /**
  17290. * Internal only
  17291. * @hidden
  17292. */
  17293. private _target;
  17294. /**
  17295. * Internal only
  17296. * @hidden
  17297. */
  17298. private _effectiveTarget;
  17299. /**
  17300. * Internal only
  17301. * @hidden
  17302. */
  17303. private _property;
  17304. /**
  17305. * Creates a new ValueCondition
  17306. * @param actionManager manager for the action the condition applies to
  17307. * @param target for the action
  17308. * @param propertyPath path to specify the property of the target the conditional operator uses
  17309. * @param value the value compared by the conditional operator against the current value of the property
  17310. * @param operator the conditional operator, default ValueCondition.IsEqual
  17311. */
  17312. constructor(actionManager: ActionManager, target: any,
  17313. /** path to specify the property of the target the conditional operator uses */
  17314. propertyPath: string,
  17315. /** the value compared by the conditional operator against the current value of the property */
  17316. value: any,
  17317. /** the conditional operator, default ValueCondition.IsEqual */
  17318. operator?: number);
  17319. /**
  17320. * Compares the given value with the property value for the specified conditional operator
  17321. * @returns the result of the comparison
  17322. */
  17323. isValid(): boolean;
  17324. /**
  17325. * Serialize the ValueCondition into a JSON compatible object
  17326. * @returns serialization object
  17327. */
  17328. serialize(): any;
  17329. /**
  17330. * Gets the name of the conditional operator for the ValueCondition
  17331. * @param operator the conditional operator
  17332. * @returns the name
  17333. */
  17334. static GetOperatorName(operator: number): string;
  17335. }
  17336. /**
  17337. * Defines a predicate condition as an extension of Condition
  17338. */
  17339. export class PredicateCondition extends Condition {
  17340. /** defines the predicate function used to validate the condition */
  17341. predicate: () => boolean;
  17342. /**
  17343. * Internal only - manager for action
  17344. * @hidden
  17345. */
  17346. _actionManager: ActionManager;
  17347. /**
  17348. * Creates a new PredicateCondition
  17349. * @param actionManager manager for the action the condition applies to
  17350. * @param predicate defines the predicate function used to validate the condition
  17351. */
  17352. constructor(actionManager: ActionManager,
  17353. /** defines the predicate function used to validate the condition */
  17354. predicate: () => boolean);
  17355. /**
  17356. * @returns the validity of the predicate condition
  17357. */
  17358. isValid(): boolean;
  17359. }
  17360. /**
  17361. * Defines a state condition as an extension of Condition
  17362. */
  17363. export class StateCondition extends Condition {
  17364. /** Value to compare with target state */
  17365. value: string;
  17366. /**
  17367. * Internal only - manager for action
  17368. * @hidden
  17369. */
  17370. _actionManager: ActionManager;
  17371. /**
  17372. * Internal only
  17373. * @hidden
  17374. */
  17375. private _target;
  17376. /**
  17377. * Creates a new StateCondition
  17378. * @param actionManager manager for the action the condition applies to
  17379. * @param target of the condition
  17380. * @param value to compare with target state
  17381. */
  17382. constructor(actionManager: ActionManager, target: any,
  17383. /** Value to compare with target state */
  17384. value: string);
  17385. /**
  17386. * Gets a boolean indicating if the current condition is met
  17387. * @returns the validity of the state
  17388. */
  17389. isValid(): boolean;
  17390. /**
  17391. * Serialize the StateCondition into a JSON compatible object
  17392. * @returns serialization object
  17393. */
  17394. serialize(): any;
  17395. }
  17396. }
  17397. declare module BABYLON {
  17398. /**
  17399. * This defines an action responsible to toggle a boolean once triggered.
  17400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17401. */
  17402. export class SwitchBooleanAction extends Action {
  17403. /**
  17404. * The path to the boolean property in the target object
  17405. */
  17406. propertyPath: string;
  17407. private _target;
  17408. private _effectiveTarget;
  17409. private _property;
  17410. /**
  17411. * Instantiate the action
  17412. * @param triggerOptions defines the trigger options
  17413. * @param target defines the object containing the boolean
  17414. * @param propertyPath defines the path to the boolean property in the target object
  17415. * @param condition defines the trigger related conditions
  17416. */
  17417. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17418. /** @hidden */
  17419. _prepare(): void;
  17420. /**
  17421. * Execute the action toggle the boolean value.
  17422. */
  17423. execute(): void;
  17424. /**
  17425. * Serializes the actions and its related information.
  17426. * @param parent defines the object to serialize in
  17427. * @returns the serialized object
  17428. */
  17429. serialize(parent: any): any;
  17430. }
  17431. /**
  17432. * This defines an action responsible to set a the state field of the target
  17433. * to a desired value once triggered.
  17434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17435. */
  17436. export class SetStateAction extends Action {
  17437. /**
  17438. * The value to store in the state field.
  17439. */
  17440. value: string;
  17441. private _target;
  17442. /**
  17443. * Instantiate the action
  17444. * @param triggerOptions defines the trigger options
  17445. * @param target defines the object containing the state property
  17446. * @param value defines the value to store in the state field
  17447. * @param condition defines the trigger related conditions
  17448. */
  17449. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17450. /**
  17451. * Execute the action and store the value on the target state property.
  17452. */
  17453. execute(): void;
  17454. /**
  17455. * Serializes the actions and its related information.
  17456. * @param parent defines the object to serialize in
  17457. * @returns the serialized object
  17458. */
  17459. serialize(parent: any): any;
  17460. }
  17461. /**
  17462. * This defines an action responsible to set a property of the target
  17463. * to a desired value once triggered.
  17464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17465. */
  17466. export class SetValueAction extends Action {
  17467. /**
  17468. * The path of the property to set in the target.
  17469. */
  17470. propertyPath: string;
  17471. /**
  17472. * The value to set in the property
  17473. */
  17474. value: any;
  17475. private _target;
  17476. private _effectiveTarget;
  17477. private _property;
  17478. /**
  17479. * Instantiate the action
  17480. * @param triggerOptions defines the trigger options
  17481. * @param target defines the object containing the property
  17482. * @param propertyPath defines the path of the property to set in the target
  17483. * @param value defines the value to set in the property
  17484. * @param condition defines the trigger related conditions
  17485. */
  17486. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17487. /** @hidden */
  17488. _prepare(): void;
  17489. /**
  17490. * Execute the action and set the targetted property to the desired value.
  17491. */
  17492. execute(): void;
  17493. /**
  17494. * Serializes the actions and its related information.
  17495. * @param parent defines the object to serialize in
  17496. * @returns the serialized object
  17497. */
  17498. serialize(parent: any): any;
  17499. }
  17500. /**
  17501. * This defines an action responsible to increment the target value
  17502. * to a desired value once triggered.
  17503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17504. */
  17505. export class IncrementValueAction extends Action {
  17506. /**
  17507. * The path of the property to increment in the target.
  17508. */
  17509. propertyPath: string;
  17510. /**
  17511. * The value we should increment the property by.
  17512. */
  17513. value: any;
  17514. private _target;
  17515. private _effectiveTarget;
  17516. private _property;
  17517. /**
  17518. * Instantiate the action
  17519. * @param triggerOptions defines the trigger options
  17520. * @param target defines the object containing the property
  17521. * @param propertyPath defines the path of the property to increment in the target
  17522. * @param value defines the value value we should increment the property by
  17523. * @param condition defines the trigger related conditions
  17524. */
  17525. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17526. /** @hidden */
  17527. _prepare(): void;
  17528. /**
  17529. * Execute the action and increment the target of the value amount.
  17530. */
  17531. execute(): void;
  17532. /**
  17533. * Serializes the actions and its related information.
  17534. * @param parent defines the object to serialize in
  17535. * @returns the serialized object
  17536. */
  17537. serialize(parent: any): any;
  17538. }
  17539. /**
  17540. * This defines an action responsible to start an animation once triggered.
  17541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17542. */
  17543. export class PlayAnimationAction extends Action {
  17544. /**
  17545. * Where the animation should start (animation frame)
  17546. */
  17547. from: number;
  17548. /**
  17549. * Where the animation should stop (animation frame)
  17550. */
  17551. to: number;
  17552. /**
  17553. * Define if the animation should loop or stop after the first play.
  17554. */
  17555. loop?: boolean;
  17556. private _target;
  17557. /**
  17558. * Instantiate the action
  17559. * @param triggerOptions defines the trigger options
  17560. * @param target defines the target animation or animation name
  17561. * @param from defines from where the animation should start (animation frame)
  17562. * @param end defines where the animation should stop (animation frame)
  17563. * @param loop defines if the animation should loop or stop after the first play
  17564. * @param condition defines the trigger related conditions
  17565. */
  17566. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17567. /** @hidden */
  17568. _prepare(): void;
  17569. /**
  17570. * Execute the action and play the animation.
  17571. */
  17572. execute(): void;
  17573. /**
  17574. * Serializes the actions and its related information.
  17575. * @param parent defines the object to serialize in
  17576. * @returns the serialized object
  17577. */
  17578. serialize(parent: any): any;
  17579. }
  17580. /**
  17581. * This defines an action responsible to stop an animation once triggered.
  17582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17583. */
  17584. export class StopAnimationAction extends Action {
  17585. private _target;
  17586. /**
  17587. * Instantiate the action
  17588. * @param triggerOptions defines the trigger options
  17589. * @param target defines the target animation or animation name
  17590. * @param condition defines the trigger related conditions
  17591. */
  17592. constructor(triggerOptions: any, target: any, condition?: Condition);
  17593. /** @hidden */
  17594. _prepare(): void;
  17595. /**
  17596. * Execute the action and stop the animation.
  17597. */
  17598. execute(): void;
  17599. /**
  17600. * Serializes the actions and its related information.
  17601. * @param parent defines the object to serialize in
  17602. * @returns the serialized object
  17603. */
  17604. serialize(parent: any): any;
  17605. }
  17606. /**
  17607. * This defines an action responsible that does nothing once triggered.
  17608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17609. */
  17610. export class DoNothingAction extends Action {
  17611. /**
  17612. * Instantiate the action
  17613. * @param triggerOptions defines the trigger options
  17614. * @param condition defines the trigger related conditions
  17615. */
  17616. constructor(triggerOptions?: any, condition?: Condition);
  17617. /**
  17618. * Execute the action and do nothing.
  17619. */
  17620. execute(): void;
  17621. /**
  17622. * Serializes the actions and its related information.
  17623. * @param parent defines the object to serialize in
  17624. * @returns the serialized object
  17625. */
  17626. serialize(parent: any): any;
  17627. }
  17628. /**
  17629. * This defines an action responsible to trigger several actions once triggered.
  17630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17631. */
  17632. export class CombineAction extends Action {
  17633. /**
  17634. * The list of aggregated animations to run.
  17635. */
  17636. children: Action[];
  17637. /**
  17638. * Instantiate the action
  17639. * @param triggerOptions defines the trigger options
  17640. * @param children defines the list of aggregated animations to run
  17641. * @param condition defines the trigger related conditions
  17642. */
  17643. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17644. /** @hidden */
  17645. _prepare(): void;
  17646. /**
  17647. * Execute the action and executes all the aggregated actions.
  17648. */
  17649. execute(evt: ActionEvent): void;
  17650. /**
  17651. * Serializes the actions and its related information.
  17652. * @param parent defines the object to serialize in
  17653. * @returns the serialized object
  17654. */
  17655. serialize(parent: any): any;
  17656. }
  17657. /**
  17658. * This defines an action responsible to run code (external event) once triggered.
  17659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17660. */
  17661. export class ExecuteCodeAction extends Action {
  17662. /**
  17663. * The callback function to run.
  17664. */
  17665. func: (evt: ActionEvent) => void;
  17666. /**
  17667. * Instantiate the action
  17668. * @param triggerOptions defines the trigger options
  17669. * @param func defines the callback function to run
  17670. * @param condition defines the trigger related conditions
  17671. */
  17672. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17673. /**
  17674. * Execute the action and run the attached code.
  17675. */
  17676. execute(evt: ActionEvent): void;
  17677. }
  17678. /**
  17679. * This defines an action responsible to set the parent property of the target once triggered.
  17680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17681. */
  17682. export class SetParentAction extends Action {
  17683. private _parent;
  17684. private _target;
  17685. /**
  17686. * Instantiate the action
  17687. * @param triggerOptions defines the trigger options
  17688. * @param target defines the target containing the parent property
  17689. * @param parent defines from where the animation should start (animation frame)
  17690. * @param condition defines the trigger related conditions
  17691. */
  17692. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17693. /** @hidden */
  17694. _prepare(): void;
  17695. /**
  17696. * Execute the action and set the parent property.
  17697. */
  17698. execute(): void;
  17699. /**
  17700. * Serializes the actions and its related information.
  17701. * @param parent defines the object to serialize in
  17702. * @returns the serialized object
  17703. */
  17704. serialize(parent: any): any;
  17705. }
  17706. }
  17707. declare module BABYLON {
  17708. /**
  17709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17712. */
  17713. export class ActionManager extends AbstractActionManager {
  17714. /**
  17715. * Nothing
  17716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17717. */
  17718. static readonly NothingTrigger: number;
  17719. /**
  17720. * On pick
  17721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17722. */
  17723. static readonly OnPickTrigger: number;
  17724. /**
  17725. * On left pick
  17726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17727. */
  17728. static readonly OnLeftPickTrigger: number;
  17729. /**
  17730. * On right pick
  17731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17732. */
  17733. static readonly OnRightPickTrigger: number;
  17734. /**
  17735. * On center pick
  17736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17737. */
  17738. static readonly OnCenterPickTrigger: number;
  17739. /**
  17740. * On pick down
  17741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17742. */
  17743. static readonly OnPickDownTrigger: number;
  17744. /**
  17745. * On double pick
  17746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17747. */
  17748. static readonly OnDoublePickTrigger: number;
  17749. /**
  17750. * On pick up
  17751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17752. */
  17753. static readonly OnPickUpTrigger: number;
  17754. /**
  17755. * On pick out.
  17756. * This trigger will only be raised if you also declared a OnPickDown
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17758. */
  17759. static readonly OnPickOutTrigger: number;
  17760. /**
  17761. * On long press
  17762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17763. */
  17764. static readonly OnLongPressTrigger: number;
  17765. /**
  17766. * On pointer over
  17767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17768. */
  17769. static readonly OnPointerOverTrigger: number;
  17770. /**
  17771. * On pointer out
  17772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17773. */
  17774. static readonly OnPointerOutTrigger: number;
  17775. /**
  17776. * On every frame
  17777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17778. */
  17779. static readonly OnEveryFrameTrigger: number;
  17780. /**
  17781. * On intersection enter
  17782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17783. */
  17784. static readonly OnIntersectionEnterTrigger: number;
  17785. /**
  17786. * On intersection exit
  17787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17788. */
  17789. static readonly OnIntersectionExitTrigger: number;
  17790. /**
  17791. * On key down
  17792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17793. */
  17794. static readonly OnKeyDownTrigger: number;
  17795. /**
  17796. * On key up
  17797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17798. */
  17799. static readonly OnKeyUpTrigger: number;
  17800. private _scene;
  17801. /**
  17802. * Creates a new action manager
  17803. * @param scene defines the hosting scene
  17804. */
  17805. constructor(scene: Scene);
  17806. /**
  17807. * Releases all associated resources
  17808. */
  17809. dispose(): void;
  17810. /**
  17811. * Gets hosting scene
  17812. * @returns the hosting scene
  17813. */
  17814. getScene(): Scene;
  17815. /**
  17816. * Does this action manager handles actions of any of the given triggers
  17817. * @param triggers defines the triggers to be tested
  17818. * @return a boolean indicating whether one (or more) of the triggers is handled
  17819. */
  17820. hasSpecificTriggers(triggers: number[]): boolean;
  17821. /**
  17822. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17823. * speed.
  17824. * @param triggerA defines the trigger to be tested
  17825. * @param triggerB defines the trigger to be tested
  17826. * @return a boolean indicating whether one (or more) of the triggers is handled
  17827. */
  17828. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17829. /**
  17830. * Does this action manager handles actions of a given trigger
  17831. * @param trigger defines the trigger to be tested
  17832. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17833. * @return whether the trigger is handled
  17834. */
  17835. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17836. /**
  17837. * Does this action manager has pointer triggers
  17838. */
  17839. get hasPointerTriggers(): boolean;
  17840. /**
  17841. * Does this action manager has pick triggers
  17842. */
  17843. get hasPickTriggers(): boolean;
  17844. /**
  17845. * Registers an action to this action manager
  17846. * @param action defines the action to be registered
  17847. * @return the action amended (prepared) after registration
  17848. */
  17849. registerAction(action: IAction): Nullable<IAction>;
  17850. /**
  17851. * Unregisters an action to this action manager
  17852. * @param action defines the action to be unregistered
  17853. * @return a boolean indicating whether the action has been unregistered
  17854. */
  17855. unregisterAction(action: IAction): Boolean;
  17856. /**
  17857. * Process a specific trigger
  17858. * @param trigger defines the trigger to process
  17859. * @param evt defines the event details to be processed
  17860. */
  17861. processTrigger(trigger: number, evt?: IActionEvent): void;
  17862. /** @hidden */
  17863. _getEffectiveTarget(target: any, propertyPath: string): any;
  17864. /** @hidden */
  17865. _getProperty(propertyPath: string): string;
  17866. /**
  17867. * Serialize this manager to a JSON object
  17868. * @param name defines the property name to store this manager
  17869. * @returns a JSON representation of this manager
  17870. */
  17871. serialize(name: string): any;
  17872. /**
  17873. * Creates a new ActionManager from a JSON data
  17874. * @param parsedActions defines the JSON data to read from
  17875. * @param object defines the hosting mesh
  17876. * @param scene defines the hosting scene
  17877. */
  17878. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17879. /**
  17880. * Get a trigger name by index
  17881. * @param trigger defines the trigger index
  17882. * @returns a trigger name
  17883. */
  17884. static GetTriggerName(trigger: number): string;
  17885. }
  17886. }
  17887. declare module BABYLON {
  17888. /**
  17889. * Class used to represent a sprite
  17890. * @see http://doc.babylonjs.com/babylon101/sprites
  17891. */
  17892. export class Sprite {
  17893. /** defines the name */
  17894. name: string;
  17895. /** Gets or sets the current world position */
  17896. position: Vector3;
  17897. /** Gets or sets the main color */
  17898. color: Color4;
  17899. /** Gets or sets the width */
  17900. width: number;
  17901. /** Gets or sets the height */
  17902. height: number;
  17903. /** Gets or sets rotation angle */
  17904. angle: number;
  17905. /** Gets or sets the cell index in the sprite sheet */
  17906. cellIndex: number;
  17907. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17908. cellRef: string;
  17909. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17910. invertU: number;
  17911. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17912. invertV: number;
  17913. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17914. disposeWhenFinishedAnimating: boolean;
  17915. /** Gets the list of attached animations */
  17916. animations: Animation[];
  17917. /** Gets or sets a boolean indicating if the sprite can be picked */
  17918. isPickable: boolean;
  17919. /**
  17920. * Gets or sets the associated action manager
  17921. */
  17922. actionManager: Nullable<ActionManager>;
  17923. private _animationStarted;
  17924. private _loopAnimation;
  17925. private _fromIndex;
  17926. private _toIndex;
  17927. private _delay;
  17928. private _direction;
  17929. private _manager;
  17930. private _time;
  17931. private _onAnimationEnd;
  17932. /**
  17933. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17934. */
  17935. isVisible: boolean;
  17936. /**
  17937. * Gets or sets the sprite size
  17938. */
  17939. get size(): number;
  17940. set size(value: number);
  17941. /**
  17942. * Creates a new Sprite
  17943. * @param name defines the name
  17944. * @param manager defines the manager
  17945. */
  17946. constructor(
  17947. /** defines the name */
  17948. name: string, manager: ISpriteManager);
  17949. /**
  17950. * Starts an animation
  17951. * @param from defines the initial key
  17952. * @param to defines the end key
  17953. * @param loop defines if the animation must loop
  17954. * @param delay defines the start delay (in ms)
  17955. * @param onAnimationEnd defines a callback to call when animation ends
  17956. */
  17957. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17958. /** Stops current animation (if any) */
  17959. stopAnimation(): void;
  17960. /** @hidden */
  17961. _animate(deltaTime: number): void;
  17962. /** Release associated resources */
  17963. dispose(): void;
  17964. }
  17965. }
  17966. declare module BABYLON {
  17967. /**
  17968. * Information about the result of picking within a scene
  17969. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17970. */
  17971. export class PickingInfo {
  17972. /** @hidden */
  17973. _pickingUnavailable: boolean;
  17974. /**
  17975. * If the pick collided with an object
  17976. */
  17977. hit: boolean;
  17978. /**
  17979. * Distance away where the pick collided
  17980. */
  17981. distance: number;
  17982. /**
  17983. * The location of pick collision
  17984. */
  17985. pickedPoint: Nullable<Vector3>;
  17986. /**
  17987. * The mesh corresponding the the pick collision
  17988. */
  17989. pickedMesh: Nullable<AbstractMesh>;
  17990. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17991. bu: number;
  17992. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17993. bv: number;
  17994. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17995. faceId: number;
  17996. /** Id of the the submesh that was picked */
  17997. subMeshId: number;
  17998. /** If a sprite was picked, this will be the sprite the pick collided with */
  17999. pickedSprite: Nullable<Sprite>;
  18000. /**
  18001. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18002. */
  18003. originMesh: Nullable<AbstractMesh>;
  18004. /**
  18005. * The ray that was used to perform the picking.
  18006. */
  18007. ray: Nullable<Ray>;
  18008. /**
  18009. * Gets the normal correspodning to the face the pick collided with
  18010. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18011. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18012. * @returns The normal correspodning to the face the pick collided with
  18013. */
  18014. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18015. /**
  18016. * Gets the texture coordinates of where the pick occured
  18017. * @returns the vector containing the coordnates of the texture
  18018. */
  18019. getTextureCoordinates(): Nullable<Vector2>;
  18020. }
  18021. }
  18022. declare module BABYLON {
  18023. /**
  18024. * Gather the list of pointer event types as constants.
  18025. */
  18026. export class PointerEventTypes {
  18027. /**
  18028. * 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.
  18029. */
  18030. static readonly POINTERDOWN: number;
  18031. /**
  18032. * The pointerup event is fired when a pointer is no longer active.
  18033. */
  18034. static readonly POINTERUP: number;
  18035. /**
  18036. * The pointermove event is fired when a pointer changes coordinates.
  18037. */
  18038. static readonly POINTERMOVE: number;
  18039. /**
  18040. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18041. */
  18042. static readonly POINTERWHEEL: number;
  18043. /**
  18044. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18045. */
  18046. static readonly POINTERPICK: number;
  18047. /**
  18048. * The pointertap event is fired when a the object has been touched and released without drag.
  18049. */
  18050. static readonly POINTERTAP: number;
  18051. /**
  18052. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18053. */
  18054. static readonly POINTERDOUBLETAP: number;
  18055. }
  18056. /**
  18057. * Base class of pointer info types.
  18058. */
  18059. export class PointerInfoBase {
  18060. /**
  18061. * Defines the type of event (PointerEventTypes)
  18062. */
  18063. type: number;
  18064. /**
  18065. * Defines the related dom event
  18066. */
  18067. event: PointerEvent | MouseWheelEvent;
  18068. /**
  18069. * Instantiates the base class of pointers info.
  18070. * @param type Defines the type of event (PointerEventTypes)
  18071. * @param event Defines the related dom event
  18072. */
  18073. constructor(
  18074. /**
  18075. * Defines the type of event (PointerEventTypes)
  18076. */
  18077. type: number,
  18078. /**
  18079. * Defines the related dom event
  18080. */
  18081. event: PointerEvent | MouseWheelEvent);
  18082. }
  18083. /**
  18084. * This class is used to store pointer related info for the onPrePointerObservable event.
  18085. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18086. */
  18087. export class PointerInfoPre extends PointerInfoBase {
  18088. /**
  18089. * Ray from a pointer if availible (eg. 6dof controller)
  18090. */
  18091. ray: Nullable<Ray>;
  18092. /**
  18093. * Defines the local position of the pointer on the canvas.
  18094. */
  18095. localPosition: Vector2;
  18096. /**
  18097. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18098. */
  18099. skipOnPointerObservable: boolean;
  18100. /**
  18101. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18102. * @param type Defines the type of event (PointerEventTypes)
  18103. * @param event Defines the related dom event
  18104. * @param localX Defines the local x coordinates of the pointer when the event occured
  18105. * @param localY Defines the local y coordinates of the pointer when the event occured
  18106. */
  18107. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18108. }
  18109. /**
  18110. * This type contains all the data related to a pointer event in Babylon.js.
  18111. * 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.
  18112. */
  18113. export class PointerInfo extends PointerInfoBase {
  18114. /**
  18115. * Defines the picking info associated to the info (if any)\
  18116. */
  18117. pickInfo: Nullable<PickingInfo>;
  18118. /**
  18119. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18120. * @param type Defines the type of event (PointerEventTypes)
  18121. * @param event Defines the related dom event
  18122. * @param pickInfo Defines the picking info associated to the info (if any)\
  18123. */
  18124. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18125. /**
  18126. * Defines the picking info associated to the info (if any)\
  18127. */
  18128. pickInfo: Nullable<PickingInfo>);
  18129. }
  18130. /**
  18131. * Data relating to a touch event on the screen.
  18132. */
  18133. export interface PointerTouch {
  18134. /**
  18135. * X coordinate of touch.
  18136. */
  18137. x: number;
  18138. /**
  18139. * Y coordinate of touch.
  18140. */
  18141. y: number;
  18142. /**
  18143. * Id of touch. Unique for each finger.
  18144. */
  18145. pointerId: number;
  18146. /**
  18147. * Event type passed from DOM.
  18148. */
  18149. type: any;
  18150. }
  18151. }
  18152. declare module BABYLON {
  18153. /**
  18154. * Manage the mouse inputs to control the movement of a free camera.
  18155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18156. */
  18157. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18158. /**
  18159. * Define if touch is enabled in the mouse input
  18160. */
  18161. touchEnabled: boolean;
  18162. /**
  18163. * Defines the camera the input is attached to.
  18164. */
  18165. camera: FreeCamera;
  18166. /**
  18167. * Defines the buttons associated with the input to handle camera move.
  18168. */
  18169. buttons: number[];
  18170. /**
  18171. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18172. */
  18173. angularSensibility: number;
  18174. private _pointerInput;
  18175. private _onMouseMove;
  18176. private _observer;
  18177. private previousPosition;
  18178. /**
  18179. * Observable for when a pointer move event occurs containing the move offset
  18180. */
  18181. onPointerMovedObservable: Observable<{
  18182. offsetX: number;
  18183. offsetY: number;
  18184. }>;
  18185. /**
  18186. * @hidden
  18187. * If the camera should be rotated automatically based on pointer movement
  18188. */
  18189. _allowCameraRotation: boolean;
  18190. /**
  18191. * Manage the mouse inputs to control the movement of a free camera.
  18192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18193. * @param touchEnabled Defines if touch is enabled or not
  18194. */
  18195. constructor(
  18196. /**
  18197. * Define if touch is enabled in the mouse input
  18198. */
  18199. touchEnabled?: boolean);
  18200. /**
  18201. * Attach the input controls to a specific dom element to get the input from.
  18202. * @param element Defines the element the controls should be listened from
  18203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18204. */
  18205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18206. /**
  18207. * Called on JS contextmenu event.
  18208. * Override this method to provide functionality.
  18209. */
  18210. protected onContextMenu(evt: PointerEvent): void;
  18211. /**
  18212. * Detach the current controls from the specified dom element.
  18213. * @param element Defines the element to stop listening the inputs from
  18214. */
  18215. detachControl(element: Nullable<HTMLElement>): void;
  18216. /**
  18217. * Gets the class name of the current intput.
  18218. * @returns the class name
  18219. */
  18220. getClassName(): string;
  18221. /**
  18222. * Get the friendly name associated with the input class.
  18223. * @returns the input friendly name
  18224. */
  18225. getSimpleName(): string;
  18226. }
  18227. }
  18228. declare module BABYLON {
  18229. /**
  18230. * Manage the touch inputs to control the movement of a free camera.
  18231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18232. */
  18233. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18234. /**
  18235. * Defines the camera the input is attached to.
  18236. */
  18237. camera: FreeCamera;
  18238. /**
  18239. * Defines the touch sensibility for rotation.
  18240. * The higher the faster.
  18241. */
  18242. touchAngularSensibility: number;
  18243. /**
  18244. * Defines the touch sensibility for move.
  18245. * The higher the faster.
  18246. */
  18247. touchMoveSensibility: number;
  18248. private _offsetX;
  18249. private _offsetY;
  18250. private _pointerPressed;
  18251. private _pointerInput;
  18252. private _observer;
  18253. private _onLostFocus;
  18254. /**
  18255. * Attach the input controls to a specific dom element to get the input from.
  18256. * @param element Defines the element the controls should be listened from
  18257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18258. */
  18259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18260. /**
  18261. * Detach the current controls from the specified dom element.
  18262. * @param element Defines the element to stop listening the inputs from
  18263. */
  18264. detachControl(element: Nullable<HTMLElement>): void;
  18265. /**
  18266. * Update the current camera state depending on the inputs that have been used this frame.
  18267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18268. */
  18269. checkInputs(): void;
  18270. /**
  18271. * Gets the class name of the current intput.
  18272. * @returns the class name
  18273. */
  18274. getClassName(): string;
  18275. /**
  18276. * Get the friendly name associated with the input class.
  18277. * @returns the input friendly name
  18278. */
  18279. getSimpleName(): string;
  18280. }
  18281. }
  18282. declare module BABYLON {
  18283. /**
  18284. * Default Inputs manager for the FreeCamera.
  18285. * It groups all the default supported inputs for ease of use.
  18286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18287. */
  18288. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18289. /**
  18290. * @hidden
  18291. */
  18292. _mouseInput: Nullable<FreeCameraMouseInput>;
  18293. /**
  18294. * Instantiates a new FreeCameraInputsManager.
  18295. * @param camera Defines the camera the inputs belong to
  18296. */
  18297. constructor(camera: FreeCamera);
  18298. /**
  18299. * Add keyboard input support to the input manager.
  18300. * @returns the current input manager
  18301. */
  18302. addKeyboard(): FreeCameraInputsManager;
  18303. /**
  18304. * Add mouse input support to the input manager.
  18305. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18306. * @returns the current input manager
  18307. */
  18308. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18309. /**
  18310. * Removes the mouse input support from the manager
  18311. * @returns the current input manager
  18312. */
  18313. removeMouse(): FreeCameraInputsManager;
  18314. /**
  18315. * Add touch input support to the input manager.
  18316. * @returns the current input manager
  18317. */
  18318. addTouch(): FreeCameraInputsManager;
  18319. /**
  18320. * Remove all attached input methods from a camera
  18321. */
  18322. clear(): void;
  18323. }
  18324. }
  18325. declare module BABYLON {
  18326. /**
  18327. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18328. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18329. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18330. */
  18331. export class FreeCamera extends TargetCamera {
  18332. /**
  18333. * Define the collision ellipsoid of the camera.
  18334. * This is helpful to simulate a camera body like the player body around the camera
  18335. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18336. */
  18337. ellipsoid: Vector3;
  18338. /**
  18339. * Define an offset for the position of the ellipsoid around the camera.
  18340. * This can be helpful to determine the center of the body near the gravity center of the body
  18341. * instead of its head.
  18342. */
  18343. ellipsoidOffset: Vector3;
  18344. /**
  18345. * Enable or disable collisions of the camera with the rest of the scene objects.
  18346. */
  18347. checkCollisions: boolean;
  18348. /**
  18349. * Enable or disable gravity on the camera.
  18350. */
  18351. applyGravity: boolean;
  18352. /**
  18353. * Define the input manager associated to the camera.
  18354. */
  18355. inputs: FreeCameraInputsManager;
  18356. /**
  18357. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18358. * Higher values reduce sensitivity.
  18359. */
  18360. get angularSensibility(): number;
  18361. /**
  18362. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18363. * Higher values reduce sensitivity.
  18364. */
  18365. set angularSensibility(value: number);
  18366. /**
  18367. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18368. */
  18369. get keysUp(): number[];
  18370. set keysUp(value: number[]);
  18371. /**
  18372. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18373. */
  18374. get keysDown(): number[];
  18375. set keysDown(value: number[]);
  18376. /**
  18377. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18378. */
  18379. get keysLeft(): number[];
  18380. set keysLeft(value: number[]);
  18381. /**
  18382. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18383. */
  18384. get keysRight(): number[];
  18385. set keysRight(value: number[]);
  18386. /**
  18387. * Event raised when the camera collide with a mesh in the scene.
  18388. */
  18389. onCollide: (collidedMesh: AbstractMesh) => void;
  18390. private _collider;
  18391. private _needMoveForGravity;
  18392. private _oldPosition;
  18393. private _diffPosition;
  18394. private _newPosition;
  18395. /** @hidden */
  18396. _localDirection: Vector3;
  18397. /** @hidden */
  18398. _transformedDirection: Vector3;
  18399. /**
  18400. * Instantiates a Free Camera.
  18401. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18402. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18403. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18404. * @param name Define the name of the camera in the scene
  18405. * @param position Define the start position of the camera in the scene
  18406. * @param scene Define the scene the camera belongs to
  18407. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18408. */
  18409. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18410. /**
  18411. * Attached controls to the current camera.
  18412. * @param element Defines the element the controls should be listened from
  18413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18414. */
  18415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18416. /**
  18417. * Detach the current controls from the camera.
  18418. * The camera will stop reacting to inputs.
  18419. * @param element Defines the element to stop listening the inputs from
  18420. */
  18421. detachControl(element: HTMLElement): void;
  18422. private _collisionMask;
  18423. /**
  18424. * Define a collision mask to limit the list of object the camera can collide with
  18425. */
  18426. get collisionMask(): number;
  18427. set collisionMask(mask: number);
  18428. /** @hidden */
  18429. _collideWithWorld(displacement: Vector3): void;
  18430. private _onCollisionPositionChange;
  18431. /** @hidden */
  18432. _checkInputs(): void;
  18433. /** @hidden */
  18434. _decideIfNeedsToMove(): boolean;
  18435. /** @hidden */
  18436. _updatePosition(): void;
  18437. /**
  18438. * Destroy the camera and release the current resources hold by it.
  18439. */
  18440. dispose(): void;
  18441. /**
  18442. * Gets the current object class name.
  18443. * @return the class name
  18444. */
  18445. getClassName(): string;
  18446. }
  18447. }
  18448. declare module BABYLON {
  18449. /**
  18450. * Represents a gamepad control stick position
  18451. */
  18452. export class StickValues {
  18453. /**
  18454. * The x component of the control stick
  18455. */
  18456. x: number;
  18457. /**
  18458. * The y component of the control stick
  18459. */
  18460. y: number;
  18461. /**
  18462. * Initializes the gamepad x and y control stick values
  18463. * @param x The x component of the gamepad control stick value
  18464. * @param y The y component of the gamepad control stick value
  18465. */
  18466. constructor(
  18467. /**
  18468. * The x component of the control stick
  18469. */
  18470. x: number,
  18471. /**
  18472. * The y component of the control stick
  18473. */
  18474. y: number);
  18475. }
  18476. /**
  18477. * An interface which manages callbacks for gamepad button changes
  18478. */
  18479. export interface GamepadButtonChanges {
  18480. /**
  18481. * Called when a gamepad has been changed
  18482. */
  18483. changed: boolean;
  18484. /**
  18485. * Called when a gamepad press event has been triggered
  18486. */
  18487. pressChanged: boolean;
  18488. /**
  18489. * Called when a touch event has been triggered
  18490. */
  18491. touchChanged: boolean;
  18492. /**
  18493. * Called when a value has changed
  18494. */
  18495. valueChanged: boolean;
  18496. }
  18497. /**
  18498. * Represents a gamepad
  18499. */
  18500. export class Gamepad {
  18501. /**
  18502. * The id of the gamepad
  18503. */
  18504. id: string;
  18505. /**
  18506. * The index of the gamepad
  18507. */
  18508. index: number;
  18509. /**
  18510. * The browser gamepad
  18511. */
  18512. browserGamepad: any;
  18513. /**
  18514. * Specifies what type of gamepad this represents
  18515. */
  18516. type: number;
  18517. private _leftStick;
  18518. private _rightStick;
  18519. /** @hidden */
  18520. _isConnected: boolean;
  18521. private _leftStickAxisX;
  18522. private _leftStickAxisY;
  18523. private _rightStickAxisX;
  18524. private _rightStickAxisY;
  18525. /**
  18526. * Triggered when the left control stick has been changed
  18527. */
  18528. private _onleftstickchanged;
  18529. /**
  18530. * Triggered when the right control stick has been changed
  18531. */
  18532. private _onrightstickchanged;
  18533. /**
  18534. * Represents a gamepad controller
  18535. */
  18536. static GAMEPAD: number;
  18537. /**
  18538. * Represents a generic controller
  18539. */
  18540. static GENERIC: number;
  18541. /**
  18542. * Represents an XBox controller
  18543. */
  18544. static XBOX: number;
  18545. /**
  18546. * Represents a pose-enabled controller
  18547. */
  18548. static POSE_ENABLED: number;
  18549. /**
  18550. * Represents an Dual Shock controller
  18551. */
  18552. static DUALSHOCK: number;
  18553. /**
  18554. * Specifies whether the left control stick should be Y-inverted
  18555. */
  18556. protected _invertLeftStickY: boolean;
  18557. /**
  18558. * Specifies if the gamepad has been connected
  18559. */
  18560. get isConnected(): boolean;
  18561. /**
  18562. * Initializes the gamepad
  18563. * @param id The id of the gamepad
  18564. * @param index The index of the gamepad
  18565. * @param browserGamepad The browser gamepad
  18566. * @param leftStickX The x component of the left joystick
  18567. * @param leftStickY The y component of the left joystick
  18568. * @param rightStickX The x component of the right joystick
  18569. * @param rightStickY The y component of the right joystick
  18570. */
  18571. constructor(
  18572. /**
  18573. * The id of the gamepad
  18574. */
  18575. id: string,
  18576. /**
  18577. * The index of the gamepad
  18578. */
  18579. index: number,
  18580. /**
  18581. * The browser gamepad
  18582. */
  18583. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18584. /**
  18585. * Callback triggered when the left joystick has changed
  18586. * @param callback
  18587. */
  18588. onleftstickchanged(callback: (values: StickValues) => void): void;
  18589. /**
  18590. * Callback triggered when the right joystick has changed
  18591. * @param callback
  18592. */
  18593. onrightstickchanged(callback: (values: StickValues) => void): void;
  18594. /**
  18595. * Gets the left joystick
  18596. */
  18597. get leftStick(): StickValues;
  18598. /**
  18599. * Sets the left joystick values
  18600. */
  18601. set leftStick(newValues: StickValues);
  18602. /**
  18603. * Gets the right joystick
  18604. */
  18605. get rightStick(): StickValues;
  18606. /**
  18607. * Sets the right joystick value
  18608. */
  18609. set rightStick(newValues: StickValues);
  18610. /**
  18611. * Updates the gamepad joystick positions
  18612. */
  18613. update(): void;
  18614. /**
  18615. * Disposes the gamepad
  18616. */
  18617. dispose(): void;
  18618. }
  18619. /**
  18620. * Represents a generic gamepad
  18621. */
  18622. export class GenericPad extends Gamepad {
  18623. private _buttons;
  18624. private _onbuttondown;
  18625. private _onbuttonup;
  18626. /**
  18627. * Observable triggered when a button has been pressed
  18628. */
  18629. onButtonDownObservable: Observable<number>;
  18630. /**
  18631. * Observable triggered when a button has been released
  18632. */
  18633. onButtonUpObservable: Observable<number>;
  18634. /**
  18635. * Callback triggered when a button has been pressed
  18636. * @param callback Called when a button has been pressed
  18637. */
  18638. onbuttondown(callback: (buttonPressed: number) => void): void;
  18639. /**
  18640. * Callback triggered when a button has been released
  18641. * @param callback Called when a button has been released
  18642. */
  18643. onbuttonup(callback: (buttonReleased: number) => void): void;
  18644. /**
  18645. * Initializes the generic gamepad
  18646. * @param id The id of the generic gamepad
  18647. * @param index The index of the generic gamepad
  18648. * @param browserGamepad The browser gamepad
  18649. */
  18650. constructor(id: string, index: number, browserGamepad: any);
  18651. private _setButtonValue;
  18652. /**
  18653. * Updates the generic gamepad
  18654. */
  18655. update(): void;
  18656. /**
  18657. * Disposes the generic gamepad
  18658. */
  18659. dispose(): void;
  18660. }
  18661. }
  18662. declare module BABYLON {
  18663. /**
  18664. * Defines the types of pose enabled controllers that are supported
  18665. */
  18666. export enum PoseEnabledControllerType {
  18667. /**
  18668. * HTC Vive
  18669. */
  18670. VIVE = 0,
  18671. /**
  18672. * Oculus Rift
  18673. */
  18674. OCULUS = 1,
  18675. /**
  18676. * Windows mixed reality
  18677. */
  18678. WINDOWS = 2,
  18679. /**
  18680. * Samsung gear VR
  18681. */
  18682. GEAR_VR = 3,
  18683. /**
  18684. * Google Daydream
  18685. */
  18686. DAYDREAM = 4,
  18687. /**
  18688. * Generic
  18689. */
  18690. GENERIC = 5
  18691. }
  18692. /**
  18693. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18694. */
  18695. export interface MutableGamepadButton {
  18696. /**
  18697. * Value of the button/trigger
  18698. */
  18699. value: number;
  18700. /**
  18701. * If the button/trigger is currently touched
  18702. */
  18703. touched: boolean;
  18704. /**
  18705. * If the button/trigger is currently pressed
  18706. */
  18707. pressed: boolean;
  18708. }
  18709. /**
  18710. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18711. * @hidden
  18712. */
  18713. export interface ExtendedGamepadButton extends GamepadButton {
  18714. /**
  18715. * If the button/trigger is currently pressed
  18716. */
  18717. readonly pressed: boolean;
  18718. /**
  18719. * If the button/trigger is currently touched
  18720. */
  18721. readonly touched: boolean;
  18722. /**
  18723. * Value of the button/trigger
  18724. */
  18725. readonly value: number;
  18726. }
  18727. /** @hidden */
  18728. export interface _GamePadFactory {
  18729. /**
  18730. * Returns whether or not the current gamepad can be created for this type of controller.
  18731. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18732. * @returns true if it can be created, otherwise false
  18733. */
  18734. canCreate(gamepadInfo: any): boolean;
  18735. /**
  18736. * Creates a new instance of the Gamepad.
  18737. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18738. * @returns the new gamepad instance
  18739. */
  18740. create(gamepadInfo: any): Gamepad;
  18741. }
  18742. /**
  18743. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18744. */
  18745. export class PoseEnabledControllerHelper {
  18746. /** @hidden */
  18747. static _ControllerFactories: _GamePadFactory[];
  18748. /** @hidden */
  18749. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18750. /**
  18751. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18752. * @param vrGamepad the gamepad to initialized
  18753. * @returns a vr controller of the type the gamepad identified as
  18754. */
  18755. static InitiateController(vrGamepad: any): Gamepad;
  18756. }
  18757. /**
  18758. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18759. */
  18760. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18761. /**
  18762. * If the controller is used in a webXR session
  18763. */
  18764. isXR: boolean;
  18765. private _deviceRoomPosition;
  18766. private _deviceRoomRotationQuaternion;
  18767. /**
  18768. * The device position in babylon space
  18769. */
  18770. devicePosition: Vector3;
  18771. /**
  18772. * The device rotation in babylon space
  18773. */
  18774. deviceRotationQuaternion: Quaternion;
  18775. /**
  18776. * The scale factor of the device in babylon space
  18777. */
  18778. deviceScaleFactor: number;
  18779. /**
  18780. * (Likely devicePosition should be used instead) The device position in its room space
  18781. */
  18782. position: Vector3;
  18783. /**
  18784. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18785. */
  18786. rotationQuaternion: Quaternion;
  18787. /**
  18788. * The type of controller (Eg. Windows mixed reality)
  18789. */
  18790. controllerType: PoseEnabledControllerType;
  18791. protected _calculatedPosition: Vector3;
  18792. private _calculatedRotation;
  18793. /**
  18794. * The raw pose from the device
  18795. */
  18796. rawPose: DevicePose;
  18797. private _trackPosition;
  18798. private _maxRotationDistFromHeadset;
  18799. private _draggedRoomRotation;
  18800. /**
  18801. * @hidden
  18802. */
  18803. _disableTrackPosition(fixedPosition: Vector3): void;
  18804. /**
  18805. * Internal, the mesh attached to the controller
  18806. * @hidden
  18807. */
  18808. _mesh: Nullable<AbstractMesh>;
  18809. private _poseControlledCamera;
  18810. private _leftHandSystemQuaternion;
  18811. /**
  18812. * Internal, matrix used to convert room space to babylon space
  18813. * @hidden
  18814. */
  18815. _deviceToWorld: Matrix;
  18816. /**
  18817. * Node to be used when casting a ray from the controller
  18818. * @hidden
  18819. */
  18820. _pointingPoseNode: Nullable<TransformNode>;
  18821. /**
  18822. * Name of the child mesh that can be used to cast a ray from the controller
  18823. */
  18824. static readonly POINTING_POSE: string;
  18825. /**
  18826. * Creates a new PoseEnabledController from a gamepad
  18827. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18828. */
  18829. constructor(browserGamepad: any);
  18830. private _workingMatrix;
  18831. /**
  18832. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18833. */
  18834. update(): void;
  18835. /**
  18836. * Updates only the pose device and mesh without doing any button event checking
  18837. */
  18838. protected _updatePoseAndMesh(): void;
  18839. /**
  18840. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18841. * @param poseData raw pose fromthe device
  18842. */
  18843. updateFromDevice(poseData: DevicePose): void;
  18844. /**
  18845. * @hidden
  18846. */
  18847. _meshAttachedObservable: Observable<AbstractMesh>;
  18848. /**
  18849. * Attaches a mesh to the controller
  18850. * @param mesh the mesh to be attached
  18851. */
  18852. attachToMesh(mesh: AbstractMesh): void;
  18853. /**
  18854. * Attaches the controllers mesh to a camera
  18855. * @param camera the camera the mesh should be attached to
  18856. */
  18857. attachToPoseControlledCamera(camera: TargetCamera): void;
  18858. /**
  18859. * Disposes of the controller
  18860. */
  18861. dispose(): void;
  18862. /**
  18863. * The mesh that is attached to the controller
  18864. */
  18865. get mesh(): Nullable<AbstractMesh>;
  18866. /**
  18867. * Gets the ray of the controller in the direction the controller is pointing
  18868. * @param length the length the resulting ray should be
  18869. * @returns a ray in the direction the controller is pointing
  18870. */
  18871. getForwardRay(length?: number): Ray;
  18872. }
  18873. }
  18874. declare module BABYLON {
  18875. /**
  18876. * Defines the WebVRController object that represents controllers tracked in 3D space
  18877. */
  18878. export abstract class WebVRController extends PoseEnabledController {
  18879. /**
  18880. * Internal, the default controller model for the controller
  18881. */
  18882. protected _defaultModel: Nullable<AbstractMesh>;
  18883. /**
  18884. * Fired when the trigger state has changed
  18885. */
  18886. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18887. /**
  18888. * Fired when the main button state has changed
  18889. */
  18890. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18891. /**
  18892. * Fired when the secondary button state has changed
  18893. */
  18894. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18895. /**
  18896. * Fired when the pad state has changed
  18897. */
  18898. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18899. /**
  18900. * Fired when controllers stick values have changed
  18901. */
  18902. onPadValuesChangedObservable: Observable<StickValues>;
  18903. /**
  18904. * Array of button availible on the controller
  18905. */
  18906. protected _buttons: Array<MutableGamepadButton>;
  18907. private _onButtonStateChange;
  18908. /**
  18909. * Fired when a controller button's state has changed
  18910. * @param callback the callback containing the button that was modified
  18911. */
  18912. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18913. /**
  18914. * X and Y axis corresponding to the controllers joystick
  18915. */
  18916. pad: StickValues;
  18917. /**
  18918. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18919. */
  18920. hand: string;
  18921. /**
  18922. * The default controller model for the controller
  18923. */
  18924. get defaultModel(): Nullable<AbstractMesh>;
  18925. /**
  18926. * Creates a new WebVRController from a gamepad
  18927. * @param vrGamepad the gamepad that the WebVRController should be created from
  18928. */
  18929. constructor(vrGamepad: any);
  18930. /**
  18931. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18932. */
  18933. update(): void;
  18934. /**
  18935. * Function to be called when a button is modified
  18936. */
  18937. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18938. /**
  18939. * Loads a mesh and attaches it to the controller
  18940. * @param scene the scene the mesh should be added to
  18941. * @param meshLoaded callback for when the mesh has been loaded
  18942. */
  18943. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18944. private _setButtonValue;
  18945. private _changes;
  18946. private _checkChanges;
  18947. /**
  18948. * Disposes of th webVRCOntroller
  18949. */
  18950. dispose(): void;
  18951. }
  18952. }
  18953. declare module BABYLON {
  18954. /**
  18955. * The HemisphericLight simulates the ambient environment light,
  18956. * so the passed direction is the light reflection direction, not the incoming direction.
  18957. */
  18958. export class HemisphericLight extends Light {
  18959. /**
  18960. * The groundColor is the light in the opposite direction to the one specified during creation.
  18961. * 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.
  18962. */
  18963. groundColor: Color3;
  18964. /**
  18965. * The light reflection direction, not the incoming direction.
  18966. */
  18967. direction: Vector3;
  18968. /**
  18969. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18970. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18971. * The HemisphericLight can't cast shadows.
  18972. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18973. * @param name The friendly name of the light
  18974. * @param direction The direction of the light reflection
  18975. * @param scene The scene the light belongs to
  18976. */
  18977. constructor(name: string, direction: Vector3, scene: Scene);
  18978. protected _buildUniformLayout(): void;
  18979. /**
  18980. * Returns the string "HemisphericLight".
  18981. * @return The class name
  18982. */
  18983. getClassName(): string;
  18984. /**
  18985. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18986. * Returns the updated direction.
  18987. * @param target The target the direction should point to
  18988. * @return The computed direction
  18989. */
  18990. setDirectionToTarget(target: Vector3): Vector3;
  18991. /**
  18992. * Returns the shadow generator associated to the light.
  18993. * @returns Always null for hemispheric lights because it does not support shadows.
  18994. */
  18995. getShadowGenerator(): Nullable<IShadowGenerator>;
  18996. /**
  18997. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18998. * @param effect The effect to update
  18999. * @param lightIndex The index of the light in the effect to update
  19000. * @returns The hemispheric light
  19001. */
  19002. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19003. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19004. /**
  19005. * Computes the world matrix of the node
  19006. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19007. * @param useWasUpdatedFlag defines a reserved property
  19008. * @returns the world matrix
  19009. */
  19010. computeWorldMatrix(): Matrix;
  19011. /**
  19012. * Returns the integer 3.
  19013. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19014. */
  19015. getTypeID(): number;
  19016. /**
  19017. * Prepares the list of defines specific to the light type.
  19018. * @param defines the list of defines
  19019. * @param lightIndex defines the index of the light for the effect
  19020. */
  19021. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19022. }
  19023. }
  19024. declare module BABYLON {
  19025. /** @hidden */
  19026. export var vrMultiviewToSingleviewPixelShader: {
  19027. name: string;
  19028. shader: string;
  19029. };
  19030. }
  19031. declare module BABYLON {
  19032. /**
  19033. * Renders to multiple views with a single draw call
  19034. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19035. */
  19036. export class MultiviewRenderTarget extends RenderTargetTexture {
  19037. /**
  19038. * Creates a multiview render target
  19039. * @param scene scene used with the render target
  19040. * @param size the size of the render target (used for each view)
  19041. */
  19042. constructor(scene: Scene, size?: number | {
  19043. width: number;
  19044. height: number;
  19045. } | {
  19046. ratio: number;
  19047. });
  19048. /**
  19049. * @hidden
  19050. * @param faceIndex the face index, if its a cube texture
  19051. */
  19052. _bindFrameBuffer(faceIndex?: number): void;
  19053. /**
  19054. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19055. * @returns the view count
  19056. */
  19057. getViewCount(): number;
  19058. }
  19059. }
  19060. declare module BABYLON {
  19061. /**
  19062. * Represents a camera frustum
  19063. */
  19064. export class Frustum {
  19065. /**
  19066. * Gets the planes representing the frustum
  19067. * @param transform matrix to be applied to the returned planes
  19068. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19069. */
  19070. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19071. /**
  19072. * Gets the near frustum plane transformed by the transform matrix
  19073. * @param transform transformation matrix to be applied to the resulting frustum plane
  19074. * @param frustumPlane the resuling frustum plane
  19075. */
  19076. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19077. /**
  19078. * Gets the far frustum plane transformed by the transform matrix
  19079. * @param transform transformation matrix to be applied to the resulting frustum plane
  19080. * @param frustumPlane the resuling frustum plane
  19081. */
  19082. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19083. /**
  19084. * Gets the left frustum plane transformed by the transform matrix
  19085. * @param transform transformation matrix to be applied to the resulting frustum plane
  19086. * @param frustumPlane the resuling frustum plane
  19087. */
  19088. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19089. /**
  19090. * Gets the right frustum plane transformed by the transform matrix
  19091. * @param transform transformation matrix to be applied to the resulting frustum plane
  19092. * @param frustumPlane the resuling frustum plane
  19093. */
  19094. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19095. /**
  19096. * Gets the top frustum plane transformed by the transform matrix
  19097. * @param transform transformation matrix to be applied to the resulting frustum plane
  19098. * @param frustumPlane the resuling frustum plane
  19099. */
  19100. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19101. /**
  19102. * Gets the bottom frustum plane transformed by the transform matrix
  19103. * @param transform transformation matrix to be applied to the resulting frustum plane
  19104. * @param frustumPlane the resuling frustum plane
  19105. */
  19106. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19107. /**
  19108. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19109. * @param transform transformation matrix to be applied to the resulting frustum planes
  19110. * @param frustumPlanes the resuling frustum planes
  19111. */
  19112. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19113. }
  19114. }
  19115. declare module BABYLON {
  19116. interface Engine {
  19117. /**
  19118. * Creates a new multiview render target
  19119. * @param width defines the width of the texture
  19120. * @param height defines the height of the texture
  19121. * @returns the created multiview texture
  19122. */
  19123. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19124. /**
  19125. * Binds a multiview framebuffer to be drawn to
  19126. * @param multiviewTexture texture to bind
  19127. */
  19128. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19129. }
  19130. interface Camera {
  19131. /**
  19132. * @hidden
  19133. * 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)
  19134. */
  19135. _useMultiviewToSingleView: boolean;
  19136. /**
  19137. * @hidden
  19138. * 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)
  19139. */
  19140. _multiviewTexture: Nullable<RenderTargetTexture>;
  19141. /**
  19142. * @hidden
  19143. * ensures the multiview texture of the camera exists and has the specified width/height
  19144. * @param width height to set on the multiview texture
  19145. * @param height width to set on the multiview texture
  19146. */
  19147. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19148. }
  19149. interface Scene {
  19150. /** @hidden */
  19151. _transformMatrixR: Matrix;
  19152. /** @hidden */
  19153. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19154. /** @hidden */
  19155. _createMultiviewUbo(): void;
  19156. /** @hidden */
  19157. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19158. /** @hidden */
  19159. _renderMultiviewToSingleView(camera: Camera): void;
  19160. }
  19161. }
  19162. declare module BABYLON {
  19163. /**
  19164. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19165. * This will not be used for webXR as it supports displaying texture arrays directly
  19166. */
  19167. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19168. /**
  19169. * Initializes a VRMultiviewToSingleview
  19170. * @param name name of the post process
  19171. * @param camera camera to be applied to
  19172. * @param scaleFactor scaling factor to the size of the output texture
  19173. */
  19174. constructor(name: string, camera: Camera, scaleFactor: number);
  19175. }
  19176. }
  19177. declare module BABYLON {
  19178. /**
  19179. * Interface used to define additional presentation attributes
  19180. */
  19181. export interface IVRPresentationAttributes {
  19182. /**
  19183. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19184. */
  19185. highRefreshRate: boolean;
  19186. /**
  19187. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19188. */
  19189. foveationLevel: number;
  19190. }
  19191. interface Engine {
  19192. /** @hidden */
  19193. _vrDisplay: any;
  19194. /** @hidden */
  19195. _vrSupported: boolean;
  19196. /** @hidden */
  19197. _oldSize: Size;
  19198. /** @hidden */
  19199. _oldHardwareScaleFactor: number;
  19200. /** @hidden */
  19201. _vrExclusivePointerMode: boolean;
  19202. /** @hidden */
  19203. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19204. /** @hidden */
  19205. _onVRDisplayPointerRestricted: () => void;
  19206. /** @hidden */
  19207. _onVRDisplayPointerUnrestricted: () => void;
  19208. /** @hidden */
  19209. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19210. /** @hidden */
  19211. _onVrDisplayDisconnect: Nullable<() => void>;
  19212. /** @hidden */
  19213. _onVrDisplayPresentChange: Nullable<() => void>;
  19214. /**
  19215. * Observable signaled when VR display mode changes
  19216. */
  19217. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19218. /**
  19219. * Observable signaled when VR request present is complete
  19220. */
  19221. onVRRequestPresentComplete: Observable<boolean>;
  19222. /**
  19223. * Observable signaled when VR request present starts
  19224. */
  19225. onVRRequestPresentStart: Observable<Engine>;
  19226. /**
  19227. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19228. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19229. */
  19230. isInVRExclusivePointerMode: boolean;
  19231. /**
  19232. * Gets a boolean indicating if a webVR device was detected
  19233. * @returns true if a webVR device was detected
  19234. */
  19235. isVRDevicePresent(): boolean;
  19236. /**
  19237. * Gets the current webVR device
  19238. * @returns the current webVR device (or null)
  19239. */
  19240. getVRDevice(): any;
  19241. /**
  19242. * Initializes a webVR display and starts listening to display change events
  19243. * The onVRDisplayChangedObservable will be notified upon these changes
  19244. * @returns A promise containing a VRDisplay and if vr is supported
  19245. */
  19246. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19247. /** @hidden */
  19248. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19249. /**
  19250. * Gets or sets the presentation attributes used to configure VR rendering
  19251. */
  19252. vrPresentationAttributes?: IVRPresentationAttributes;
  19253. /**
  19254. * Call this function to switch to webVR mode
  19255. * Will do nothing if webVR is not supported or if there is no webVR device
  19256. * @param options the webvr options provided to the camera. mainly used for multiview
  19257. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19258. */
  19259. enableVR(options: WebVROptions): void;
  19260. /** @hidden */
  19261. _onVRFullScreenTriggered(): void;
  19262. }
  19263. }
  19264. declare module BABYLON {
  19265. /**
  19266. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19267. * IMPORTANT!! The data is right-hand data.
  19268. * @export
  19269. * @interface DevicePose
  19270. */
  19271. export interface DevicePose {
  19272. /**
  19273. * The position of the device, values in array are [x,y,z].
  19274. */
  19275. readonly position: Nullable<Float32Array>;
  19276. /**
  19277. * The linearVelocity of the device, values in array are [x,y,z].
  19278. */
  19279. readonly linearVelocity: Nullable<Float32Array>;
  19280. /**
  19281. * The linearAcceleration of the device, values in array are [x,y,z].
  19282. */
  19283. readonly linearAcceleration: Nullable<Float32Array>;
  19284. /**
  19285. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19286. */
  19287. readonly orientation: Nullable<Float32Array>;
  19288. /**
  19289. * The angularVelocity of the device, values in array are [x,y,z].
  19290. */
  19291. readonly angularVelocity: Nullable<Float32Array>;
  19292. /**
  19293. * The angularAcceleration of the device, values in array are [x,y,z].
  19294. */
  19295. readonly angularAcceleration: Nullable<Float32Array>;
  19296. }
  19297. /**
  19298. * Interface representing a pose controlled object in Babylon.
  19299. * A pose controlled object has both regular pose values as well as pose values
  19300. * from an external device such as a VR head mounted display
  19301. */
  19302. export interface PoseControlled {
  19303. /**
  19304. * The position of the object in babylon space.
  19305. */
  19306. position: Vector3;
  19307. /**
  19308. * The rotation quaternion of the object in babylon space.
  19309. */
  19310. rotationQuaternion: Quaternion;
  19311. /**
  19312. * The position of the device in babylon space.
  19313. */
  19314. devicePosition?: Vector3;
  19315. /**
  19316. * The rotation quaternion of the device in babylon space.
  19317. */
  19318. deviceRotationQuaternion: Quaternion;
  19319. /**
  19320. * The raw pose coming from the device.
  19321. */
  19322. rawPose: Nullable<DevicePose>;
  19323. /**
  19324. * The scale of the device to be used when translating from device space to babylon space.
  19325. */
  19326. deviceScaleFactor: number;
  19327. /**
  19328. * Updates the poseControlled values based on the input device pose.
  19329. * @param poseData the pose data to update the object with
  19330. */
  19331. updateFromDevice(poseData: DevicePose): void;
  19332. }
  19333. /**
  19334. * Set of options to customize the webVRCamera
  19335. */
  19336. export interface WebVROptions {
  19337. /**
  19338. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19339. */
  19340. trackPosition?: boolean;
  19341. /**
  19342. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19343. */
  19344. positionScale?: number;
  19345. /**
  19346. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19347. */
  19348. displayName?: string;
  19349. /**
  19350. * Should the native controller meshes be initialized. (default: true)
  19351. */
  19352. controllerMeshes?: boolean;
  19353. /**
  19354. * Creating a default HemiLight only on controllers. (default: true)
  19355. */
  19356. defaultLightingOnControllers?: boolean;
  19357. /**
  19358. * If you don't want to use the default VR button of the helper. (default: false)
  19359. */
  19360. useCustomVRButton?: boolean;
  19361. /**
  19362. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19363. */
  19364. customVRButton?: HTMLButtonElement;
  19365. /**
  19366. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19367. */
  19368. rayLength?: number;
  19369. /**
  19370. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19371. */
  19372. defaultHeight?: number;
  19373. /**
  19374. * If multiview should be used if availible (default: false)
  19375. */
  19376. useMultiview?: boolean;
  19377. }
  19378. /**
  19379. * This represents a WebVR camera.
  19380. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19381. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19382. */
  19383. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19384. private webVROptions;
  19385. /**
  19386. * @hidden
  19387. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19388. */
  19389. _vrDevice: any;
  19390. /**
  19391. * The rawPose of the vrDevice.
  19392. */
  19393. rawPose: Nullable<DevicePose>;
  19394. private _onVREnabled;
  19395. private _specsVersion;
  19396. private _attached;
  19397. private _frameData;
  19398. protected _descendants: Array<Node>;
  19399. private _deviceRoomPosition;
  19400. /** @hidden */
  19401. _deviceRoomRotationQuaternion: Quaternion;
  19402. private _standingMatrix;
  19403. /**
  19404. * Represents device position in babylon space.
  19405. */
  19406. devicePosition: Vector3;
  19407. /**
  19408. * Represents device rotation in babylon space.
  19409. */
  19410. deviceRotationQuaternion: Quaternion;
  19411. /**
  19412. * The scale of the device to be used when translating from device space to babylon space.
  19413. */
  19414. deviceScaleFactor: number;
  19415. private _deviceToWorld;
  19416. private _worldToDevice;
  19417. /**
  19418. * References to the webVR controllers for the vrDevice.
  19419. */
  19420. controllers: Array<WebVRController>;
  19421. /**
  19422. * Emits an event when a controller is attached.
  19423. */
  19424. onControllersAttachedObservable: Observable<WebVRController[]>;
  19425. /**
  19426. * Emits an event when a controller's mesh has been loaded;
  19427. */
  19428. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19429. /**
  19430. * Emits an event when the HMD's pose has been updated.
  19431. */
  19432. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19433. private _poseSet;
  19434. /**
  19435. * If the rig cameras be used as parent instead of this camera.
  19436. */
  19437. rigParenting: boolean;
  19438. private _lightOnControllers;
  19439. private _defaultHeight?;
  19440. /**
  19441. * Instantiates a WebVRFreeCamera.
  19442. * @param name The name of the WebVRFreeCamera
  19443. * @param position The starting anchor position for the camera
  19444. * @param scene The scene the camera belongs to
  19445. * @param webVROptions a set of customizable options for the webVRCamera
  19446. */
  19447. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19448. /**
  19449. * Gets the device distance from the ground in meters.
  19450. * @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.
  19451. */
  19452. deviceDistanceToRoomGround(): number;
  19453. /**
  19454. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19455. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19456. */
  19457. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19458. /**
  19459. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19460. * @returns A promise with a boolean set to if the standing matrix is supported.
  19461. */
  19462. useStandingMatrixAsync(): Promise<boolean>;
  19463. /**
  19464. * Disposes the camera
  19465. */
  19466. dispose(): void;
  19467. /**
  19468. * Gets a vrController by name.
  19469. * @param name The name of the controller to retreive
  19470. * @returns the controller matching the name specified or null if not found
  19471. */
  19472. getControllerByName(name: string): Nullable<WebVRController>;
  19473. private _leftController;
  19474. /**
  19475. * The controller corresponding to the users left hand.
  19476. */
  19477. get leftController(): Nullable<WebVRController>;
  19478. private _rightController;
  19479. /**
  19480. * The controller corresponding to the users right hand.
  19481. */
  19482. get rightController(): Nullable<WebVRController>;
  19483. /**
  19484. * Casts a ray forward from the vrCamera's gaze.
  19485. * @param length Length of the ray (default: 100)
  19486. * @returns the ray corresponding to the gaze
  19487. */
  19488. getForwardRay(length?: number): Ray;
  19489. /**
  19490. * @hidden
  19491. * Updates the camera based on device's frame data
  19492. */
  19493. _checkInputs(): void;
  19494. /**
  19495. * Updates the poseControlled values based on the input device pose.
  19496. * @param poseData Pose coming from the device
  19497. */
  19498. updateFromDevice(poseData: DevicePose): void;
  19499. private _htmlElementAttached;
  19500. private _detachIfAttached;
  19501. /**
  19502. * WebVR's attach control will start broadcasting frames to the device.
  19503. * Note that in certain browsers (chrome for example) this function must be called
  19504. * within a user-interaction callback. Example:
  19505. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19506. *
  19507. * @param element html element to attach the vrDevice to
  19508. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19509. */
  19510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19511. /**
  19512. * Detaches the camera from the html element and disables VR
  19513. *
  19514. * @param element html element to detach from
  19515. */
  19516. detachControl(element: HTMLElement): void;
  19517. /**
  19518. * @returns the name of this class
  19519. */
  19520. getClassName(): string;
  19521. /**
  19522. * Calls resetPose on the vrDisplay
  19523. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19524. */
  19525. resetToCurrentRotation(): void;
  19526. /**
  19527. * @hidden
  19528. * Updates the rig cameras (left and right eye)
  19529. */
  19530. _updateRigCameras(): void;
  19531. private _workingVector;
  19532. private _oneVector;
  19533. private _workingMatrix;
  19534. private updateCacheCalled;
  19535. private _correctPositionIfNotTrackPosition;
  19536. /**
  19537. * @hidden
  19538. * Updates the cached values of the camera
  19539. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19540. */
  19541. _updateCache(ignoreParentClass?: boolean): void;
  19542. /**
  19543. * @hidden
  19544. * Get current device position in babylon world
  19545. */
  19546. _computeDevicePosition(): void;
  19547. /**
  19548. * Updates the current device position and rotation in the babylon world
  19549. */
  19550. update(): void;
  19551. /**
  19552. * @hidden
  19553. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19554. * @returns an identity matrix
  19555. */
  19556. _getViewMatrix(): Matrix;
  19557. private _tmpMatrix;
  19558. /**
  19559. * This function is called by the two RIG cameras.
  19560. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19561. * @hidden
  19562. */
  19563. _getWebVRViewMatrix(): Matrix;
  19564. /** @hidden */
  19565. _getWebVRProjectionMatrix(): Matrix;
  19566. private _onGamepadConnectedObserver;
  19567. private _onGamepadDisconnectedObserver;
  19568. private _updateCacheWhenTrackingDisabledObserver;
  19569. /**
  19570. * Initializes the controllers and their meshes
  19571. */
  19572. initControllers(): void;
  19573. }
  19574. }
  19575. declare module BABYLON {
  19576. /**
  19577. * Size options for a post process
  19578. */
  19579. export type PostProcessOptions = {
  19580. width: number;
  19581. height: number;
  19582. };
  19583. /**
  19584. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19585. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19586. */
  19587. export class PostProcess {
  19588. /** Name of the PostProcess. */
  19589. name: string;
  19590. /**
  19591. * Gets or sets the unique id of the post process
  19592. */
  19593. uniqueId: number;
  19594. /**
  19595. * Width of the texture to apply the post process on
  19596. */
  19597. width: number;
  19598. /**
  19599. * Height of the texture to apply the post process on
  19600. */
  19601. height: number;
  19602. /**
  19603. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19604. * @hidden
  19605. */
  19606. _outputTexture: Nullable<InternalTexture>;
  19607. /**
  19608. * Sampling mode used by the shader
  19609. * See https://doc.babylonjs.com/classes/3.1/texture
  19610. */
  19611. renderTargetSamplingMode: number;
  19612. /**
  19613. * Clear color to use when screen clearing
  19614. */
  19615. clearColor: Color4;
  19616. /**
  19617. * If the buffer needs to be cleared before applying the post process. (default: true)
  19618. * Should be set to false if shader will overwrite all previous pixels.
  19619. */
  19620. autoClear: boolean;
  19621. /**
  19622. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19623. */
  19624. alphaMode: number;
  19625. /**
  19626. * Sets the setAlphaBlendConstants of the babylon engine
  19627. */
  19628. alphaConstants: Color4;
  19629. /**
  19630. * Animations to be used for the post processing
  19631. */
  19632. animations: Animation[];
  19633. /**
  19634. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19635. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19636. */
  19637. enablePixelPerfectMode: boolean;
  19638. /**
  19639. * Force the postprocess to be applied without taking in account viewport
  19640. */
  19641. forceFullscreenViewport: boolean;
  19642. /**
  19643. * List of inspectable custom properties (used by the Inspector)
  19644. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19645. */
  19646. inspectableCustomProperties: IInspectable[];
  19647. /**
  19648. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19649. *
  19650. * | Value | Type | Description |
  19651. * | ----- | ----------------------------------- | ----------- |
  19652. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19653. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19654. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19655. *
  19656. */
  19657. scaleMode: number;
  19658. /**
  19659. * Force textures to be a power of two (default: false)
  19660. */
  19661. alwaysForcePOT: boolean;
  19662. private _samples;
  19663. /**
  19664. * Number of sample textures (default: 1)
  19665. */
  19666. get samples(): number;
  19667. set samples(n: number);
  19668. /**
  19669. * Modify the scale of the post process to be the same as the viewport (default: false)
  19670. */
  19671. adaptScaleToCurrentViewport: boolean;
  19672. private _camera;
  19673. private _scene;
  19674. private _engine;
  19675. private _options;
  19676. private _reusable;
  19677. private _textureType;
  19678. private _textureFormat;
  19679. /**
  19680. * Smart array of input and output textures for the post process.
  19681. * @hidden
  19682. */
  19683. _textures: SmartArray<InternalTexture>;
  19684. /**
  19685. * The index in _textures that corresponds to the output texture.
  19686. * @hidden
  19687. */
  19688. _currentRenderTextureInd: number;
  19689. private _effect;
  19690. private _samplers;
  19691. private _fragmentUrl;
  19692. private _vertexUrl;
  19693. private _parameters;
  19694. private _scaleRatio;
  19695. protected _indexParameters: any;
  19696. private _shareOutputWithPostProcess;
  19697. private _texelSize;
  19698. private _forcedOutputTexture;
  19699. /**
  19700. * Returns the fragment url or shader name used in the post process.
  19701. * @returns the fragment url or name in the shader store.
  19702. */
  19703. getEffectName(): string;
  19704. /**
  19705. * An event triggered when the postprocess is activated.
  19706. */
  19707. onActivateObservable: Observable<Camera>;
  19708. private _onActivateObserver;
  19709. /**
  19710. * A function that is added to the onActivateObservable
  19711. */
  19712. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19713. /**
  19714. * An event triggered when the postprocess changes its size.
  19715. */
  19716. onSizeChangedObservable: Observable<PostProcess>;
  19717. private _onSizeChangedObserver;
  19718. /**
  19719. * A function that is added to the onSizeChangedObservable
  19720. */
  19721. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19722. /**
  19723. * An event triggered when the postprocess applies its effect.
  19724. */
  19725. onApplyObservable: Observable<Effect>;
  19726. private _onApplyObserver;
  19727. /**
  19728. * A function that is added to the onApplyObservable
  19729. */
  19730. set onApply(callback: (effect: Effect) => void);
  19731. /**
  19732. * An event triggered before rendering the postprocess
  19733. */
  19734. onBeforeRenderObservable: Observable<Effect>;
  19735. private _onBeforeRenderObserver;
  19736. /**
  19737. * A function that is added to the onBeforeRenderObservable
  19738. */
  19739. set onBeforeRender(callback: (effect: Effect) => void);
  19740. /**
  19741. * An event triggered after rendering the postprocess
  19742. */
  19743. onAfterRenderObservable: Observable<Effect>;
  19744. private _onAfterRenderObserver;
  19745. /**
  19746. * A function that is added to the onAfterRenderObservable
  19747. */
  19748. set onAfterRender(callback: (efect: Effect) => void);
  19749. /**
  19750. * 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
  19751. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19752. */
  19753. get inputTexture(): InternalTexture;
  19754. set inputTexture(value: InternalTexture);
  19755. /**
  19756. * Gets the camera which post process is applied to.
  19757. * @returns The camera the post process is applied to.
  19758. */
  19759. getCamera(): Camera;
  19760. /**
  19761. * Gets the texel size of the postprocess.
  19762. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19763. */
  19764. get texelSize(): Vector2;
  19765. /**
  19766. * Creates a new instance PostProcess
  19767. * @param name The name of the PostProcess.
  19768. * @param fragmentUrl The url of the fragment shader to be used.
  19769. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19770. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19771. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19772. * @param camera The camera to apply the render pass to.
  19773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19774. * @param engine The engine which the post process will be applied. (default: current engine)
  19775. * @param reusable If the post process can be reused on the same frame. (default: false)
  19776. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19777. * @param textureType Type of textures used when performing the post process. (default: 0)
  19778. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19779. * @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
  19780. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19781. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19782. */
  19783. constructor(
  19784. /** Name of the PostProcess. */
  19785. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  19786. /**
  19787. * Gets a string idenfifying the name of the class
  19788. * @returns "PostProcess" string
  19789. */
  19790. getClassName(): string;
  19791. /**
  19792. * Gets the engine which this post process belongs to.
  19793. * @returns The engine the post process was enabled with.
  19794. */
  19795. getEngine(): Engine;
  19796. /**
  19797. * The effect that is created when initializing the post process.
  19798. * @returns The created effect corresponding the the postprocess.
  19799. */
  19800. getEffect(): Effect;
  19801. /**
  19802. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19803. * @param postProcess The post process to share the output with.
  19804. * @returns This post process.
  19805. */
  19806. shareOutputWith(postProcess: PostProcess): PostProcess;
  19807. /**
  19808. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19809. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19810. */
  19811. useOwnOutput(): void;
  19812. /**
  19813. * Updates the effect with the current post process compile time values and recompiles the shader.
  19814. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19815. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19816. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19817. * @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
  19818. * @param onCompiled Called when the shader has been compiled.
  19819. * @param onError Called if there is an error when compiling a shader.
  19820. */
  19821. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19822. /**
  19823. * The post process is reusable if it can be used multiple times within one frame.
  19824. * @returns If the post process is reusable
  19825. */
  19826. isReusable(): boolean;
  19827. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19828. markTextureDirty(): void;
  19829. /**
  19830. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19831. * 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.
  19832. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19833. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19834. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19835. * @returns The target texture that was bound to be written to.
  19836. */
  19837. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19838. /**
  19839. * If the post process is supported.
  19840. */
  19841. get isSupported(): boolean;
  19842. /**
  19843. * The aspect ratio of the output texture.
  19844. */
  19845. get aspectRatio(): number;
  19846. /**
  19847. * Get a value indicating if the post-process is ready to be used
  19848. * @returns true if the post-process is ready (shader is compiled)
  19849. */
  19850. isReady(): boolean;
  19851. /**
  19852. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19853. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19854. */
  19855. apply(): Nullable<Effect>;
  19856. private _disposeTextures;
  19857. /**
  19858. * Disposes the post process.
  19859. * @param camera The camera to dispose the post process on.
  19860. */
  19861. dispose(camera?: Camera): void;
  19862. }
  19863. }
  19864. declare module BABYLON {
  19865. /** @hidden */
  19866. export var kernelBlurVaryingDeclaration: {
  19867. name: string;
  19868. shader: string;
  19869. };
  19870. }
  19871. declare module BABYLON {
  19872. /** @hidden */
  19873. export var kernelBlurFragment: {
  19874. name: string;
  19875. shader: string;
  19876. };
  19877. }
  19878. declare module BABYLON {
  19879. /** @hidden */
  19880. export var kernelBlurFragment2: {
  19881. name: string;
  19882. shader: string;
  19883. };
  19884. }
  19885. declare module BABYLON {
  19886. /** @hidden */
  19887. export var kernelBlurPixelShader: {
  19888. name: string;
  19889. shader: string;
  19890. };
  19891. }
  19892. declare module BABYLON {
  19893. /** @hidden */
  19894. export var kernelBlurVertex: {
  19895. name: string;
  19896. shader: string;
  19897. };
  19898. }
  19899. declare module BABYLON {
  19900. /** @hidden */
  19901. export var kernelBlurVertexShader: {
  19902. name: string;
  19903. shader: string;
  19904. };
  19905. }
  19906. declare module BABYLON {
  19907. /**
  19908. * The Blur Post Process which blurs an image based on a kernel and direction.
  19909. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19910. */
  19911. export class BlurPostProcess extends PostProcess {
  19912. /** The direction in which to blur the image. */
  19913. direction: Vector2;
  19914. private blockCompilation;
  19915. protected _kernel: number;
  19916. protected _idealKernel: number;
  19917. protected _packedFloat: boolean;
  19918. private _staticDefines;
  19919. /**
  19920. * Sets the length in pixels of the blur sample region
  19921. */
  19922. set kernel(v: number);
  19923. /**
  19924. * Gets the length in pixels of the blur sample region
  19925. */
  19926. get kernel(): number;
  19927. /**
  19928. * Sets wether or not the blur needs to unpack/repack floats
  19929. */
  19930. set packedFloat(v: boolean);
  19931. /**
  19932. * Gets wether or not the blur is unpacking/repacking floats
  19933. */
  19934. get packedFloat(): boolean;
  19935. /**
  19936. * Creates a new instance BlurPostProcess
  19937. * @param name The name of the effect.
  19938. * @param direction The direction in which to blur the image.
  19939. * @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.
  19940. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19941. * @param camera The camera to apply the render pass to.
  19942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19943. * @param engine The engine which the post process will be applied. (default: current engine)
  19944. * @param reusable If the post process can be reused on the same frame. (default: false)
  19945. * @param textureType Type of textures used when performing the post process. (default: 0)
  19946. * @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)
  19947. */
  19948. constructor(name: string,
  19949. /** The direction in which to blur the image. */
  19950. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19951. /**
  19952. * Updates the effect with the current post process compile time values and recompiles the shader.
  19953. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19954. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19955. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19956. * @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
  19957. * @param onCompiled Called when the shader has been compiled.
  19958. * @param onError Called if there is an error when compiling a shader.
  19959. */
  19960. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19961. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19962. /**
  19963. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19964. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19965. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19966. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19967. * The gaps between physical kernels are compensated for in the weighting of the samples
  19968. * @param idealKernel Ideal blur kernel.
  19969. * @return Nearest best kernel.
  19970. */
  19971. protected _nearestBestKernel(idealKernel: number): number;
  19972. /**
  19973. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19974. * @param x The point on the Gaussian distribution to sample.
  19975. * @return the value of the Gaussian function at x.
  19976. */
  19977. protected _gaussianWeight(x: number): number;
  19978. /**
  19979. * Generates a string that can be used as a floating point number in GLSL.
  19980. * @param x Value to print.
  19981. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19982. * @return GLSL float string.
  19983. */
  19984. protected _glslFloat(x: number, decimalFigures?: number): string;
  19985. }
  19986. }
  19987. declare module BABYLON {
  19988. /**
  19989. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19990. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19991. * You can then easily use it as a reflectionTexture on a flat surface.
  19992. * In case the surface is not a plane, please consider relying on reflection probes.
  19993. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19994. */
  19995. export class MirrorTexture extends RenderTargetTexture {
  19996. private scene;
  19997. /**
  19998. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19999. * 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.
  20000. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20001. */
  20002. mirrorPlane: Plane;
  20003. /**
  20004. * Define the blur ratio used to blur the reflection if needed.
  20005. */
  20006. set blurRatio(value: number);
  20007. get blurRatio(): number;
  20008. /**
  20009. * Define the adaptive blur kernel used to blur the reflection if needed.
  20010. * This will autocompute the closest best match for the `blurKernel`
  20011. */
  20012. set adaptiveBlurKernel(value: number);
  20013. /**
  20014. * Define the blur kernel used to blur the reflection if needed.
  20015. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20016. */
  20017. set blurKernel(value: number);
  20018. /**
  20019. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20020. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20021. */
  20022. set blurKernelX(value: number);
  20023. get blurKernelX(): number;
  20024. /**
  20025. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20026. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20027. */
  20028. set blurKernelY(value: number);
  20029. get blurKernelY(): number;
  20030. private _autoComputeBlurKernel;
  20031. protected _onRatioRescale(): void;
  20032. private _updateGammaSpace;
  20033. private _imageProcessingConfigChangeObserver;
  20034. private _transformMatrix;
  20035. private _mirrorMatrix;
  20036. private _savedViewMatrix;
  20037. private _blurX;
  20038. private _blurY;
  20039. private _adaptiveBlurKernel;
  20040. private _blurKernelX;
  20041. private _blurKernelY;
  20042. private _blurRatio;
  20043. /**
  20044. * Instantiates a Mirror Texture.
  20045. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20046. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20047. * You can then easily use it as a reflectionTexture on a flat surface.
  20048. * In case the surface is not a plane, please consider relying on reflection probes.
  20049. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20050. * @param name
  20051. * @param size
  20052. * @param scene
  20053. * @param generateMipMaps
  20054. * @param type
  20055. * @param samplingMode
  20056. * @param generateDepthBuffer
  20057. */
  20058. constructor(name: string, size: number | {
  20059. width: number;
  20060. height: number;
  20061. } | {
  20062. ratio: number;
  20063. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20064. private _preparePostProcesses;
  20065. /**
  20066. * Clone the mirror texture.
  20067. * @returns the cloned texture
  20068. */
  20069. clone(): MirrorTexture;
  20070. /**
  20071. * Serialize the texture to a JSON representation you could use in Parse later on
  20072. * @returns the serialized JSON representation
  20073. */
  20074. serialize(): any;
  20075. /**
  20076. * Dispose the texture and release its associated resources.
  20077. */
  20078. dispose(): void;
  20079. }
  20080. }
  20081. declare module BABYLON {
  20082. /**
  20083. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20084. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20085. */
  20086. export class Texture extends BaseTexture {
  20087. /**
  20088. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20089. */
  20090. static SerializeBuffers: boolean;
  20091. /** @hidden */
  20092. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20093. /** @hidden */
  20094. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20095. /** @hidden */
  20096. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20097. /** nearest is mag = nearest and min = nearest and mip = linear */
  20098. static readonly NEAREST_SAMPLINGMODE: number;
  20099. /** nearest is mag = nearest and min = nearest and mip = linear */
  20100. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20101. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20102. static readonly BILINEAR_SAMPLINGMODE: number;
  20103. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20104. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20105. /** Trilinear is mag = linear and min = linear and mip = linear */
  20106. static readonly TRILINEAR_SAMPLINGMODE: number;
  20107. /** Trilinear is mag = linear and min = linear and mip = linear */
  20108. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20109. /** mag = nearest and min = nearest and mip = nearest */
  20110. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20111. /** mag = nearest and min = linear and mip = nearest */
  20112. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20113. /** mag = nearest and min = linear and mip = linear */
  20114. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20115. /** mag = nearest and min = linear and mip = none */
  20116. static readonly NEAREST_LINEAR: number;
  20117. /** mag = nearest and min = nearest and mip = none */
  20118. static readonly NEAREST_NEAREST: number;
  20119. /** mag = linear and min = nearest and mip = nearest */
  20120. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20121. /** mag = linear and min = nearest and mip = linear */
  20122. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20123. /** mag = linear and min = linear and mip = none */
  20124. static readonly LINEAR_LINEAR: number;
  20125. /** mag = linear and min = nearest and mip = none */
  20126. static readonly LINEAR_NEAREST: number;
  20127. /** Explicit coordinates mode */
  20128. static readonly EXPLICIT_MODE: number;
  20129. /** Spherical coordinates mode */
  20130. static readonly SPHERICAL_MODE: number;
  20131. /** Planar coordinates mode */
  20132. static readonly PLANAR_MODE: number;
  20133. /** Cubic coordinates mode */
  20134. static readonly CUBIC_MODE: number;
  20135. /** Projection coordinates mode */
  20136. static readonly PROJECTION_MODE: number;
  20137. /** Inverse Cubic coordinates mode */
  20138. static readonly SKYBOX_MODE: number;
  20139. /** Inverse Cubic coordinates mode */
  20140. static readonly INVCUBIC_MODE: number;
  20141. /** Equirectangular coordinates mode */
  20142. static readonly EQUIRECTANGULAR_MODE: number;
  20143. /** Equirectangular Fixed coordinates mode */
  20144. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20145. /** Equirectangular Fixed Mirrored coordinates mode */
  20146. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20147. /** Texture is not repeating outside of 0..1 UVs */
  20148. static readonly CLAMP_ADDRESSMODE: number;
  20149. /** Texture is repeating outside of 0..1 UVs */
  20150. static readonly WRAP_ADDRESSMODE: number;
  20151. /** Texture is repeating and mirrored */
  20152. static readonly MIRROR_ADDRESSMODE: number;
  20153. /**
  20154. * 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
  20155. */
  20156. static UseSerializedUrlIfAny: boolean;
  20157. /**
  20158. * Define the url of the texture.
  20159. */
  20160. url: Nullable<string>;
  20161. /**
  20162. * Define an offset on the texture to offset the u coordinates of the UVs
  20163. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20164. */
  20165. uOffset: number;
  20166. /**
  20167. * Define an offset on the texture to offset the v coordinates of the UVs
  20168. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20169. */
  20170. vOffset: number;
  20171. /**
  20172. * Define an offset on the texture to scale the u coordinates of the UVs
  20173. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20174. */
  20175. uScale: number;
  20176. /**
  20177. * Define an offset on the texture to scale the v coordinates of the UVs
  20178. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20179. */
  20180. vScale: number;
  20181. /**
  20182. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20183. * @see http://doc.babylonjs.com/how_to/more_materials
  20184. */
  20185. uAng: number;
  20186. /**
  20187. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20188. * @see http://doc.babylonjs.com/how_to/more_materials
  20189. */
  20190. vAng: number;
  20191. /**
  20192. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20193. * @see http://doc.babylonjs.com/how_to/more_materials
  20194. */
  20195. wAng: number;
  20196. /**
  20197. * Defines the center of rotation (U)
  20198. */
  20199. uRotationCenter: number;
  20200. /**
  20201. * Defines the center of rotation (V)
  20202. */
  20203. vRotationCenter: number;
  20204. /**
  20205. * Defines the center of rotation (W)
  20206. */
  20207. wRotationCenter: number;
  20208. /**
  20209. * Are mip maps generated for this texture or not.
  20210. */
  20211. get noMipmap(): boolean;
  20212. /**
  20213. * List of inspectable custom properties (used by the Inspector)
  20214. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20215. */
  20216. inspectableCustomProperties: Nullable<IInspectable[]>;
  20217. private _noMipmap;
  20218. /** @hidden */
  20219. _invertY: boolean;
  20220. private _rowGenerationMatrix;
  20221. private _cachedTextureMatrix;
  20222. private _projectionModeMatrix;
  20223. private _t0;
  20224. private _t1;
  20225. private _t2;
  20226. private _cachedUOffset;
  20227. private _cachedVOffset;
  20228. private _cachedUScale;
  20229. private _cachedVScale;
  20230. private _cachedUAng;
  20231. private _cachedVAng;
  20232. private _cachedWAng;
  20233. private _cachedProjectionMatrixId;
  20234. private _cachedCoordinatesMode;
  20235. /** @hidden */
  20236. protected _initialSamplingMode: number;
  20237. /** @hidden */
  20238. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20239. private _deleteBuffer;
  20240. protected _format: Nullable<number>;
  20241. private _delayedOnLoad;
  20242. private _delayedOnError;
  20243. private _mimeType?;
  20244. /**
  20245. * Observable triggered once the texture has been loaded.
  20246. */
  20247. onLoadObservable: Observable<Texture>;
  20248. protected _isBlocking: boolean;
  20249. /**
  20250. * Is the texture preventing material to render while loading.
  20251. * If false, a default texture will be used instead of the loading one during the preparation step.
  20252. */
  20253. set isBlocking(value: boolean);
  20254. get isBlocking(): boolean;
  20255. /**
  20256. * Get the current sampling mode associated with the texture.
  20257. */
  20258. get samplingMode(): number;
  20259. /**
  20260. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20261. */
  20262. get invertY(): boolean;
  20263. /**
  20264. * Instantiates a new texture.
  20265. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20266. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20267. * @param url defines the url of the picture to load as a texture
  20268. * @param scene defines the scene or engine the texture will belong to
  20269. * @param noMipmap defines if the texture will require mip maps or not
  20270. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20271. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20272. * @param onLoad defines a callback triggered when the texture has been loaded
  20273. * @param onError defines a callback triggered when an error occurred during the loading session
  20274. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20275. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20276. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20277. * @param mimeType defines an optional mime type information
  20278. */
  20279. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20280. /**
  20281. * Update the url (and optional buffer) of this texture if url was null during construction.
  20282. * @param url the url of the texture
  20283. * @param buffer the buffer of the texture (defaults to null)
  20284. * @param onLoad callback called when the texture is loaded (defaults to null)
  20285. */
  20286. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20287. /**
  20288. * Finish the loading sequence of a texture flagged as delayed load.
  20289. * @hidden
  20290. */
  20291. delayLoad(): void;
  20292. private _prepareRowForTextureGeneration;
  20293. /**
  20294. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20295. * @returns the transform matrix of the texture.
  20296. */
  20297. getTextureMatrix(uBase?: number): Matrix;
  20298. /**
  20299. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20300. * @returns The reflection texture transform
  20301. */
  20302. getReflectionTextureMatrix(): Matrix;
  20303. /**
  20304. * Clones the texture.
  20305. * @returns the cloned texture
  20306. */
  20307. clone(): Texture;
  20308. /**
  20309. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20310. * @returns The JSON representation of the texture
  20311. */
  20312. serialize(): any;
  20313. /**
  20314. * Get the current class name of the texture useful for serialization or dynamic coding.
  20315. * @returns "Texture"
  20316. */
  20317. getClassName(): string;
  20318. /**
  20319. * Dispose the texture and release its associated resources.
  20320. */
  20321. dispose(): void;
  20322. /**
  20323. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20324. * @param parsedTexture Define the JSON representation of the texture
  20325. * @param scene Define the scene the parsed texture should be instantiated in
  20326. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20327. * @returns The parsed texture if successful
  20328. */
  20329. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20330. /**
  20331. * Creates a texture from its base 64 representation.
  20332. * @param data Define the base64 payload without the data: prefix
  20333. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20334. * @param scene Define the scene the texture should belong to
  20335. * @param noMipmap Forces the texture to not create mip map information if true
  20336. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20337. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20338. * @param onLoad define a callback triggered when the texture has been loaded
  20339. * @param onError define a callback triggered when an error occurred during the loading session
  20340. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20341. * @returns the created texture
  20342. */
  20343. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20344. /**
  20345. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20346. * @param data Define the base64 payload without the data: prefix
  20347. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20348. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20349. * @param scene Define the scene the texture should belong to
  20350. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20351. * @param noMipmap Forces the texture to not create mip map information if true
  20352. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20353. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20354. * @param onLoad define a callback triggered when the texture has been loaded
  20355. * @param onError define a callback triggered when an error occurred during the loading session
  20356. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20357. * @returns the created texture
  20358. */
  20359. 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;
  20360. }
  20361. }
  20362. declare module BABYLON {
  20363. /**
  20364. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20365. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20366. */
  20367. export class PostProcessManager {
  20368. private _scene;
  20369. private _indexBuffer;
  20370. private _vertexBuffers;
  20371. /**
  20372. * Creates a new instance PostProcess
  20373. * @param scene The scene that the post process is associated with.
  20374. */
  20375. constructor(scene: Scene);
  20376. private _prepareBuffers;
  20377. private _buildIndexBuffer;
  20378. /**
  20379. * Rebuilds the vertex buffers of the manager.
  20380. * @hidden
  20381. */
  20382. _rebuild(): void;
  20383. /**
  20384. * Prepares a frame to be run through a post process.
  20385. * @param sourceTexture The input texture to the post procesess. (default: null)
  20386. * @param postProcesses An array of post processes to be run. (default: null)
  20387. * @returns True if the post processes were able to be run.
  20388. * @hidden
  20389. */
  20390. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20391. /**
  20392. * Manually render a set of post processes to a texture.
  20393. * @param postProcesses An array of post processes to be run.
  20394. * @param targetTexture The target texture to render to.
  20395. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20396. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20397. * @param lodLevel defines which lod of the texture to render to
  20398. */
  20399. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20400. /**
  20401. * Finalize the result of the output of the postprocesses.
  20402. * @param doNotPresent If true the result will not be displayed to the screen.
  20403. * @param targetTexture The target texture to render to.
  20404. * @param faceIndex The index of the face to bind the target texture to.
  20405. * @param postProcesses The array of post processes to render.
  20406. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20407. * @hidden
  20408. */
  20409. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20410. /**
  20411. * Disposes of the post process manager.
  20412. */
  20413. dispose(): void;
  20414. }
  20415. }
  20416. declare module BABYLON {
  20417. /**
  20418. * This Helps creating a texture that will be created from a camera in your scene.
  20419. * It is basically a dynamic texture that could be used to create special effects for instance.
  20420. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20421. */
  20422. export class RenderTargetTexture extends Texture {
  20423. isCube: boolean;
  20424. /**
  20425. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20426. */
  20427. static readonly REFRESHRATE_RENDER_ONCE: number;
  20428. /**
  20429. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20430. */
  20431. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20432. /**
  20433. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20434. * the central point of your effect and can save a lot of performances.
  20435. */
  20436. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20437. /**
  20438. * Use this predicate to dynamically define the list of mesh you want to render.
  20439. * If set, the renderList property will be overwritten.
  20440. */
  20441. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20442. private _renderList;
  20443. /**
  20444. * Use this list to define the list of mesh you want to render.
  20445. */
  20446. get renderList(): Nullable<Array<AbstractMesh>>;
  20447. set renderList(value: Nullable<Array<AbstractMesh>>);
  20448. /**
  20449. * Use this function to overload the renderList array at rendering time.
  20450. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20451. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20452. * the cube (if the RTT is a cube, else layerOrFace=0).
  20453. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20454. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20455. * hold dummy elements!
  20456. */
  20457. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20458. private _hookArray;
  20459. /**
  20460. * Define if particles should be rendered in your texture.
  20461. */
  20462. renderParticles: boolean;
  20463. /**
  20464. * Define if sprites should be rendered in your texture.
  20465. */
  20466. renderSprites: boolean;
  20467. /**
  20468. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20469. */
  20470. coordinatesMode: number;
  20471. /**
  20472. * Define the camera used to render the texture.
  20473. */
  20474. activeCamera: Nullable<Camera>;
  20475. /**
  20476. * Override the render function of the texture with your own one.
  20477. */
  20478. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20479. /**
  20480. * Define if camera post processes should be use while rendering the texture.
  20481. */
  20482. useCameraPostProcesses: boolean;
  20483. /**
  20484. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20485. */
  20486. ignoreCameraViewport: boolean;
  20487. private _postProcessManager;
  20488. private _postProcesses;
  20489. private _resizeObserver;
  20490. /**
  20491. * An event triggered when the texture is unbind.
  20492. */
  20493. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20494. /**
  20495. * An event triggered when the texture is unbind.
  20496. */
  20497. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20498. private _onAfterUnbindObserver;
  20499. /**
  20500. * Set a after unbind callback in the texture.
  20501. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20502. */
  20503. set onAfterUnbind(callback: () => void);
  20504. /**
  20505. * An event triggered before rendering the texture
  20506. */
  20507. onBeforeRenderObservable: Observable<number>;
  20508. private _onBeforeRenderObserver;
  20509. /**
  20510. * Set a before render callback in the texture.
  20511. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20512. */
  20513. set onBeforeRender(callback: (faceIndex: number) => void);
  20514. /**
  20515. * An event triggered after rendering the texture
  20516. */
  20517. onAfterRenderObservable: Observable<number>;
  20518. private _onAfterRenderObserver;
  20519. /**
  20520. * Set a after render callback in the texture.
  20521. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20522. */
  20523. set onAfterRender(callback: (faceIndex: number) => void);
  20524. /**
  20525. * An event triggered after the texture clear
  20526. */
  20527. onClearObservable: Observable<Engine>;
  20528. private _onClearObserver;
  20529. /**
  20530. * Set a clear callback in the texture.
  20531. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20532. */
  20533. set onClear(callback: (Engine: Engine) => void);
  20534. /**
  20535. * An event triggered when the texture is resized.
  20536. */
  20537. onResizeObservable: Observable<RenderTargetTexture>;
  20538. /**
  20539. * Define the clear color of the Render Target if it should be different from the scene.
  20540. */
  20541. clearColor: Color4;
  20542. protected _size: number | {
  20543. width: number;
  20544. height: number;
  20545. layers?: number;
  20546. };
  20547. protected _initialSizeParameter: number | {
  20548. width: number;
  20549. height: number;
  20550. } | {
  20551. ratio: number;
  20552. };
  20553. protected _sizeRatio: Nullable<number>;
  20554. /** @hidden */
  20555. _generateMipMaps: boolean;
  20556. protected _renderingManager: RenderingManager;
  20557. /** @hidden */
  20558. _waitingRenderList: string[];
  20559. protected _doNotChangeAspectRatio: boolean;
  20560. protected _currentRefreshId: number;
  20561. protected _refreshRate: number;
  20562. protected _textureMatrix: Matrix;
  20563. protected _samples: number;
  20564. protected _renderTargetOptions: RenderTargetCreationOptions;
  20565. /**
  20566. * Gets render target creation options that were used.
  20567. */
  20568. get renderTargetOptions(): RenderTargetCreationOptions;
  20569. protected _engine: Engine;
  20570. protected _onRatioRescale(): void;
  20571. /**
  20572. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20573. * It must define where the camera used to render the texture is set
  20574. */
  20575. boundingBoxPosition: Vector3;
  20576. private _boundingBoxSize;
  20577. /**
  20578. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20579. * When defined, the cubemap will switch to local mode
  20580. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20581. * @example https://www.babylonjs-playground.com/#RNASML
  20582. */
  20583. set boundingBoxSize(value: Vector3);
  20584. get boundingBoxSize(): Vector3;
  20585. /**
  20586. * In case the RTT has been created with a depth texture, get the associated
  20587. * depth texture.
  20588. * Otherwise, return null.
  20589. */
  20590. get depthStencilTexture(): Nullable<InternalTexture>;
  20591. /**
  20592. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20593. * or used a shadow, depth texture...
  20594. * @param name The friendly name of the texture
  20595. * @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)
  20596. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20597. * @param generateMipMaps True if mip maps need to be generated after render.
  20598. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20599. * @param type The type of the buffer in the RTT (int, half float, float...)
  20600. * @param isCube True if a cube texture needs to be created
  20601. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20602. * @param generateDepthBuffer True to generate a depth buffer
  20603. * @param generateStencilBuffer True to generate a stencil buffer
  20604. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20605. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20606. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20607. */
  20608. constructor(name: string, size: number | {
  20609. width: number;
  20610. height: number;
  20611. layers?: number;
  20612. } | {
  20613. ratio: number;
  20614. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20615. /**
  20616. * Creates a depth stencil texture.
  20617. * This is only available in WebGL 2 or with the depth texture extension available.
  20618. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20619. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20620. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20621. */
  20622. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20623. private _processSizeParameter;
  20624. /**
  20625. * Define the number of samples to use in case of MSAA.
  20626. * It defaults to one meaning no MSAA has been enabled.
  20627. */
  20628. get samples(): number;
  20629. set samples(value: number);
  20630. /**
  20631. * Resets the refresh counter of the texture and start bak from scratch.
  20632. * Could be useful to regenerate the texture if it is setup to render only once.
  20633. */
  20634. resetRefreshCounter(): void;
  20635. /**
  20636. * Define the refresh rate of the texture or the rendering frequency.
  20637. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20638. */
  20639. get refreshRate(): number;
  20640. set refreshRate(value: number);
  20641. /**
  20642. * Adds a post process to the render target rendering passes.
  20643. * @param postProcess define the post process to add
  20644. */
  20645. addPostProcess(postProcess: PostProcess): void;
  20646. /**
  20647. * Clear all the post processes attached to the render target
  20648. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20649. */
  20650. clearPostProcesses(dispose?: boolean): void;
  20651. /**
  20652. * Remove one of the post process from the list of attached post processes to the texture
  20653. * @param postProcess define the post process to remove from the list
  20654. */
  20655. removePostProcess(postProcess: PostProcess): void;
  20656. /** @hidden */
  20657. _shouldRender(): boolean;
  20658. /**
  20659. * Gets the actual render size of the texture.
  20660. * @returns the width of the render size
  20661. */
  20662. getRenderSize(): number;
  20663. /**
  20664. * Gets the actual render width of the texture.
  20665. * @returns the width of the render size
  20666. */
  20667. getRenderWidth(): number;
  20668. /**
  20669. * Gets the actual render height of the texture.
  20670. * @returns the height of the render size
  20671. */
  20672. getRenderHeight(): number;
  20673. /**
  20674. * Gets the actual number of layers of the texture.
  20675. * @returns the number of layers
  20676. */
  20677. getRenderLayers(): number;
  20678. /**
  20679. * Get if the texture can be rescaled or not.
  20680. */
  20681. get canRescale(): boolean;
  20682. /**
  20683. * Resize the texture using a ratio.
  20684. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20685. */
  20686. scale(ratio: number): void;
  20687. /**
  20688. * Get the texture reflection matrix used to rotate/transform the reflection.
  20689. * @returns the reflection matrix
  20690. */
  20691. getReflectionTextureMatrix(): Matrix;
  20692. /**
  20693. * Resize the texture to a new desired size.
  20694. * Be carrefull as it will recreate all the data in the new texture.
  20695. * @param size Define the new size. It can be:
  20696. * - a number for squared texture,
  20697. * - an object containing { width: number, height: number }
  20698. * - or an object containing a ratio { ratio: number }
  20699. */
  20700. resize(size: number | {
  20701. width: number;
  20702. height: number;
  20703. } | {
  20704. ratio: number;
  20705. }): void;
  20706. private _defaultRenderListPrepared;
  20707. /**
  20708. * Renders all the objects from the render list into the texture.
  20709. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20710. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20711. */
  20712. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20713. private _bestReflectionRenderTargetDimension;
  20714. private _prepareRenderingManager;
  20715. /**
  20716. * @hidden
  20717. * @param faceIndex face index to bind to if this is a cubetexture
  20718. * @param layer defines the index of the texture to bind in the array
  20719. */
  20720. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20721. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20722. private renderToTarget;
  20723. /**
  20724. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20725. * This allowed control for front to back rendering or reversly depending of the special needs.
  20726. *
  20727. * @param renderingGroupId The rendering group id corresponding to its index
  20728. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20729. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20730. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20731. */
  20732. 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;
  20733. /**
  20734. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20735. *
  20736. * @param renderingGroupId The rendering group id corresponding to its index
  20737. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20738. */
  20739. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20740. /**
  20741. * Clones the texture.
  20742. * @returns the cloned texture
  20743. */
  20744. clone(): RenderTargetTexture;
  20745. /**
  20746. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20747. * @returns The JSON representation of the texture
  20748. */
  20749. serialize(): any;
  20750. /**
  20751. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20752. */
  20753. disposeFramebufferObjects(): void;
  20754. /**
  20755. * Dispose the texture and release its associated resources.
  20756. */
  20757. dispose(): void;
  20758. /** @hidden */
  20759. _rebuild(): void;
  20760. /**
  20761. * Clear the info related to rendering groups preventing retention point in material dispose.
  20762. */
  20763. freeRenderingGroups(): void;
  20764. /**
  20765. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20766. * @returns the view count
  20767. */
  20768. getViewCount(): number;
  20769. }
  20770. }
  20771. declare module BABYLON {
  20772. /**
  20773. * Options for compiling materials.
  20774. */
  20775. export interface IMaterialCompilationOptions {
  20776. /**
  20777. * Defines whether clip planes are enabled.
  20778. */
  20779. clipPlane: boolean;
  20780. /**
  20781. * Defines whether instances are enabled.
  20782. */
  20783. useInstances: boolean;
  20784. }
  20785. /**
  20786. * Base class for the main features of a material in Babylon.js
  20787. */
  20788. export class Material implements IAnimatable {
  20789. /**
  20790. * Returns the triangle fill mode
  20791. */
  20792. static readonly TriangleFillMode: number;
  20793. /**
  20794. * Returns the wireframe mode
  20795. */
  20796. static readonly WireFrameFillMode: number;
  20797. /**
  20798. * Returns the point fill mode
  20799. */
  20800. static readonly PointFillMode: number;
  20801. /**
  20802. * Returns the point list draw mode
  20803. */
  20804. static readonly PointListDrawMode: number;
  20805. /**
  20806. * Returns the line list draw mode
  20807. */
  20808. static readonly LineListDrawMode: number;
  20809. /**
  20810. * Returns the line loop draw mode
  20811. */
  20812. static readonly LineLoopDrawMode: number;
  20813. /**
  20814. * Returns the line strip draw mode
  20815. */
  20816. static readonly LineStripDrawMode: number;
  20817. /**
  20818. * Returns the triangle strip draw mode
  20819. */
  20820. static readonly TriangleStripDrawMode: number;
  20821. /**
  20822. * Returns the triangle fan draw mode
  20823. */
  20824. static readonly TriangleFanDrawMode: number;
  20825. /**
  20826. * Stores the clock-wise side orientation
  20827. */
  20828. static readonly ClockWiseSideOrientation: number;
  20829. /**
  20830. * Stores the counter clock-wise side orientation
  20831. */
  20832. static readonly CounterClockWiseSideOrientation: number;
  20833. /**
  20834. * The dirty texture flag value
  20835. */
  20836. static readonly TextureDirtyFlag: number;
  20837. /**
  20838. * The dirty light flag value
  20839. */
  20840. static readonly LightDirtyFlag: number;
  20841. /**
  20842. * The dirty fresnel flag value
  20843. */
  20844. static readonly FresnelDirtyFlag: number;
  20845. /**
  20846. * The dirty attribute flag value
  20847. */
  20848. static readonly AttributesDirtyFlag: number;
  20849. /**
  20850. * The dirty misc flag value
  20851. */
  20852. static readonly MiscDirtyFlag: number;
  20853. /**
  20854. * The all dirty flag value
  20855. */
  20856. static readonly AllDirtyFlag: number;
  20857. /**
  20858. * The ID of the material
  20859. */
  20860. id: string;
  20861. /**
  20862. * Gets or sets the unique id of the material
  20863. */
  20864. uniqueId: number;
  20865. /**
  20866. * The name of the material
  20867. */
  20868. name: string;
  20869. /**
  20870. * Gets or sets user defined metadata
  20871. */
  20872. metadata: any;
  20873. /**
  20874. * For internal use only. Please do not use.
  20875. */
  20876. reservedDataStore: any;
  20877. /**
  20878. * Specifies if the ready state should be checked on each call
  20879. */
  20880. checkReadyOnEveryCall: boolean;
  20881. /**
  20882. * Specifies if the ready state should be checked once
  20883. */
  20884. checkReadyOnlyOnce: boolean;
  20885. /**
  20886. * The state of the material
  20887. */
  20888. state: string;
  20889. /**
  20890. * The alpha value of the material
  20891. */
  20892. protected _alpha: number;
  20893. /**
  20894. * List of inspectable custom properties (used by the Inspector)
  20895. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20896. */
  20897. inspectableCustomProperties: IInspectable[];
  20898. /**
  20899. * Sets the alpha value of the material
  20900. */
  20901. set alpha(value: number);
  20902. /**
  20903. * Gets the alpha value of the material
  20904. */
  20905. get alpha(): number;
  20906. /**
  20907. * Specifies if back face culling is enabled
  20908. */
  20909. protected _backFaceCulling: boolean;
  20910. /**
  20911. * Sets the back-face culling state
  20912. */
  20913. set backFaceCulling(value: boolean);
  20914. /**
  20915. * Gets the back-face culling state
  20916. */
  20917. get backFaceCulling(): boolean;
  20918. /**
  20919. * Stores the value for side orientation
  20920. */
  20921. sideOrientation: number;
  20922. /**
  20923. * Callback triggered when the material is compiled
  20924. */
  20925. onCompiled: Nullable<(effect: Effect) => void>;
  20926. /**
  20927. * Callback triggered when an error occurs
  20928. */
  20929. onError: Nullable<(effect: Effect, errors: string) => void>;
  20930. /**
  20931. * Callback triggered to get the render target textures
  20932. */
  20933. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20934. /**
  20935. * Gets a boolean indicating that current material needs to register RTT
  20936. */
  20937. get hasRenderTargetTextures(): boolean;
  20938. /**
  20939. * Specifies if the material should be serialized
  20940. */
  20941. doNotSerialize: boolean;
  20942. /**
  20943. * @hidden
  20944. */
  20945. _storeEffectOnSubMeshes: boolean;
  20946. /**
  20947. * Stores the animations for the material
  20948. */
  20949. animations: Nullable<Array<Animation>>;
  20950. /**
  20951. * An event triggered when the material is disposed
  20952. */
  20953. onDisposeObservable: Observable<Material>;
  20954. /**
  20955. * An observer which watches for dispose events
  20956. */
  20957. private _onDisposeObserver;
  20958. private _onUnBindObservable;
  20959. /**
  20960. * Called during a dispose event
  20961. */
  20962. set onDispose(callback: () => void);
  20963. private _onBindObservable;
  20964. /**
  20965. * An event triggered when the material is bound
  20966. */
  20967. get onBindObservable(): Observable<AbstractMesh>;
  20968. /**
  20969. * An observer which watches for bind events
  20970. */
  20971. private _onBindObserver;
  20972. /**
  20973. * Called during a bind event
  20974. */
  20975. set onBind(callback: (Mesh: AbstractMesh) => void);
  20976. /**
  20977. * An event triggered when the material is unbound
  20978. */
  20979. get onUnBindObservable(): Observable<Material>;
  20980. /**
  20981. * Stores the value of the alpha mode
  20982. */
  20983. private _alphaMode;
  20984. /**
  20985. * Sets the value of the alpha mode.
  20986. *
  20987. * | Value | Type | Description |
  20988. * | --- | --- | --- |
  20989. * | 0 | ALPHA_DISABLE | |
  20990. * | 1 | ALPHA_ADD | |
  20991. * | 2 | ALPHA_COMBINE | |
  20992. * | 3 | ALPHA_SUBTRACT | |
  20993. * | 4 | ALPHA_MULTIPLY | |
  20994. * | 5 | ALPHA_MAXIMIZED | |
  20995. * | 6 | ALPHA_ONEONE | |
  20996. * | 7 | ALPHA_PREMULTIPLIED | |
  20997. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20998. * | 9 | ALPHA_INTERPOLATE | |
  20999. * | 10 | ALPHA_SCREENMODE | |
  21000. *
  21001. */
  21002. set alphaMode(value: number);
  21003. /**
  21004. * Gets the value of the alpha mode
  21005. */
  21006. get alphaMode(): number;
  21007. /**
  21008. * Stores the state of the need depth pre-pass value
  21009. */
  21010. private _needDepthPrePass;
  21011. /**
  21012. * Sets the need depth pre-pass value
  21013. */
  21014. set needDepthPrePass(value: boolean);
  21015. /**
  21016. * Gets the depth pre-pass value
  21017. */
  21018. get needDepthPrePass(): boolean;
  21019. /**
  21020. * Specifies if depth writing should be disabled
  21021. */
  21022. disableDepthWrite: boolean;
  21023. /**
  21024. * Specifies if depth writing should be forced
  21025. */
  21026. forceDepthWrite: boolean;
  21027. /**
  21028. * Specifies the depth function that should be used. 0 means the default engine function
  21029. */
  21030. depthFunction: number;
  21031. /**
  21032. * Specifies if there should be a separate pass for culling
  21033. */
  21034. separateCullingPass: boolean;
  21035. /**
  21036. * Stores the state specifing if fog should be enabled
  21037. */
  21038. private _fogEnabled;
  21039. /**
  21040. * Sets the state for enabling fog
  21041. */
  21042. set fogEnabled(value: boolean);
  21043. /**
  21044. * Gets the value of the fog enabled state
  21045. */
  21046. get fogEnabled(): boolean;
  21047. /**
  21048. * Stores the size of points
  21049. */
  21050. pointSize: number;
  21051. /**
  21052. * Stores the z offset value
  21053. */
  21054. zOffset: number;
  21055. /**
  21056. * Gets a value specifying if wireframe mode is enabled
  21057. */
  21058. get wireframe(): boolean;
  21059. /**
  21060. * Sets the state of wireframe mode
  21061. */
  21062. set wireframe(value: boolean);
  21063. /**
  21064. * Gets the value specifying if point clouds are enabled
  21065. */
  21066. get pointsCloud(): boolean;
  21067. /**
  21068. * Sets the state of point cloud mode
  21069. */
  21070. set pointsCloud(value: boolean);
  21071. /**
  21072. * Gets the material fill mode
  21073. */
  21074. get fillMode(): number;
  21075. /**
  21076. * Sets the material fill mode
  21077. */
  21078. set fillMode(value: number);
  21079. /**
  21080. * @hidden
  21081. * Stores the effects for the material
  21082. */
  21083. _effect: Nullable<Effect>;
  21084. /**
  21085. * Specifies if uniform buffers should be used
  21086. */
  21087. private _useUBO;
  21088. /**
  21089. * Stores a reference to the scene
  21090. */
  21091. private _scene;
  21092. /**
  21093. * Stores the fill mode state
  21094. */
  21095. private _fillMode;
  21096. /**
  21097. * Specifies if the depth write state should be cached
  21098. */
  21099. private _cachedDepthWriteState;
  21100. /**
  21101. * Specifies if the depth function state should be cached
  21102. */
  21103. private _cachedDepthFunctionState;
  21104. /**
  21105. * Stores the uniform buffer
  21106. */
  21107. protected _uniformBuffer: UniformBuffer;
  21108. /** @hidden */
  21109. _indexInSceneMaterialArray: number;
  21110. /** @hidden */
  21111. meshMap: Nullable<{
  21112. [id: string]: AbstractMesh | undefined;
  21113. }>;
  21114. /**
  21115. * Creates a material instance
  21116. * @param name defines the name of the material
  21117. * @param scene defines the scene to reference
  21118. * @param doNotAdd specifies if the material should be added to the scene
  21119. */
  21120. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21121. /**
  21122. * Returns a string representation of the current material
  21123. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21124. * @returns a string with material information
  21125. */
  21126. toString(fullDetails?: boolean): string;
  21127. /**
  21128. * Gets the class name of the material
  21129. * @returns a string with the class name of the material
  21130. */
  21131. getClassName(): string;
  21132. /**
  21133. * Specifies if updates for the material been locked
  21134. */
  21135. get isFrozen(): boolean;
  21136. /**
  21137. * Locks updates for the material
  21138. */
  21139. freeze(): void;
  21140. /**
  21141. * Unlocks updates for the material
  21142. */
  21143. unfreeze(): void;
  21144. /**
  21145. * Specifies if the material is ready to be used
  21146. * @param mesh defines the mesh to check
  21147. * @param useInstances specifies if instances should be used
  21148. * @returns a boolean indicating if the material is ready to be used
  21149. */
  21150. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21151. /**
  21152. * Specifies that the submesh is ready to be used
  21153. * @param mesh defines the mesh to check
  21154. * @param subMesh defines which submesh to check
  21155. * @param useInstances specifies that instances should be used
  21156. * @returns a boolean indicating that the submesh is ready or not
  21157. */
  21158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21159. /**
  21160. * Returns the material effect
  21161. * @returns the effect associated with the material
  21162. */
  21163. getEffect(): Nullable<Effect>;
  21164. /**
  21165. * Returns the current scene
  21166. * @returns a Scene
  21167. */
  21168. getScene(): Scene;
  21169. /**
  21170. * Specifies if the material will require alpha blending
  21171. * @returns a boolean specifying if alpha blending is needed
  21172. */
  21173. needAlphaBlending(): boolean;
  21174. /**
  21175. * Specifies if the mesh will require alpha blending
  21176. * @param mesh defines the mesh to check
  21177. * @returns a boolean specifying if alpha blending is needed for the mesh
  21178. */
  21179. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21180. /**
  21181. * Specifies if this material should be rendered in alpha test mode
  21182. * @returns a boolean specifying if an alpha test is needed.
  21183. */
  21184. needAlphaTesting(): boolean;
  21185. /**
  21186. * Gets the texture used for the alpha test
  21187. * @returns the texture to use for alpha testing
  21188. */
  21189. getAlphaTestTexture(): Nullable<BaseTexture>;
  21190. /**
  21191. * Marks the material to indicate that it needs to be re-calculated
  21192. */
  21193. markDirty(): void;
  21194. /** @hidden */
  21195. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21196. /**
  21197. * Binds the material to the mesh
  21198. * @param world defines the world transformation matrix
  21199. * @param mesh defines the mesh to bind the material to
  21200. */
  21201. bind(world: Matrix, mesh?: Mesh): void;
  21202. /**
  21203. * Binds the submesh to the material
  21204. * @param world defines the world transformation matrix
  21205. * @param mesh defines the mesh containing the submesh
  21206. * @param subMesh defines the submesh to bind the material to
  21207. */
  21208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21209. /**
  21210. * Binds the world matrix to the material
  21211. * @param world defines the world transformation matrix
  21212. */
  21213. bindOnlyWorldMatrix(world: Matrix): void;
  21214. /**
  21215. * Binds the scene's uniform buffer to the effect.
  21216. * @param effect defines the effect to bind to the scene uniform buffer
  21217. * @param sceneUbo defines the uniform buffer storing scene data
  21218. */
  21219. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21220. /**
  21221. * Binds the view matrix to the effect
  21222. * @param effect defines the effect to bind the view matrix to
  21223. */
  21224. bindView(effect: Effect): void;
  21225. /**
  21226. * Binds the view projection matrix to the effect
  21227. * @param effect defines the effect to bind the view projection matrix to
  21228. */
  21229. bindViewProjection(effect: Effect): void;
  21230. /**
  21231. * Specifies if material alpha testing should be turned on for the mesh
  21232. * @param mesh defines the mesh to check
  21233. */
  21234. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21235. /**
  21236. * Processes to execute after binding the material to a mesh
  21237. * @param mesh defines the rendered mesh
  21238. */
  21239. protected _afterBind(mesh?: Mesh): void;
  21240. /**
  21241. * Unbinds the material from the mesh
  21242. */
  21243. unbind(): void;
  21244. /**
  21245. * Gets the active textures from the material
  21246. * @returns an array of textures
  21247. */
  21248. getActiveTextures(): BaseTexture[];
  21249. /**
  21250. * Specifies if the material uses a texture
  21251. * @param texture defines the texture to check against the material
  21252. * @returns a boolean specifying if the material uses the texture
  21253. */
  21254. hasTexture(texture: BaseTexture): boolean;
  21255. /**
  21256. * Makes a duplicate of the material, and gives it a new name
  21257. * @param name defines the new name for the duplicated material
  21258. * @returns the cloned material
  21259. */
  21260. clone(name: string): Nullable<Material>;
  21261. /**
  21262. * Gets the meshes bound to the material
  21263. * @returns an array of meshes bound to the material
  21264. */
  21265. getBindedMeshes(): AbstractMesh[];
  21266. /**
  21267. * Force shader compilation
  21268. * @param mesh defines the mesh associated with this material
  21269. * @param onCompiled defines a function to execute once the material is compiled
  21270. * @param options defines the options to configure the compilation
  21271. * @param onError defines a function to execute if the material fails compiling
  21272. */
  21273. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21274. /**
  21275. * Force shader compilation
  21276. * @param mesh defines the mesh that will use this material
  21277. * @param options defines additional options for compiling the shaders
  21278. * @returns a promise that resolves when the compilation completes
  21279. */
  21280. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21281. private static readonly _AllDirtyCallBack;
  21282. private static readonly _ImageProcessingDirtyCallBack;
  21283. private static readonly _TextureDirtyCallBack;
  21284. private static readonly _FresnelDirtyCallBack;
  21285. private static readonly _MiscDirtyCallBack;
  21286. private static readonly _LightsDirtyCallBack;
  21287. private static readonly _AttributeDirtyCallBack;
  21288. private static _FresnelAndMiscDirtyCallBack;
  21289. private static _TextureAndMiscDirtyCallBack;
  21290. private static readonly _DirtyCallbackArray;
  21291. private static readonly _RunDirtyCallBacks;
  21292. /**
  21293. * Marks a define in the material to indicate that it needs to be re-computed
  21294. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21295. */
  21296. markAsDirty(flag: number): void;
  21297. /**
  21298. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21299. * @param func defines a function which checks material defines against the submeshes
  21300. */
  21301. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21302. /**
  21303. * Indicates that we need to re-calculated for all submeshes
  21304. */
  21305. protected _markAllSubMeshesAsAllDirty(): void;
  21306. /**
  21307. * Indicates that image processing needs to be re-calculated for all submeshes
  21308. */
  21309. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21310. /**
  21311. * Indicates that textures need to be re-calculated for all submeshes
  21312. */
  21313. protected _markAllSubMeshesAsTexturesDirty(): void;
  21314. /**
  21315. * Indicates that fresnel needs to be re-calculated for all submeshes
  21316. */
  21317. protected _markAllSubMeshesAsFresnelDirty(): void;
  21318. /**
  21319. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21320. */
  21321. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21322. /**
  21323. * Indicates that lights need to be re-calculated for all submeshes
  21324. */
  21325. protected _markAllSubMeshesAsLightsDirty(): void;
  21326. /**
  21327. * Indicates that attributes need to be re-calculated for all submeshes
  21328. */
  21329. protected _markAllSubMeshesAsAttributesDirty(): void;
  21330. /**
  21331. * Indicates that misc needs to be re-calculated for all submeshes
  21332. */
  21333. protected _markAllSubMeshesAsMiscDirty(): void;
  21334. /**
  21335. * Indicates that textures and misc need to be re-calculated for all submeshes
  21336. */
  21337. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21338. /**
  21339. * Disposes the material
  21340. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21341. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21342. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21343. */
  21344. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21345. /** @hidden */
  21346. private releaseVertexArrayObject;
  21347. /**
  21348. * Serializes this material
  21349. * @returns the serialized material object
  21350. */
  21351. serialize(): any;
  21352. /**
  21353. * Creates a material from parsed material data
  21354. * @param parsedMaterial defines parsed material data
  21355. * @param scene defines the hosting scene
  21356. * @param rootUrl defines the root URL to use to load textures
  21357. * @returns a new material
  21358. */
  21359. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21360. }
  21361. }
  21362. declare module BABYLON {
  21363. /**
  21364. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21365. * separate meshes. This can be use to improve performances.
  21366. * @see http://doc.babylonjs.com/how_to/multi_materials
  21367. */
  21368. export class MultiMaterial extends Material {
  21369. private _subMaterials;
  21370. /**
  21371. * Gets or Sets the list of Materials used within the multi material.
  21372. * They need to be ordered according to the submeshes order in the associated mesh
  21373. */
  21374. get subMaterials(): Nullable<Material>[];
  21375. set subMaterials(value: Nullable<Material>[]);
  21376. /**
  21377. * Function used to align with Node.getChildren()
  21378. * @returns the list of Materials used within the multi material
  21379. */
  21380. getChildren(): Nullable<Material>[];
  21381. /**
  21382. * Instantiates a new Multi Material
  21383. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21384. * separate meshes. This can be use to improve performances.
  21385. * @see http://doc.babylonjs.com/how_to/multi_materials
  21386. * @param name Define the name in the scene
  21387. * @param scene Define the scene the material belongs to
  21388. */
  21389. constructor(name: string, scene: Scene);
  21390. private _hookArray;
  21391. /**
  21392. * Get one of the submaterial by its index in the submaterials array
  21393. * @param index The index to look the sub material at
  21394. * @returns The Material if the index has been defined
  21395. */
  21396. getSubMaterial(index: number): Nullable<Material>;
  21397. /**
  21398. * Get the list of active textures for the whole sub materials list.
  21399. * @returns All the textures that will be used during the rendering
  21400. */
  21401. getActiveTextures(): BaseTexture[];
  21402. /**
  21403. * Gets the current class name of the material e.g. "MultiMaterial"
  21404. * Mainly use in serialization.
  21405. * @returns the class name
  21406. */
  21407. getClassName(): string;
  21408. /**
  21409. * Checks if the material is ready to render the requested sub mesh
  21410. * @param mesh Define the mesh the submesh belongs to
  21411. * @param subMesh Define the sub mesh to look readyness for
  21412. * @param useInstances Define whether or not the material is used with instances
  21413. * @returns true if ready, otherwise false
  21414. */
  21415. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21416. /**
  21417. * Clones the current material and its related sub materials
  21418. * @param name Define the name of the newly cloned material
  21419. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21420. * @returns the cloned material
  21421. */
  21422. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21423. /**
  21424. * Serializes the materials into a JSON representation.
  21425. * @returns the JSON representation
  21426. */
  21427. serialize(): any;
  21428. /**
  21429. * Dispose the material and release its associated resources
  21430. * @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)
  21431. * @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)
  21432. * @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)
  21433. */
  21434. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21435. /**
  21436. * Creates a MultiMaterial from parsed MultiMaterial data.
  21437. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21438. * @param scene defines the hosting scene
  21439. * @returns a new MultiMaterial
  21440. */
  21441. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21442. }
  21443. }
  21444. declare module BABYLON {
  21445. /**
  21446. * Base class for submeshes
  21447. */
  21448. export class BaseSubMesh {
  21449. /** @hidden */
  21450. _materialDefines: Nullable<MaterialDefines>;
  21451. /** @hidden */
  21452. _materialEffect: Nullable<Effect>;
  21453. /**
  21454. * Gets material defines used by the effect associated to the sub mesh
  21455. */
  21456. get materialDefines(): Nullable<MaterialDefines>;
  21457. /**
  21458. * Sets material defines used by the effect associated to the sub mesh
  21459. */
  21460. set materialDefines(defines: Nullable<MaterialDefines>);
  21461. /**
  21462. * Gets associated effect
  21463. */
  21464. get effect(): Nullable<Effect>;
  21465. /**
  21466. * Sets associated effect (effect used to render this submesh)
  21467. * @param effect defines the effect to associate with
  21468. * @param defines defines the set of defines used to compile this effect
  21469. */
  21470. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21471. }
  21472. /**
  21473. * Defines a subdivision inside a mesh
  21474. */
  21475. export class SubMesh extends BaseSubMesh implements ICullable {
  21476. /** the material index to use */
  21477. materialIndex: number;
  21478. /** vertex index start */
  21479. verticesStart: number;
  21480. /** vertices count */
  21481. verticesCount: number;
  21482. /** index start */
  21483. indexStart: number;
  21484. /** indices count */
  21485. indexCount: number;
  21486. /** @hidden */
  21487. _linesIndexCount: number;
  21488. private _mesh;
  21489. private _renderingMesh;
  21490. private _boundingInfo;
  21491. private _linesIndexBuffer;
  21492. /** @hidden */
  21493. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21494. /** @hidden */
  21495. _trianglePlanes: Plane[];
  21496. /** @hidden */
  21497. _lastColliderTransformMatrix: Nullable<Matrix>;
  21498. /** @hidden */
  21499. _renderId: number;
  21500. /** @hidden */
  21501. _alphaIndex: number;
  21502. /** @hidden */
  21503. _distanceToCamera: number;
  21504. /** @hidden */
  21505. _id: number;
  21506. private _currentMaterial;
  21507. /**
  21508. * Add a new submesh to a mesh
  21509. * @param materialIndex defines the material index to use
  21510. * @param verticesStart defines vertex index start
  21511. * @param verticesCount defines vertices count
  21512. * @param indexStart defines index start
  21513. * @param indexCount defines indices count
  21514. * @param mesh defines the parent mesh
  21515. * @param renderingMesh defines an optional rendering mesh
  21516. * @param createBoundingBox defines if bounding box should be created for this submesh
  21517. * @returns the new submesh
  21518. */
  21519. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21520. /**
  21521. * Creates a new submesh
  21522. * @param materialIndex defines the material index to use
  21523. * @param verticesStart defines vertex index start
  21524. * @param verticesCount defines vertices count
  21525. * @param indexStart defines index start
  21526. * @param indexCount defines indices count
  21527. * @param mesh defines the parent mesh
  21528. * @param renderingMesh defines an optional rendering mesh
  21529. * @param createBoundingBox defines if bounding box should be created for this submesh
  21530. */
  21531. constructor(
  21532. /** the material index to use */
  21533. materialIndex: number,
  21534. /** vertex index start */
  21535. verticesStart: number,
  21536. /** vertices count */
  21537. verticesCount: number,
  21538. /** index start */
  21539. indexStart: number,
  21540. /** indices count */
  21541. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21542. /**
  21543. * Returns true if this submesh covers the entire parent mesh
  21544. * @ignorenaming
  21545. */
  21546. get IsGlobal(): boolean;
  21547. /**
  21548. * Returns the submesh BoudingInfo object
  21549. * @returns current bounding info (or mesh's one if the submesh is global)
  21550. */
  21551. getBoundingInfo(): BoundingInfo;
  21552. /**
  21553. * Sets the submesh BoundingInfo
  21554. * @param boundingInfo defines the new bounding info to use
  21555. * @returns the SubMesh
  21556. */
  21557. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21558. /**
  21559. * Returns the mesh of the current submesh
  21560. * @return the parent mesh
  21561. */
  21562. getMesh(): AbstractMesh;
  21563. /**
  21564. * Returns the rendering mesh of the submesh
  21565. * @returns the rendering mesh (could be different from parent mesh)
  21566. */
  21567. getRenderingMesh(): Mesh;
  21568. /**
  21569. * Returns the submesh material
  21570. * @returns null or the current material
  21571. */
  21572. getMaterial(): Nullable<Material>;
  21573. /**
  21574. * Sets a new updated BoundingInfo object to the submesh
  21575. * @param data defines an optional position array to use to determine the bounding info
  21576. * @returns the SubMesh
  21577. */
  21578. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21579. /** @hidden */
  21580. _checkCollision(collider: Collider): boolean;
  21581. /**
  21582. * Updates the submesh BoundingInfo
  21583. * @param world defines the world matrix to use to update the bounding info
  21584. * @returns the submesh
  21585. */
  21586. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21587. /**
  21588. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21589. * @param frustumPlanes defines the frustum planes
  21590. * @returns true if the submesh is intersecting with the frustum
  21591. */
  21592. isInFrustum(frustumPlanes: Plane[]): boolean;
  21593. /**
  21594. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21595. * @param frustumPlanes defines the frustum planes
  21596. * @returns true if the submesh is inside the frustum
  21597. */
  21598. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21599. /**
  21600. * Renders the submesh
  21601. * @param enableAlphaMode defines if alpha needs to be used
  21602. * @returns the submesh
  21603. */
  21604. render(enableAlphaMode: boolean): SubMesh;
  21605. /**
  21606. * @hidden
  21607. */
  21608. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21609. /**
  21610. * Checks if the submesh intersects with a ray
  21611. * @param ray defines the ray to test
  21612. * @returns true is the passed ray intersects the submesh bounding box
  21613. */
  21614. canIntersects(ray: Ray): boolean;
  21615. /**
  21616. * Intersects current submesh with a ray
  21617. * @param ray defines the ray to test
  21618. * @param positions defines mesh's positions array
  21619. * @param indices defines mesh's indices array
  21620. * @param fastCheck defines if only bounding info should be used
  21621. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21622. * @returns intersection info or null if no intersection
  21623. */
  21624. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21625. /** @hidden */
  21626. private _intersectLines;
  21627. /** @hidden */
  21628. private _intersectUnIndexedLines;
  21629. /** @hidden */
  21630. private _intersectTriangles;
  21631. /** @hidden */
  21632. private _intersectUnIndexedTriangles;
  21633. /** @hidden */
  21634. _rebuild(): void;
  21635. /**
  21636. * Creates a new submesh from the passed mesh
  21637. * @param newMesh defines the new hosting mesh
  21638. * @param newRenderingMesh defines an optional rendering mesh
  21639. * @returns the new submesh
  21640. */
  21641. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21642. /**
  21643. * Release associated resources
  21644. */
  21645. dispose(): void;
  21646. /**
  21647. * Gets the class name
  21648. * @returns the string "SubMesh".
  21649. */
  21650. getClassName(): string;
  21651. /**
  21652. * Creates a new submesh from indices data
  21653. * @param materialIndex the index of the main mesh material
  21654. * @param startIndex the index where to start the copy in the mesh indices array
  21655. * @param indexCount the number of indices to copy then from the startIndex
  21656. * @param mesh the main mesh to create the submesh from
  21657. * @param renderingMesh the optional rendering mesh
  21658. * @returns a new submesh
  21659. */
  21660. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21661. }
  21662. }
  21663. declare module BABYLON {
  21664. /**
  21665. * Class used to represent data loading progression
  21666. */
  21667. export class SceneLoaderFlags {
  21668. private static _ForceFullSceneLoadingForIncremental;
  21669. private static _ShowLoadingScreen;
  21670. private static _CleanBoneMatrixWeights;
  21671. private static _loggingLevel;
  21672. /**
  21673. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21674. */
  21675. static get ForceFullSceneLoadingForIncremental(): boolean;
  21676. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21677. /**
  21678. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21679. */
  21680. static get ShowLoadingScreen(): boolean;
  21681. static set ShowLoadingScreen(value: boolean);
  21682. /**
  21683. * Defines the current logging level (while loading the scene)
  21684. * @ignorenaming
  21685. */
  21686. static get loggingLevel(): number;
  21687. static set loggingLevel(value: number);
  21688. /**
  21689. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21690. */
  21691. static get CleanBoneMatrixWeights(): boolean;
  21692. static set CleanBoneMatrixWeights(value: boolean);
  21693. }
  21694. }
  21695. declare module BABYLON {
  21696. /**
  21697. * Class used to store geometry data (vertex buffers + index buffer)
  21698. */
  21699. export class Geometry implements IGetSetVerticesData {
  21700. /**
  21701. * Gets or sets the ID of the geometry
  21702. */
  21703. id: string;
  21704. /**
  21705. * Gets or sets the unique ID of the geometry
  21706. */
  21707. uniqueId: number;
  21708. /**
  21709. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21710. */
  21711. delayLoadState: number;
  21712. /**
  21713. * Gets the file containing the data to load when running in delay load state
  21714. */
  21715. delayLoadingFile: Nullable<string>;
  21716. /**
  21717. * Callback called when the geometry is updated
  21718. */
  21719. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21720. private _scene;
  21721. private _engine;
  21722. private _meshes;
  21723. private _totalVertices;
  21724. /** @hidden */
  21725. _indices: IndicesArray;
  21726. /** @hidden */
  21727. _vertexBuffers: {
  21728. [key: string]: VertexBuffer;
  21729. };
  21730. private _isDisposed;
  21731. private _extend;
  21732. private _boundingBias;
  21733. /** @hidden */
  21734. _delayInfo: Array<string>;
  21735. private _indexBuffer;
  21736. private _indexBufferIsUpdatable;
  21737. /** @hidden */
  21738. _boundingInfo: Nullable<BoundingInfo>;
  21739. /** @hidden */
  21740. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21741. /** @hidden */
  21742. _softwareSkinningFrameId: number;
  21743. private _vertexArrayObjects;
  21744. private _updatable;
  21745. /** @hidden */
  21746. _positions: Nullable<Vector3[]>;
  21747. /**
  21748. * 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
  21749. */
  21750. get boundingBias(): Vector2;
  21751. /**
  21752. * 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
  21753. */
  21754. set boundingBias(value: Vector2);
  21755. /**
  21756. * Static function used to attach a new empty geometry to a mesh
  21757. * @param mesh defines the mesh to attach the geometry to
  21758. * @returns the new Geometry
  21759. */
  21760. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21761. /**
  21762. * Creates a new geometry
  21763. * @param id defines the unique ID
  21764. * @param scene defines the hosting scene
  21765. * @param vertexData defines the VertexData used to get geometry data
  21766. * @param updatable defines if geometry must be updatable (false by default)
  21767. * @param mesh defines the mesh that will be associated with the geometry
  21768. */
  21769. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21770. /**
  21771. * Gets the current extend of the geometry
  21772. */
  21773. get extend(): {
  21774. minimum: Vector3;
  21775. maximum: Vector3;
  21776. };
  21777. /**
  21778. * Gets the hosting scene
  21779. * @returns the hosting Scene
  21780. */
  21781. getScene(): Scene;
  21782. /**
  21783. * Gets the hosting engine
  21784. * @returns the hosting Engine
  21785. */
  21786. getEngine(): Engine;
  21787. /**
  21788. * Defines if the geometry is ready to use
  21789. * @returns true if the geometry is ready to be used
  21790. */
  21791. isReady(): boolean;
  21792. /**
  21793. * Gets a value indicating that the geometry should not be serialized
  21794. */
  21795. get doNotSerialize(): boolean;
  21796. /** @hidden */
  21797. _rebuild(): void;
  21798. /**
  21799. * Affects all geometry data in one call
  21800. * @param vertexData defines the geometry data
  21801. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21802. */
  21803. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21804. /**
  21805. * Set specific vertex data
  21806. * @param kind defines the data kind (Position, normal, etc...)
  21807. * @param data defines the vertex data to use
  21808. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21809. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21810. */
  21811. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21812. /**
  21813. * Removes a specific vertex data
  21814. * @param kind defines the data kind (Position, normal, etc...)
  21815. */
  21816. removeVerticesData(kind: string): void;
  21817. /**
  21818. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21819. * @param buffer defines the vertex buffer to use
  21820. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21821. */
  21822. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21823. /**
  21824. * Update a specific vertex buffer
  21825. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21826. * It will do nothing if the buffer is not updatable
  21827. * @param kind defines the data kind (Position, normal, etc...)
  21828. * @param data defines the data to use
  21829. * @param offset defines the offset in the target buffer where to store the data
  21830. * @param useBytes set to true if the offset is in bytes
  21831. */
  21832. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21833. /**
  21834. * Update a specific vertex buffer
  21835. * This function will create a new buffer if the current one is not updatable
  21836. * @param kind defines the data kind (Position, normal, etc...)
  21837. * @param data defines the data to use
  21838. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21839. */
  21840. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21841. private _updateBoundingInfo;
  21842. /** @hidden */
  21843. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21844. /**
  21845. * Gets total number of vertices
  21846. * @returns the total number of vertices
  21847. */
  21848. getTotalVertices(): number;
  21849. /**
  21850. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21851. * @param kind defines the data kind (Position, normal, etc...)
  21852. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21853. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21854. * @returns a float array containing vertex data
  21855. */
  21856. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21857. /**
  21858. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21859. * @param kind defines the data kind (Position, normal, etc...)
  21860. * @returns true if the vertex buffer with the specified kind is updatable
  21861. */
  21862. isVertexBufferUpdatable(kind: string): boolean;
  21863. /**
  21864. * Gets a specific vertex buffer
  21865. * @param kind defines the data kind (Position, normal, etc...)
  21866. * @returns a VertexBuffer
  21867. */
  21868. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21869. /**
  21870. * Returns all vertex buffers
  21871. * @return an object holding all vertex buffers indexed by kind
  21872. */
  21873. getVertexBuffers(): Nullable<{
  21874. [key: string]: VertexBuffer;
  21875. }>;
  21876. /**
  21877. * Gets a boolean indicating if specific vertex buffer is present
  21878. * @param kind defines the data kind (Position, normal, etc...)
  21879. * @returns true if data is present
  21880. */
  21881. isVerticesDataPresent(kind: string): boolean;
  21882. /**
  21883. * Gets a list of all attached data kinds (Position, normal, etc...)
  21884. * @returns a list of string containing all kinds
  21885. */
  21886. getVerticesDataKinds(): string[];
  21887. /**
  21888. * Update index buffer
  21889. * @param indices defines the indices to store in the index buffer
  21890. * @param offset defines the offset in the target buffer where to store the data
  21891. * @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)
  21892. */
  21893. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21894. /**
  21895. * Creates a new index buffer
  21896. * @param indices defines the indices to store in the index buffer
  21897. * @param totalVertices defines the total number of vertices (could be null)
  21898. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21899. */
  21900. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21901. /**
  21902. * Return the total number of indices
  21903. * @returns the total number of indices
  21904. */
  21905. getTotalIndices(): number;
  21906. /**
  21907. * Gets the index buffer array
  21908. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21909. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21910. * @returns the index buffer array
  21911. */
  21912. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21913. /**
  21914. * Gets the index buffer
  21915. * @return the index buffer
  21916. */
  21917. getIndexBuffer(): Nullable<DataBuffer>;
  21918. /** @hidden */
  21919. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21920. /**
  21921. * Release the associated resources for a specific mesh
  21922. * @param mesh defines the source mesh
  21923. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21924. */
  21925. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21926. /**
  21927. * Apply current geometry to a given mesh
  21928. * @param mesh defines the mesh to apply geometry to
  21929. */
  21930. applyToMesh(mesh: Mesh): void;
  21931. private _updateExtend;
  21932. private _applyToMesh;
  21933. private notifyUpdate;
  21934. /**
  21935. * Load the geometry if it was flagged as delay loaded
  21936. * @param scene defines the hosting scene
  21937. * @param onLoaded defines a callback called when the geometry is loaded
  21938. */
  21939. load(scene: Scene, onLoaded?: () => void): void;
  21940. private _queueLoad;
  21941. /**
  21942. * Invert the geometry to move from a right handed system to a left handed one.
  21943. */
  21944. toLeftHanded(): void;
  21945. /** @hidden */
  21946. _resetPointsArrayCache(): void;
  21947. /** @hidden */
  21948. _generatePointsArray(): boolean;
  21949. /**
  21950. * Gets a value indicating if the geometry is disposed
  21951. * @returns true if the geometry was disposed
  21952. */
  21953. isDisposed(): boolean;
  21954. private _disposeVertexArrayObjects;
  21955. /**
  21956. * Free all associated resources
  21957. */
  21958. dispose(): void;
  21959. /**
  21960. * Clone the current geometry into a new geometry
  21961. * @param id defines the unique ID of the new geometry
  21962. * @returns a new geometry object
  21963. */
  21964. copy(id: string): Geometry;
  21965. /**
  21966. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21967. * @return a JSON representation of the current geometry data (without the vertices data)
  21968. */
  21969. serialize(): any;
  21970. private toNumberArray;
  21971. /**
  21972. * Serialize all vertices data into a JSON oject
  21973. * @returns a JSON representation of the current geometry data
  21974. */
  21975. serializeVerticeData(): any;
  21976. /**
  21977. * Extracts a clone of a mesh geometry
  21978. * @param mesh defines the source mesh
  21979. * @param id defines the unique ID of the new geometry object
  21980. * @returns the new geometry object
  21981. */
  21982. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21983. /**
  21984. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21985. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21986. * Be aware Math.random() could cause collisions, but:
  21987. * "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"
  21988. * @returns a string containing a new GUID
  21989. */
  21990. static RandomId(): string;
  21991. /** @hidden */
  21992. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21993. private static _CleanMatricesWeights;
  21994. /**
  21995. * Create a new geometry from persisted data (Using .babylon file format)
  21996. * @param parsedVertexData defines the persisted data
  21997. * @param scene defines the hosting scene
  21998. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21999. * @returns the new geometry object
  22000. */
  22001. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22002. }
  22003. }
  22004. declare module BABYLON {
  22005. /**
  22006. * Define an interface for all classes that will get and set the data on vertices
  22007. */
  22008. export interface IGetSetVerticesData {
  22009. /**
  22010. * Gets a boolean indicating if specific vertex data is present
  22011. * @param kind defines the vertex data kind to use
  22012. * @returns true is data kind is present
  22013. */
  22014. isVerticesDataPresent(kind: string): boolean;
  22015. /**
  22016. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22017. * @param kind defines the data kind (Position, normal, etc...)
  22018. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22019. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22020. * @returns a float array containing vertex data
  22021. */
  22022. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22023. /**
  22024. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22025. * @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.
  22026. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22027. * @returns the indices array or an empty array if the mesh has no geometry
  22028. */
  22029. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22030. /**
  22031. * Set specific vertex data
  22032. * @param kind defines the data kind (Position, normal, etc...)
  22033. * @param data defines the vertex data to use
  22034. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22035. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22036. */
  22037. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22038. /**
  22039. * Update a specific associated vertex buffer
  22040. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22041. * - VertexBuffer.PositionKind
  22042. * - VertexBuffer.UVKind
  22043. * - VertexBuffer.UV2Kind
  22044. * - VertexBuffer.UV3Kind
  22045. * - VertexBuffer.UV4Kind
  22046. * - VertexBuffer.UV5Kind
  22047. * - VertexBuffer.UV6Kind
  22048. * - VertexBuffer.ColorKind
  22049. * - VertexBuffer.MatricesIndicesKind
  22050. * - VertexBuffer.MatricesIndicesExtraKind
  22051. * - VertexBuffer.MatricesWeightsKind
  22052. * - VertexBuffer.MatricesWeightsExtraKind
  22053. * @param data defines the data source
  22054. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22055. * @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)
  22056. */
  22057. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22058. /**
  22059. * Creates a new index buffer
  22060. * @param indices defines the indices to store in the index buffer
  22061. * @param totalVertices defines the total number of vertices (could be null)
  22062. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22063. */
  22064. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22065. }
  22066. /**
  22067. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22068. */
  22069. export class VertexData {
  22070. /**
  22071. * Mesh side orientation : usually the external or front surface
  22072. */
  22073. static readonly FRONTSIDE: number;
  22074. /**
  22075. * Mesh side orientation : usually the internal or back surface
  22076. */
  22077. static readonly BACKSIDE: number;
  22078. /**
  22079. * Mesh side orientation : both internal and external or front and back surfaces
  22080. */
  22081. static readonly DOUBLESIDE: number;
  22082. /**
  22083. * Mesh side orientation : by default, `FRONTSIDE`
  22084. */
  22085. static readonly DEFAULTSIDE: number;
  22086. /**
  22087. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22088. */
  22089. positions: Nullable<FloatArray>;
  22090. /**
  22091. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22092. */
  22093. normals: Nullable<FloatArray>;
  22094. /**
  22095. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22096. */
  22097. tangents: Nullable<FloatArray>;
  22098. /**
  22099. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22100. */
  22101. uvs: Nullable<FloatArray>;
  22102. /**
  22103. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22104. */
  22105. uvs2: Nullable<FloatArray>;
  22106. /**
  22107. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22108. */
  22109. uvs3: Nullable<FloatArray>;
  22110. /**
  22111. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22112. */
  22113. uvs4: Nullable<FloatArray>;
  22114. /**
  22115. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22116. */
  22117. uvs5: Nullable<FloatArray>;
  22118. /**
  22119. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22120. */
  22121. uvs6: Nullable<FloatArray>;
  22122. /**
  22123. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22124. */
  22125. colors: Nullable<FloatArray>;
  22126. /**
  22127. * 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).
  22128. */
  22129. matricesIndices: Nullable<FloatArray>;
  22130. /**
  22131. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22132. */
  22133. matricesWeights: Nullable<FloatArray>;
  22134. /**
  22135. * An array extending the number of possible indices
  22136. */
  22137. matricesIndicesExtra: Nullable<FloatArray>;
  22138. /**
  22139. * An array extending the number of possible weights when the number of indices is extended
  22140. */
  22141. matricesWeightsExtra: Nullable<FloatArray>;
  22142. /**
  22143. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22144. */
  22145. indices: Nullable<IndicesArray>;
  22146. /**
  22147. * Uses the passed data array to set the set the values for the specified kind of data
  22148. * @param data a linear array of floating numbers
  22149. * @param kind the type of data that is being set, eg positions, colors etc
  22150. */
  22151. set(data: FloatArray, kind: string): void;
  22152. /**
  22153. * Associates the vertexData to the passed Mesh.
  22154. * Sets it as updatable or not (default `false`)
  22155. * @param mesh the mesh the vertexData is applied to
  22156. * @param updatable when used and having the value true allows new data to update the vertexData
  22157. * @returns the VertexData
  22158. */
  22159. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22160. /**
  22161. * Associates the vertexData to the passed Geometry.
  22162. * Sets it as updatable or not (default `false`)
  22163. * @param geometry the geometry the vertexData is applied to
  22164. * @param updatable when used and having the value true allows new data to update the vertexData
  22165. * @returns VertexData
  22166. */
  22167. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22168. /**
  22169. * Updates the associated mesh
  22170. * @param mesh the mesh to be updated
  22171. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22172. * @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
  22173. * @returns VertexData
  22174. */
  22175. updateMesh(mesh: Mesh): VertexData;
  22176. /**
  22177. * Updates the associated geometry
  22178. * @param geometry the geometry to be updated
  22179. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22180. * @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
  22181. * @returns VertexData.
  22182. */
  22183. updateGeometry(geometry: Geometry): VertexData;
  22184. private _applyTo;
  22185. private _update;
  22186. /**
  22187. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22188. * @param matrix the transforming matrix
  22189. * @returns the VertexData
  22190. */
  22191. transform(matrix: Matrix): VertexData;
  22192. /**
  22193. * Merges the passed VertexData into the current one
  22194. * @param other the VertexData to be merged into the current one
  22195. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22196. * @returns the modified VertexData
  22197. */
  22198. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22199. private _mergeElement;
  22200. private _validate;
  22201. /**
  22202. * Serializes the VertexData
  22203. * @returns a serialized object
  22204. */
  22205. serialize(): any;
  22206. /**
  22207. * Extracts the vertexData from a mesh
  22208. * @param mesh the mesh from which to extract the VertexData
  22209. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22210. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22211. * @returns the object VertexData associated to the passed mesh
  22212. */
  22213. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22214. /**
  22215. * Extracts the vertexData from the geometry
  22216. * @param geometry the geometry from which to extract the VertexData
  22217. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22218. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22219. * @returns the object VertexData associated to the passed mesh
  22220. */
  22221. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22222. private static _ExtractFrom;
  22223. /**
  22224. * Creates the VertexData for a Ribbon
  22225. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22226. * * pathArray array of paths, each of which an array of successive Vector3
  22227. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22228. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22229. * * 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
  22230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22231. * * 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)
  22232. * * 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)
  22233. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22234. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22235. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22236. * @returns the VertexData of the ribbon
  22237. */
  22238. static CreateRibbon(options: {
  22239. pathArray: Vector3[][];
  22240. closeArray?: boolean;
  22241. closePath?: boolean;
  22242. offset?: number;
  22243. sideOrientation?: number;
  22244. frontUVs?: Vector4;
  22245. backUVs?: Vector4;
  22246. invertUV?: boolean;
  22247. uvs?: Vector2[];
  22248. colors?: Color4[];
  22249. }): VertexData;
  22250. /**
  22251. * Creates the VertexData for a box
  22252. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22253. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22254. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22255. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22256. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22257. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22258. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22260. * * 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)
  22261. * * 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)
  22262. * @returns the VertexData of the box
  22263. */
  22264. static CreateBox(options: {
  22265. size?: number;
  22266. width?: number;
  22267. height?: number;
  22268. depth?: number;
  22269. faceUV?: Vector4[];
  22270. faceColors?: Color4[];
  22271. sideOrientation?: number;
  22272. frontUVs?: Vector4;
  22273. backUVs?: Vector4;
  22274. }): VertexData;
  22275. /**
  22276. * Creates the VertexData for a tiled box
  22277. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22278. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22279. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22280. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22281. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22282. * @returns the VertexData of the box
  22283. */
  22284. static CreateTiledBox(options: {
  22285. pattern?: number;
  22286. width?: number;
  22287. height?: number;
  22288. depth?: number;
  22289. tileSize?: number;
  22290. tileWidth?: number;
  22291. tileHeight?: number;
  22292. alignHorizontal?: number;
  22293. alignVertical?: number;
  22294. faceUV?: Vector4[];
  22295. faceColors?: Color4[];
  22296. sideOrientation?: number;
  22297. }): VertexData;
  22298. /**
  22299. * Creates the VertexData for a tiled plane
  22300. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22301. * * pattern a limited pattern arrangement depending on the number
  22302. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22303. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22304. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22306. * * 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)
  22307. * * 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)
  22308. * @returns the VertexData of the tiled plane
  22309. */
  22310. static CreateTiledPlane(options: {
  22311. pattern?: number;
  22312. tileSize?: number;
  22313. tileWidth?: number;
  22314. tileHeight?: number;
  22315. size?: number;
  22316. width?: number;
  22317. height?: number;
  22318. alignHorizontal?: number;
  22319. alignVertical?: number;
  22320. sideOrientation?: number;
  22321. frontUVs?: Vector4;
  22322. backUVs?: Vector4;
  22323. }): VertexData;
  22324. /**
  22325. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22326. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22327. * * segments sets the number of horizontal strips optional, default 32
  22328. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22329. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22330. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22331. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22332. * * 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
  22333. * * 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
  22334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22335. * * 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)
  22336. * * 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)
  22337. * @returns the VertexData of the ellipsoid
  22338. */
  22339. static CreateSphere(options: {
  22340. segments?: number;
  22341. diameter?: number;
  22342. diameterX?: number;
  22343. diameterY?: number;
  22344. diameterZ?: number;
  22345. arc?: number;
  22346. slice?: number;
  22347. sideOrientation?: number;
  22348. frontUVs?: Vector4;
  22349. backUVs?: Vector4;
  22350. }): VertexData;
  22351. /**
  22352. * Creates the VertexData for a cylinder, cone or prism
  22353. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22354. * * height sets the height (y direction) of the cylinder, optional, default 2
  22355. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22356. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22357. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22358. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22359. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22360. * * 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
  22361. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22362. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22363. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22364. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22365. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22366. * * 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)
  22367. * * 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)
  22368. * @returns the VertexData of the cylinder, cone or prism
  22369. */
  22370. static CreateCylinder(options: {
  22371. height?: number;
  22372. diameterTop?: number;
  22373. diameterBottom?: number;
  22374. diameter?: number;
  22375. tessellation?: number;
  22376. subdivisions?: number;
  22377. arc?: number;
  22378. faceColors?: Color4[];
  22379. faceUV?: Vector4[];
  22380. hasRings?: boolean;
  22381. enclose?: boolean;
  22382. sideOrientation?: number;
  22383. frontUVs?: Vector4;
  22384. backUVs?: Vector4;
  22385. }): VertexData;
  22386. /**
  22387. * Creates the VertexData for a torus
  22388. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22389. * * diameter the diameter of the torus, optional default 1
  22390. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22391. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22393. * * 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)
  22394. * * 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)
  22395. * @returns the VertexData of the torus
  22396. */
  22397. static CreateTorus(options: {
  22398. diameter?: number;
  22399. thickness?: number;
  22400. tessellation?: number;
  22401. sideOrientation?: number;
  22402. frontUVs?: Vector4;
  22403. backUVs?: Vector4;
  22404. }): VertexData;
  22405. /**
  22406. * Creates the VertexData of the LineSystem
  22407. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22408. * - lines an array of lines, each line being an array of successive Vector3
  22409. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22410. * @returns the VertexData of the LineSystem
  22411. */
  22412. static CreateLineSystem(options: {
  22413. lines: Vector3[][];
  22414. colors?: Nullable<Color4[][]>;
  22415. }): VertexData;
  22416. /**
  22417. * Create the VertexData for a DashedLines
  22418. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22419. * - points an array successive Vector3
  22420. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22421. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22422. * - dashNb the intended total number of dashes, optional, default 200
  22423. * @returns the VertexData for the DashedLines
  22424. */
  22425. static CreateDashedLines(options: {
  22426. points: Vector3[];
  22427. dashSize?: number;
  22428. gapSize?: number;
  22429. dashNb?: number;
  22430. }): VertexData;
  22431. /**
  22432. * Creates the VertexData for a Ground
  22433. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22434. * - width the width (x direction) of the ground, optional, default 1
  22435. * - height the height (z direction) of the ground, optional, default 1
  22436. * - subdivisions the number of subdivisions per side, optional, default 1
  22437. * @returns the VertexData of the Ground
  22438. */
  22439. static CreateGround(options: {
  22440. width?: number;
  22441. height?: number;
  22442. subdivisions?: number;
  22443. subdivisionsX?: number;
  22444. subdivisionsY?: number;
  22445. }): VertexData;
  22446. /**
  22447. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22448. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22449. * * xmin the ground minimum X coordinate, optional, default -1
  22450. * * zmin the ground minimum Z coordinate, optional, default -1
  22451. * * xmax the ground maximum X coordinate, optional, default 1
  22452. * * zmax the ground maximum Z coordinate, optional, default 1
  22453. * * 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}
  22454. * * 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}
  22455. * @returns the VertexData of the TiledGround
  22456. */
  22457. static CreateTiledGround(options: {
  22458. xmin: number;
  22459. zmin: number;
  22460. xmax: number;
  22461. zmax: number;
  22462. subdivisions?: {
  22463. w: number;
  22464. h: number;
  22465. };
  22466. precision?: {
  22467. w: number;
  22468. h: number;
  22469. };
  22470. }): VertexData;
  22471. /**
  22472. * Creates the VertexData of the Ground designed from a heightmap
  22473. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22474. * * width the width (x direction) of the ground
  22475. * * height the height (z direction) of the ground
  22476. * * subdivisions the number of subdivisions per side
  22477. * * minHeight the minimum altitude on the ground, optional, default 0
  22478. * * maxHeight the maximum altitude on the ground, optional default 1
  22479. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22480. * * buffer the array holding the image color data
  22481. * * bufferWidth the width of image
  22482. * * bufferHeight the height of image
  22483. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22484. * @returns the VertexData of the Ground designed from a heightmap
  22485. */
  22486. static CreateGroundFromHeightMap(options: {
  22487. width: number;
  22488. height: number;
  22489. subdivisions: number;
  22490. minHeight: number;
  22491. maxHeight: number;
  22492. colorFilter: Color3;
  22493. buffer: Uint8Array;
  22494. bufferWidth: number;
  22495. bufferHeight: number;
  22496. alphaFilter: number;
  22497. }): VertexData;
  22498. /**
  22499. * Creates the VertexData for a Plane
  22500. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22501. * * size sets the width and height of the plane to the value of size, optional default 1
  22502. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22503. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22505. * * 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)
  22506. * * 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)
  22507. * @returns the VertexData of the box
  22508. */
  22509. static CreatePlane(options: {
  22510. size?: number;
  22511. width?: number;
  22512. height?: number;
  22513. sideOrientation?: number;
  22514. frontUVs?: Vector4;
  22515. backUVs?: Vector4;
  22516. }): VertexData;
  22517. /**
  22518. * Creates the VertexData of the Disc or regular Polygon
  22519. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22520. * * radius the radius of the disc, optional default 0.5
  22521. * * tessellation the number of polygon sides, optional, default 64
  22522. * * 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
  22523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22524. * * 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)
  22525. * * 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)
  22526. * @returns the VertexData of the box
  22527. */
  22528. static CreateDisc(options: {
  22529. radius?: number;
  22530. tessellation?: number;
  22531. arc?: number;
  22532. sideOrientation?: number;
  22533. frontUVs?: Vector4;
  22534. backUVs?: Vector4;
  22535. }): VertexData;
  22536. /**
  22537. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22538. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22539. * @param polygon a mesh built from polygonTriangulation.build()
  22540. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22541. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22542. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22543. * @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)
  22544. * @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)
  22545. * @returns the VertexData of the Polygon
  22546. */
  22547. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22548. /**
  22549. * Creates the VertexData of the IcoSphere
  22550. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22551. * * radius the radius of the IcoSphere, optional default 1
  22552. * * radiusX allows stretching in the x direction, optional, default radius
  22553. * * radiusY allows stretching in the y direction, optional, default radius
  22554. * * radiusZ allows stretching in the z direction, optional, default radius
  22555. * * flat when true creates a flat shaded mesh, optional, default true
  22556. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22558. * * 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)
  22559. * * 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)
  22560. * @returns the VertexData of the IcoSphere
  22561. */
  22562. static CreateIcoSphere(options: {
  22563. radius?: number;
  22564. radiusX?: number;
  22565. radiusY?: number;
  22566. radiusZ?: number;
  22567. flat?: boolean;
  22568. subdivisions?: number;
  22569. sideOrientation?: number;
  22570. frontUVs?: Vector4;
  22571. backUVs?: Vector4;
  22572. }): VertexData;
  22573. /**
  22574. * Creates the VertexData for a Polyhedron
  22575. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22576. * * type provided types are:
  22577. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22578. * * 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)
  22579. * * size the size of the IcoSphere, optional default 1
  22580. * * sizeX allows stretching in the x direction, optional, default size
  22581. * * sizeY allows stretching in the y direction, optional, default size
  22582. * * sizeZ allows stretching in the z direction, optional, default size
  22583. * * 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
  22584. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22585. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22586. * * flat when true creates a flat shaded mesh, optional, default true
  22587. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22588. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22589. * * 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)
  22590. * * 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)
  22591. * @returns the VertexData of the Polyhedron
  22592. */
  22593. static CreatePolyhedron(options: {
  22594. type?: number;
  22595. size?: number;
  22596. sizeX?: number;
  22597. sizeY?: number;
  22598. sizeZ?: number;
  22599. custom?: any;
  22600. faceUV?: Vector4[];
  22601. faceColors?: Color4[];
  22602. flat?: boolean;
  22603. sideOrientation?: number;
  22604. frontUVs?: Vector4;
  22605. backUVs?: Vector4;
  22606. }): VertexData;
  22607. /**
  22608. * Creates the VertexData for a TorusKnot
  22609. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22610. * * radius the radius of the torus knot, optional, default 2
  22611. * * tube the thickness of the tube, optional, default 0.5
  22612. * * radialSegments the number of sides on each tube segments, optional, default 32
  22613. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22614. * * p the number of windings around the z axis, optional, default 2
  22615. * * q the number of windings around the x axis, optional, default 3
  22616. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22617. * * 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)
  22618. * * 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)
  22619. * @returns the VertexData of the Torus Knot
  22620. */
  22621. static CreateTorusKnot(options: {
  22622. radius?: number;
  22623. tube?: number;
  22624. radialSegments?: number;
  22625. tubularSegments?: number;
  22626. p?: number;
  22627. q?: number;
  22628. sideOrientation?: number;
  22629. frontUVs?: Vector4;
  22630. backUVs?: Vector4;
  22631. }): VertexData;
  22632. /**
  22633. * Compute normals for given positions and indices
  22634. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22635. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22636. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22637. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22638. * * facetNormals : optional array of facet normals (vector3)
  22639. * * facetPositions : optional array of facet positions (vector3)
  22640. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22641. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22642. * * bInfo : optional bounding info, required for facetPartitioning computation
  22643. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22644. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22645. * * useRightHandedSystem: optional boolean to for right handed system computation
  22646. * * depthSort : optional boolean to enable the facet depth sort computation
  22647. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22648. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22649. */
  22650. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22651. facetNormals?: any;
  22652. facetPositions?: any;
  22653. facetPartitioning?: any;
  22654. ratio?: number;
  22655. bInfo?: any;
  22656. bbSize?: Vector3;
  22657. subDiv?: any;
  22658. useRightHandedSystem?: boolean;
  22659. depthSort?: boolean;
  22660. distanceTo?: Vector3;
  22661. depthSortedFacets?: any;
  22662. }): void;
  22663. /** @hidden */
  22664. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22665. /**
  22666. * Applies VertexData created from the imported parameters to the geometry
  22667. * @param parsedVertexData the parsed data from an imported file
  22668. * @param geometry the geometry to apply the VertexData to
  22669. */
  22670. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22671. }
  22672. }
  22673. declare module BABYLON {
  22674. /**
  22675. * Defines a target to use with MorphTargetManager
  22676. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22677. */
  22678. export class MorphTarget implements IAnimatable {
  22679. /** defines the name of the target */
  22680. name: string;
  22681. /**
  22682. * Gets or sets the list of animations
  22683. */
  22684. animations: Animation[];
  22685. private _scene;
  22686. private _positions;
  22687. private _normals;
  22688. private _tangents;
  22689. private _uvs;
  22690. private _influence;
  22691. private _uniqueId;
  22692. /**
  22693. * Observable raised when the influence changes
  22694. */
  22695. onInfluenceChanged: Observable<boolean>;
  22696. /** @hidden */
  22697. _onDataLayoutChanged: Observable<void>;
  22698. /**
  22699. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22700. */
  22701. get influence(): number;
  22702. set influence(influence: number);
  22703. /**
  22704. * Gets or sets the id of the morph Target
  22705. */
  22706. id: string;
  22707. private _animationPropertiesOverride;
  22708. /**
  22709. * Gets or sets the animation properties override
  22710. */
  22711. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22712. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22713. /**
  22714. * Creates a new MorphTarget
  22715. * @param name defines the name of the target
  22716. * @param influence defines the influence to use
  22717. * @param scene defines the scene the morphtarget belongs to
  22718. */
  22719. constructor(
  22720. /** defines the name of the target */
  22721. name: string, influence?: number, scene?: Nullable<Scene>);
  22722. /**
  22723. * Gets the unique ID of this manager
  22724. */
  22725. get uniqueId(): number;
  22726. /**
  22727. * Gets a boolean defining if the target contains position data
  22728. */
  22729. get hasPositions(): boolean;
  22730. /**
  22731. * Gets a boolean defining if the target contains normal data
  22732. */
  22733. get hasNormals(): boolean;
  22734. /**
  22735. * Gets a boolean defining if the target contains tangent data
  22736. */
  22737. get hasTangents(): boolean;
  22738. /**
  22739. * Gets a boolean defining if the target contains texture coordinates data
  22740. */
  22741. get hasUVs(): boolean;
  22742. /**
  22743. * Affects position data to this target
  22744. * @param data defines the position data to use
  22745. */
  22746. setPositions(data: Nullable<FloatArray>): void;
  22747. /**
  22748. * Gets the position data stored in this target
  22749. * @returns a FloatArray containing the position data (or null if not present)
  22750. */
  22751. getPositions(): Nullable<FloatArray>;
  22752. /**
  22753. * Affects normal data to this target
  22754. * @param data defines the normal data to use
  22755. */
  22756. setNormals(data: Nullable<FloatArray>): void;
  22757. /**
  22758. * Gets the normal data stored in this target
  22759. * @returns a FloatArray containing the normal data (or null if not present)
  22760. */
  22761. getNormals(): Nullable<FloatArray>;
  22762. /**
  22763. * Affects tangent data to this target
  22764. * @param data defines the tangent data to use
  22765. */
  22766. setTangents(data: Nullable<FloatArray>): void;
  22767. /**
  22768. * Gets the tangent data stored in this target
  22769. * @returns a FloatArray containing the tangent data (or null if not present)
  22770. */
  22771. getTangents(): Nullable<FloatArray>;
  22772. /**
  22773. * Affects texture coordinates data to this target
  22774. * @param data defines the texture coordinates data to use
  22775. */
  22776. setUVs(data: Nullable<FloatArray>): void;
  22777. /**
  22778. * Gets the texture coordinates data stored in this target
  22779. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22780. */
  22781. getUVs(): Nullable<FloatArray>;
  22782. /**
  22783. * Clone the current target
  22784. * @returns a new MorphTarget
  22785. */
  22786. clone(): MorphTarget;
  22787. /**
  22788. * Serializes the current target into a Serialization object
  22789. * @returns the serialized object
  22790. */
  22791. serialize(): any;
  22792. /**
  22793. * Returns the string "MorphTarget"
  22794. * @returns "MorphTarget"
  22795. */
  22796. getClassName(): string;
  22797. /**
  22798. * Creates a new target from serialized data
  22799. * @param serializationObject defines the serialized data to use
  22800. * @returns a new MorphTarget
  22801. */
  22802. static Parse(serializationObject: any): MorphTarget;
  22803. /**
  22804. * Creates a MorphTarget from mesh data
  22805. * @param mesh defines the source mesh
  22806. * @param name defines the name to use for the new target
  22807. * @param influence defines the influence to attach to the target
  22808. * @returns a new MorphTarget
  22809. */
  22810. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22811. }
  22812. }
  22813. declare module BABYLON {
  22814. /**
  22815. * This class is used to deform meshes using morphing between different targets
  22816. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22817. */
  22818. export class MorphTargetManager {
  22819. private _targets;
  22820. private _targetInfluenceChangedObservers;
  22821. private _targetDataLayoutChangedObservers;
  22822. private _activeTargets;
  22823. private _scene;
  22824. private _influences;
  22825. private _supportsNormals;
  22826. private _supportsTangents;
  22827. private _supportsUVs;
  22828. private _vertexCount;
  22829. private _uniqueId;
  22830. private _tempInfluences;
  22831. /**
  22832. * Gets or sets a boolean indicating if normals must be morphed
  22833. */
  22834. enableNormalMorphing: boolean;
  22835. /**
  22836. * Gets or sets a boolean indicating if tangents must be morphed
  22837. */
  22838. enableTangentMorphing: boolean;
  22839. /**
  22840. * Gets or sets a boolean indicating if UV must be morphed
  22841. */
  22842. enableUVMorphing: boolean;
  22843. /**
  22844. * Creates a new MorphTargetManager
  22845. * @param scene defines the current scene
  22846. */
  22847. constructor(scene?: Nullable<Scene>);
  22848. /**
  22849. * Gets the unique ID of this manager
  22850. */
  22851. get uniqueId(): number;
  22852. /**
  22853. * Gets the number of vertices handled by this manager
  22854. */
  22855. get vertexCount(): number;
  22856. /**
  22857. * Gets a boolean indicating if this manager supports morphing of normals
  22858. */
  22859. get supportsNormals(): boolean;
  22860. /**
  22861. * Gets a boolean indicating if this manager supports morphing of tangents
  22862. */
  22863. get supportsTangents(): boolean;
  22864. /**
  22865. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22866. */
  22867. get supportsUVs(): boolean;
  22868. /**
  22869. * Gets the number of targets stored in this manager
  22870. */
  22871. get numTargets(): number;
  22872. /**
  22873. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22874. */
  22875. get numInfluencers(): number;
  22876. /**
  22877. * Gets the list of influences (one per target)
  22878. */
  22879. get influences(): Float32Array;
  22880. /**
  22881. * Gets the active target at specified index. An active target is a target with an influence > 0
  22882. * @param index defines the index to check
  22883. * @returns the requested target
  22884. */
  22885. getActiveTarget(index: number): MorphTarget;
  22886. /**
  22887. * Gets the target at specified index
  22888. * @param index defines the index to check
  22889. * @returns the requested target
  22890. */
  22891. getTarget(index: number): MorphTarget;
  22892. /**
  22893. * Add a new target to this manager
  22894. * @param target defines the target to add
  22895. */
  22896. addTarget(target: MorphTarget): void;
  22897. /**
  22898. * Removes a target from the manager
  22899. * @param target defines the target to remove
  22900. */
  22901. removeTarget(target: MorphTarget): void;
  22902. /**
  22903. * Clone the current manager
  22904. * @returns a new MorphTargetManager
  22905. */
  22906. clone(): MorphTargetManager;
  22907. /**
  22908. * Serializes the current manager into a Serialization object
  22909. * @returns the serialized object
  22910. */
  22911. serialize(): any;
  22912. private _syncActiveTargets;
  22913. /**
  22914. * Syncrhonize the targets with all the meshes using this morph target manager
  22915. */
  22916. synchronize(): void;
  22917. /**
  22918. * Creates a new MorphTargetManager from serialized data
  22919. * @param serializationObject defines the serialized data
  22920. * @param scene defines the hosting scene
  22921. * @returns the new MorphTargetManager
  22922. */
  22923. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22924. }
  22925. }
  22926. declare module BABYLON {
  22927. /**
  22928. * Class used to represent a specific level of detail of a mesh
  22929. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22930. */
  22931. export class MeshLODLevel {
  22932. /** Defines the distance where this level should start being displayed */
  22933. distance: number;
  22934. /** Defines the mesh to use to render this level */
  22935. mesh: Nullable<Mesh>;
  22936. /**
  22937. * Creates a new LOD level
  22938. * @param distance defines the distance where this level should star being displayed
  22939. * @param mesh defines the mesh to use to render this level
  22940. */
  22941. constructor(
  22942. /** Defines the distance where this level should start being displayed */
  22943. distance: number,
  22944. /** Defines the mesh to use to render this level */
  22945. mesh: Nullable<Mesh>);
  22946. }
  22947. }
  22948. declare module BABYLON {
  22949. /**
  22950. * Mesh representing the gorund
  22951. */
  22952. export class GroundMesh extends Mesh {
  22953. /** If octree should be generated */
  22954. generateOctree: boolean;
  22955. private _heightQuads;
  22956. /** @hidden */
  22957. _subdivisionsX: number;
  22958. /** @hidden */
  22959. _subdivisionsY: number;
  22960. /** @hidden */
  22961. _width: number;
  22962. /** @hidden */
  22963. _height: number;
  22964. /** @hidden */
  22965. _minX: number;
  22966. /** @hidden */
  22967. _maxX: number;
  22968. /** @hidden */
  22969. _minZ: number;
  22970. /** @hidden */
  22971. _maxZ: number;
  22972. constructor(name: string, scene: Scene);
  22973. /**
  22974. * "GroundMesh"
  22975. * @returns "GroundMesh"
  22976. */
  22977. getClassName(): string;
  22978. /**
  22979. * The minimum of x and y subdivisions
  22980. */
  22981. get subdivisions(): number;
  22982. /**
  22983. * X subdivisions
  22984. */
  22985. get subdivisionsX(): number;
  22986. /**
  22987. * Y subdivisions
  22988. */
  22989. get subdivisionsY(): number;
  22990. /**
  22991. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22992. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22993. * @param chunksCount the number of subdivisions for x and y
  22994. * @param octreeBlocksSize (Default: 32)
  22995. */
  22996. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22997. /**
  22998. * Returns a height (y) value in the Worl system :
  22999. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23000. * @param x x coordinate
  23001. * @param z z coordinate
  23002. * @returns the ground y position if (x, z) are outside the ground surface.
  23003. */
  23004. getHeightAtCoordinates(x: number, z: number): number;
  23005. /**
  23006. * Returns a normalized vector (Vector3) orthogonal to the ground
  23007. * at the ground coordinates (x, z) expressed in the World system.
  23008. * @param x x coordinate
  23009. * @param z z coordinate
  23010. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23011. */
  23012. getNormalAtCoordinates(x: number, z: number): Vector3;
  23013. /**
  23014. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23015. * at the ground coordinates (x, z) expressed in the World system.
  23016. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23017. * @param x x coordinate
  23018. * @param z z coordinate
  23019. * @param ref vector to store the result
  23020. * @returns the GroundMesh.
  23021. */
  23022. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23023. /**
  23024. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23025. * if the ground has been updated.
  23026. * This can be used in the render loop.
  23027. * @returns the GroundMesh.
  23028. */
  23029. updateCoordinateHeights(): GroundMesh;
  23030. private _getFacetAt;
  23031. private _initHeightQuads;
  23032. private _computeHeightQuads;
  23033. /**
  23034. * Serializes this ground mesh
  23035. * @param serializationObject object to write serialization to
  23036. */
  23037. serialize(serializationObject: any): void;
  23038. /**
  23039. * Parses a serialized ground mesh
  23040. * @param parsedMesh the serialized mesh
  23041. * @param scene the scene to create the ground mesh in
  23042. * @returns the created ground mesh
  23043. */
  23044. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23045. }
  23046. }
  23047. declare module BABYLON {
  23048. /**
  23049. * Interface for Physics-Joint data
  23050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23051. */
  23052. export interface PhysicsJointData {
  23053. /**
  23054. * The main pivot of the joint
  23055. */
  23056. mainPivot?: Vector3;
  23057. /**
  23058. * The connected pivot of the joint
  23059. */
  23060. connectedPivot?: Vector3;
  23061. /**
  23062. * The main axis of the joint
  23063. */
  23064. mainAxis?: Vector3;
  23065. /**
  23066. * The connected axis of the joint
  23067. */
  23068. connectedAxis?: Vector3;
  23069. /**
  23070. * The collision of the joint
  23071. */
  23072. collision?: boolean;
  23073. /**
  23074. * Native Oimo/Cannon/Energy data
  23075. */
  23076. nativeParams?: any;
  23077. }
  23078. /**
  23079. * This is a holder class for the physics joint created by the physics plugin
  23080. * It holds a set of functions to control the underlying joint
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class PhysicsJoint {
  23084. /**
  23085. * The type of the physics joint
  23086. */
  23087. type: number;
  23088. /**
  23089. * The data for the physics joint
  23090. */
  23091. jointData: PhysicsJointData;
  23092. private _physicsJoint;
  23093. protected _physicsPlugin: IPhysicsEnginePlugin;
  23094. /**
  23095. * Initializes the physics joint
  23096. * @param type The type of the physics joint
  23097. * @param jointData The data for the physics joint
  23098. */
  23099. constructor(
  23100. /**
  23101. * The type of the physics joint
  23102. */
  23103. type: number,
  23104. /**
  23105. * The data for the physics joint
  23106. */
  23107. jointData: PhysicsJointData);
  23108. /**
  23109. * Gets the physics joint
  23110. */
  23111. get physicsJoint(): any;
  23112. /**
  23113. * Sets the physics joint
  23114. */
  23115. set physicsJoint(newJoint: any);
  23116. /**
  23117. * Sets the physics plugin
  23118. */
  23119. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23120. /**
  23121. * Execute a function that is physics-plugin specific.
  23122. * @param {Function} func the function that will be executed.
  23123. * It accepts two parameters: the physics world and the physics joint
  23124. */
  23125. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23126. /**
  23127. * Distance-Joint type
  23128. */
  23129. static DistanceJoint: number;
  23130. /**
  23131. * Hinge-Joint type
  23132. */
  23133. static HingeJoint: number;
  23134. /**
  23135. * Ball-and-Socket joint type
  23136. */
  23137. static BallAndSocketJoint: number;
  23138. /**
  23139. * Wheel-Joint type
  23140. */
  23141. static WheelJoint: number;
  23142. /**
  23143. * Slider-Joint type
  23144. */
  23145. static SliderJoint: number;
  23146. /**
  23147. * Prismatic-Joint type
  23148. */
  23149. static PrismaticJoint: number;
  23150. /**
  23151. * Universal-Joint type
  23152. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23153. */
  23154. static UniversalJoint: number;
  23155. /**
  23156. * Hinge-Joint 2 type
  23157. */
  23158. static Hinge2Joint: number;
  23159. /**
  23160. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23161. */
  23162. static PointToPointJoint: number;
  23163. /**
  23164. * Spring-Joint type
  23165. */
  23166. static SpringJoint: number;
  23167. /**
  23168. * Lock-Joint type
  23169. */
  23170. static LockJoint: number;
  23171. }
  23172. /**
  23173. * A class representing a physics distance joint
  23174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23175. */
  23176. export class DistanceJoint extends PhysicsJoint {
  23177. /**
  23178. *
  23179. * @param jointData The data for the Distance-Joint
  23180. */
  23181. constructor(jointData: DistanceJointData);
  23182. /**
  23183. * Update the predefined distance.
  23184. * @param maxDistance The maximum preferred distance
  23185. * @param minDistance The minimum preferred distance
  23186. */
  23187. updateDistance(maxDistance: number, minDistance?: number): void;
  23188. }
  23189. /**
  23190. * Represents a Motor-Enabled Joint
  23191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23192. */
  23193. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23194. /**
  23195. * Initializes the Motor-Enabled Joint
  23196. * @param type The type of the joint
  23197. * @param jointData The physica joint data for the joint
  23198. */
  23199. constructor(type: number, jointData: PhysicsJointData);
  23200. /**
  23201. * Set the motor values.
  23202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23203. * @param force the force to apply
  23204. * @param maxForce max force for this motor.
  23205. */
  23206. setMotor(force?: number, maxForce?: number): void;
  23207. /**
  23208. * Set the motor's limits.
  23209. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23210. * @param upperLimit The upper limit of the motor
  23211. * @param lowerLimit The lower limit of the motor
  23212. */
  23213. setLimit(upperLimit: number, lowerLimit?: number): void;
  23214. }
  23215. /**
  23216. * This class represents a single physics Hinge-Joint
  23217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23218. */
  23219. export class HingeJoint extends MotorEnabledJoint {
  23220. /**
  23221. * Initializes the Hinge-Joint
  23222. * @param jointData The joint data for the Hinge-Joint
  23223. */
  23224. constructor(jointData: PhysicsJointData);
  23225. /**
  23226. * Set the motor values.
  23227. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23228. * @param {number} force the force to apply
  23229. * @param {number} maxForce max force for this motor.
  23230. */
  23231. setMotor(force?: number, maxForce?: number): void;
  23232. /**
  23233. * Set the motor's limits.
  23234. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23235. * @param upperLimit The upper limit of the motor
  23236. * @param lowerLimit The lower limit of the motor
  23237. */
  23238. setLimit(upperLimit: number, lowerLimit?: number): void;
  23239. }
  23240. /**
  23241. * This class represents a dual hinge physics joint (same as wheel joint)
  23242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23243. */
  23244. export class Hinge2Joint extends MotorEnabledJoint {
  23245. /**
  23246. * Initializes the Hinge2-Joint
  23247. * @param jointData The joint data for the Hinge2-Joint
  23248. */
  23249. constructor(jointData: PhysicsJointData);
  23250. /**
  23251. * Set the motor values.
  23252. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23253. * @param {number} targetSpeed the speed the motor is to reach
  23254. * @param {number} maxForce max force for this motor.
  23255. * @param {motorIndex} the motor's index, 0 or 1.
  23256. */
  23257. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23258. /**
  23259. * Set the motor limits.
  23260. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23261. * @param {number} upperLimit the upper limit
  23262. * @param {number} lowerLimit lower limit
  23263. * @param {motorIndex} the motor's index, 0 or 1.
  23264. */
  23265. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23266. }
  23267. /**
  23268. * Interface for a motor enabled joint
  23269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23270. */
  23271. export interface IMotorEnabledJoint {
  23272. /**
  23273. * Physics joint
  23274. */
  23275. physicsJoint: any;
  23276. /**
  23277. * Sets the motor of the motor-enabled joint
  23278. * @param force The force of the motor
  23279. * @param maxForce The maximum force of the motor
  23280. * @param motorIndex The index of the motor
  23281. */
  23282. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23283. /**
  23284. * Sets the limit of the motor
  23285. * @param upperLimit The upper limit of the motor
  23286. * @param lowerLimit The lower limit of the motor
  23287. * @param motorIndex The index of the motor
  23288. */
  23289. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23290. }
  23291. /**
  23292. * Joint data for a Distance-Joint
  23293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23294. */
  23295. export interface DistanceJointData extends PhysicsJointData {
  23296. /**
  23297. * Max distance the 2 joint objects can be apart
  23298. */
  23299. maxDistance: number;
  23300. }
  23301. /**
  23302. * Joint data from a spring joint
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export interface SpringJointData extends PhysicsJointData {
  23306. /**
  23307. * Length of the spring
  23308. */
  23309. length: number;
  23310. /**
  23311. * Stiffness of the spring
  23312. */
  23313. stiffness: number;
  23314. /**
  23315. * Damping of the spring
  23316. */
  23317. damping: number;
  23318. /** this callback will be called when applying the force to the impostors. */
  23319. forceApplicationCallback: () => void;
  23320. }
  23321. }
  23322. declare module BABYLON {
  23323. /**
  23324. * Holds the data for the raycast result
  23325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23326. */
  23327. export class PhysicsRaycastResult {
  23328. private _hasHit;
  23329. private _hitDistance;
  23330. private _hitNormalWorld;
  23331. private _hitPointWorld;
  23332. private _rayFromWorld;
  23333. private _rayToWorld;
  23334. /**
  23335. * Gets if there was a hit
  23336. */
  23337. get hasHit(): boolean;
  23338. /**
  23339. * Gets the distance from the hit
  23340. */
  23341. get hitDistance(): number;
  23342. /**
  23343. * Gets the hit normal/direction in the world
  23344. */
  23345. get hitNormalWorld(): Vector3;
  23346. /**
  23347. * Gets the hit point in the world
  23348. */
  23349. get hitPointWorld(): Vector3;
  23350. /**
  23351. * Gets the ray "start point" of the ray in the world
  23352. */
  23353. get rayFromWorld(): Vector3;
  23354. /**
  23355. * Gets the ray "end point" of the ray in the world
  23356. */
  23357. get rayToWorld(): Vector3;
  23358. /**
  23359. * Sets the hit data (normal & point in world space)
  23360. * @param hitNormalWorld defines the normal in world space
  23361. * @param hitPointWorld defines the point in world space
  23362. */
  23363. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23364. /**
  23365. * Sets the distance from the start point to the hit point
  23366. * @param distance
  23367. */
  23368. setHitDistance(distance: number): void;
  23369. /**
  23370. * Calculates the distance manually
  23371. */
  23372. calculateHitDistance(): void;
  23373. /**
  23374. * Resets all the values to default
  23375. * @param from The from point on world space
  23376. * @param to The to point on world space
  23377. */
  23378. reset(from?: Vector3, to?: Vector3): void;
  23379. }
  23380. /**
  23381. * Interface for the size containing width and height
  23382. */
  23383. interface IXYZ {
  23384. /**
  23385. * X
  23386. */
  23387. x: number;
  23388. /**
  23389. * Y
  23390. */
  23391. y: number;
  23392. /**
  23393. * Z
  23394. */
  23395. z: number;
  23396. }
  23397. }
  23398. declare module BABYLON {
  23399. /**
  23400. * Interface used to describe a physics joint
  23401. */
  23402. export interface PhysicsImpostorJoint {
  23403. /** Defines the main impostor to which the joint is linked */
  23404. mainImpostor: PhysicsImpostor;
  23405. /** Defines the impostor that is connected to the main impostor using this joint */
  23406. connectedImpostor: PhysicsImpostor;
  23407. /** Defines the joint itself */
  23408. joint: PhysicsJoint;
  23409. }
  23410. /** @hidden */
  23411. export interface IPhysicsEnginePlugin {
  23412. world: any;
  23413. name: string;
  23414. setGravity(gravity: Vector3): void;
  23415. setTimeStep(timeStep: number): void;
  23416. getTimeStep(): number;
  23417. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23418. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23419. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23420. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23421. removePhysicsBody(impostor: PhysicsImpostor): void;
  23422. generateJoint(joint: PhysicsImpostorJoint): void;
  23423. removeJoint(joint: PhysicsImpostorJoint): void;
  23424. isSupported(): boolean;
  23425. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23426. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23427. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23428. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23429. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23430. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23431. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23432. getBodyMass(impostor: PhysicsImpostor): number;
  23433. getBodyFriction(impostor: PhysicsImpostor): number;
  23434. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23435. getBodyRestitution(impostor: PhysicsImpostor): number;
  23436. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23437. getBodyPressure?(impostor: PhysicsImpostor): number;
  23438. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23439. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23440. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23441. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23442. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23443. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23444. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23445. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23446. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23447. sleepBody(impostor: PhysicsImpostor): void;
  23448. wakeUpBody(impostor: PhysicsImpostor): void;
  23449. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23450. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23451. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23452. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23453. getRadius(impostor: PhysicsImpostor): number;
  23454. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23455. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23456. dispose(): void;
  23457. }
  23458. /**
  23459. * Interface used to define a physics engine
  23460. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23461. */
  23462. export interface IPhysicsEngine {
  23463. /**
  23464. * Gets the gravity vector used by the simulation
  23465. */
  23466. gravity: Vector3;
  23467. /**
  23468. * Sets the gravity vector used by the simulation
  23469. * @param gravity defines the gravity vector to use
  23470. */
  23471. setGravity(gravity: Vector3): void;
  23472. /**
  23473. * Set the time step of the physics engine.
  23474. * Default is 1/60.
  23475. * To slow it down, enter 1/600 for example.
  23476. * To speed it up, 1/30
  23477. * @param newTimeStep the new timestep to apply to this world.
  23478. */
  23479. setTimeStep(newTimeStep: number): void;
  23480. /**
  23481. * Get the time step of the physics engine.
  23482. * @returns the current time step
  23483. */
  23484. getTimeStep(): number;
  23485. /**
  23486. * Set the sub time step of the physics engine.
  23487. * Default is 0 meaning there is no sub steps
  23488. * To increase physics resolution precision, set a small value (like 1 ms)
  23489. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23490. */
  23491. setSubTimeStep(subTimeStep: number): void;
  23492. /**
  23493. * Get the sub time step of the physics engine.
  23494. * @returns the current sub time step
  23495. */
  23496. getSubTimeStep(): number;
  23497. /**
  23498. * Release all resources
  23499. */
  23500. dispose(): void;
  23501. /**
  23502. * Gets the name of the current physics plugin
  23503. * @returns the name of the plugin
  23504. */
  23505. getPhysicsPluginName(): string;
  23506. /**
  23507. * Adding a new impostor for the impostor tracking.
  23508. * This will be done by the impostor itself.
  23509. * @param impostor the impostor to add
  23510. */
  23511. addImpostor(impostor: PhysicsImpostor): void;
  23512. /**
  23513. * Remove an impostor from the engine.
  23514. * This impostor and its mesh will not longer be updated by the physics engine.
  23515. * @param impostor the impostor to remove
  23516. */
  23517. removeImpostor(impostor: PhysicsImpostor): void;
  23518. /**
  23519. * Add a joint to the physics engine
  23520. * @param mainImpostor defines the main impostor to which the joint is added.
  23521. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23522. * @param joint defines the joint that will connect both impostors.
  23523. */
  23524. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23525. /**
  23526. * Removes a joint from the simulation
  23527. * @param mainImpostor defines the impostor used with the joint
  23528. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23529. * @param joint defines the joint to remove
  23530. */
  23531. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23532. /**
  23533. * Gets the current plugin used to run the simulation
  23534. * @returns current plugin
  23535. */
  23536. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23537. /**
  23538. * Gets the list of physic impostors
  23539. * @returns an array of PhysicsImpostor
  23540. */
  23541. getImpostors(): Array<PhysicsImpostor>;
  23542. /**
  23543. * Gets the impostor for a physics enabled object
  23544. * @param object defines the object impersonated by the impostor
  23545. * @returns the PhysicsImpostor or null if not found
  23546. */
  23547. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23548. /**
  23549. * Gets the impostor for a physics body object
  23550. * @param body defines physics body used by the impostor
  23551. * @returns the PhysicsImpostor or null if not found
  23552. */
  23553. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23554. /**
  23555. * Does a raycast in the physics world
  23556. * @param from when should the ray start?
  23557. * @param to when should the ray end?
  23558. * @returns PhysicsRaycastResult
  23559. */
  23560. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23561. /**
  23562. * Called by the scene. No need to call it.
  23563. * @param delta defines the timespam between frames
  23564. */
  23565. _step(delta: number): void;
  23566. }
  23567. }
  23568. declare module BABYLON {
  23569. /**
  23570. * The interface for the physics imposter parameters
  23571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23572. */
  23573. export interface PhysicsImpostorParameters {
  23574. /**
  23575. * The mass of the physics imposter
  23576. */
  23577. mass: number;
  23578. /**
  23579. * The friction of the physics imposter
  23580. */
  23581. friction?: number;
  23582. /**
  23583. * The coefficient of restitution of the physics imposter
  23584. */
  23585. restitution?: number;
  23586. /**
  23587. * The native options of the physics imposter
  23588. */
  23589. nativeOptions?: any;
  23590. /**
  23591. * Specifies if the parent should be ignored
  23592. */
  23593. ignoreParent?: boolean;
  23594. /**
  23595. * Specifies if bi-directional transformations should be disabled
  23596. */
  23597. disableBidirectionalTransformation?: boolean;
  23598. /**
  23599. * The pressure inside the physics imposter, soft object only
  23600. */
  23601. pressure?: number;
  23602. /**
  23603. * The stiffness the physics imposter, soft object only
  23604. */
  23605. stiffness?: number;
  23606. /**
  23607. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23608. */
  23609. velocityIterations?: number;
  23610. /**
  23611. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23612. */
  23613. positionIterations?: number;
  23614. /**
  23615. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23616. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23617. * Add to fix multiple points
  23618. */
  23619. fixedPoints?: number;
  23620. /**
  23621. * The collision margin around a soft object
  23622. */
  23623. margin?: number;
  23624. /**
  23625. * The collision margin around a soft object
  23626. */
  23627. damping?: number;
  23628. /**
  23629. * The path for a rope based on an extrusion
  23630. */
  23631. path?: any;
  23632. /**
  23633. * The shape of an extrusion used for a rope based on an extrusion
  23634. */
  23635. shape?: any;
  23636. }
  23637. /**
  23638. * Interface for a physics-enabled object
  23639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23640. */
  23641. export interface IPhysicsEnabledObject {
  23642. /**
  23643. * The position of the physics-enabled object
  23644. */
  23645. position: Vector3;
  23646. /**
  23647. * The rotation of the physics-enabled object
  23648. */
  23649. rotationQuaternion: Nullable<Quaternion>;
  23650. /**
  23651. * The scale of the physics-enabled object
  23652. */
  23653. scaling: Vector3;
  23654. /**
  23655. * The rotation of the physics-enabled object
  23656. */
  23657. rotation?: Vector3;
  23658. /**
  23659. * The parent of the physics-enabled object
  23660. */
  23661. parent?: any;
  23662. /**
  23663. * The bounding info of the physics-enabled object
  23664. * @returns The bounding info of the physics-enabled object
  23665. */
  23666. getBoundingInfo(): BoundingInfo;
  23667. /**
  23668. * Computes the world matrix
  23669. * @param force Specifies if the world matrix should be computed by force
  23670. * @returns A world matrix
  23671. */
  23672. computeWorldMatrix(force: boolean): Matrix;
  23673. /**
  23674. * Gets the world matrix
  23675. * @returns A world matrix
  23676. */
  23677. getWorldMatrix?(): Matrix;
  23678. /**
  23679. * Gets the child meshes
  23680. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23681. * @returns An array of abstract meshes
  23682. */
  23683. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23684. /**
  23685. * Gets the vertex data
  23686. * @param kind The type of vertex data
  23687. * @returns A nullable array of numbers, or a float32 array
  23688. */
  23689. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23690. /**
  23691. * Gets the indices from the mesh
  23692. * @returns A nullable array of index arrays
  23693. */
  23694. getIndices?(): Nullable<IndicesArray>;
  23695. /**
  23696. * Gets the scene from the mesh
  23697. * @returns the indices array or null
  23698. */
  23699. getScene?(): Scene;
  23700. /**
  23701. * Gets the absolute position from the mesh
  23702. * @returns the absolute position
  23703. */
  23704. getAbsolutePosition(): Vector3;
  23705. /**
  23706. * Gets the absolute pivot point from the mesh
  23707. * @returns the absolute pivot point
  23708. */
  23709. getAbsolutePivotPoint(): Vector3;
  23710. /**
  23711. * Rotates the mesh
  23712. * @param axis The axis of rotation
  23713. * @param amount The amount of rotation
  23714. * @param space The space of the rotation
  23715. * @returns The rotation transform node
  23716. */
  23717. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23718. /**
  23719. * Translates the mesh
  23720. * @param axis The axis of translation
  23721. * @param distance The distance of translation
  23722. * @param space The space of the translation
  23723. * @returns The transform node
  23724. */
  23725. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23726. /**
  23727. * Sets the absolute position of the mesh
  23728. * @param absolutePosition The absolute position of the mesh
  23729. * @returns The transform node
  23730. */
  23731. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23732. /**
  23733. * Gets the class name of the mesh
  23734. * @returns The class name
  23735. */
  23736. getClassName(): string;
  23737. }
  23738. /**
  23739. * Represents a physics imposter
  23740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23741. */
  23742. export class PhysicsImpostor {
  23743. /**
  23744. * The physics-enabled object used as the physics imposter
  23745. */
  23746. object: IPhysicsEnabledObject;
  23747. /**
  23748. * The type of the physics imposter
  23749. */
  23750. type: number;
  23751. private _options;
  23752. private _scene?;
  23753. /**
  23754. * The default object size of the imposter
  23755. */
  23756. static DEFAULT_OBJECT_SIZE: Vector3;
  23757. /**
  23758. * The identity quaternion of the imposter
  23759. */
  23760. static IDENTITY_QUATERNION: Quaternion;
  23761. /** @hidden */
  23762. _pluginData: any;
  23763. private _physicsEngine;
  23764. private _physicsBody;
  23765. private _bodyUpdateRequired;
  23766. private _onBeforePhysicsStepCallbacks;
  23767. private _onAfterPhysicsStepCallbacks;
  23768. /** @hidden */
  23769. _onPhysicsCollideCallbacks: Array<{
  23770. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23771. otherImpostors: Array<PhysicsImpostor>;
  23772. }>;
  23773. private _deltaPosition;
  23774. private _deltaRotation;
  23775. private _deltaRotationConjugated;
  23776. /** @hidden */
  23777. _isFromLine: boolean;
  23778. private _parent;
  23779. private _isDisposed;
  23780. private static _tmpVecs;
  23781. private static _tmpQuat;
  23782. /**
  23783. * Specifies if the physics imposter is disposed
  23784. */
  23785. get isDisposed(): boolean;
  23786. /**
  23787. * Gets the mass of the physics imposter
  23788. */
  23789. get mass(): number;
  23790. set mass(value: number);
  23791. /**
  23792. * Gets the coefficient of friction
  23793. */
  23794. get friction(): number;
  23795. /**
  23796. * Sets the coefficient of friction
  23797. */
  23798. set friction(value: number);
  23799. /**
  23800. * Gets the coefficient of restitution
  23801. */
  23802. get restitution(): number;
  23803. /**
  23804. * Sets the coefficient of restitution
  23805. */
  23806. set restitution(value: number);
  23807. /**
  23808. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23809. */
  23810. get pressure(): number;
  23811. /**
  23812. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23813. */
  23814. set pressure(value: number);
  23815. /**
  23816. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23817. */
  23818. get stiffness(): number;
  23819. /**
  23820. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23821. */
  23822. set stiffness(value: number);
  23823. /**
  23824. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23825. */
  23826. get velocityIterations(): number;
  23827. /**
  23828. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23829. */
  23830. set velocityIterations(value: number);
  23831. /**
  23832. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23833. */
  23834. get positionIterations(): number;
  23835. /**
  23836. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23837. */
  23838. set positionIterations(value: number);
  23839. /**
  23840. * The unique id of the physics imposter
  23841. * set by the physics engine when adding this impostor to the array
  23842. */
  23843. uniqueId: number;
  23844. /**
  23845. * @hidden
  23846. */
  23847. soft: boolean;
  23848. /**
  23849. * @hidden
  23850. */
  23851. segments: number;
  23852. private _joints;
  23853. /**
  23854. * Initializes the physics imposter
  23855. * @param object The physics-enabled object used as the physics imposter
  23856. * @param type The type of the physics imposter
  23857. * @param _options The options for the physics imposter
  23858. * @param _scene The Babylon scene
  23859. */
  23860. constructor(
  23861. /**
  23862. * The physics-enabled object used as the physics imposter
  23863. */
  23864. object: IPhysicsEnabledObject,
  23865. /**
  23866. * The type of the physics imposter
  23867. */
  23868. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23869. /**
  23870. * This function will completly initialize this impostor.
  23871. * It will create a new body - but only if this mesh has no parent.
  23872. * If it has, this impostor will not be used other than to define the impostor
  23873. * of the child mesh.
  23874. * @hidden
  23875. */
  23876. _init(): void;
  23877. private _getPhysicsParent;
  23878. /**
  23879. * Should a new body be generated.
  23880. * @returns boolean specifying if body initialization is required
  23881. */
  23882. isBodyInitRequired(): boolean;
  23883. /**
  23884. * Sets the updated scaling
  23885. * @param updated Specifies if the scaling is updated
  23886. */
  23887. setScalingUpdated(): void;
  23888. /**
  23889. * Force a regeneration of this or the parent's impostor's body.
  23890. * Use under cautious - This will remove all joints already implemented.
  23891. */
  23892. forceUpdate(): void;
  23893. /**
  23894. * Gets the body that holds this impostor. Either its own, or its parent.
  23895. */
  23896. get physicsBody(): any;
  23897. /**
  23898. * Get the parent of the physics imposter
  23899. * @returns Physics imposter or null
  23900. */
  23901. get parent(): Nullable<PhysicsImpostor>;
  23902. /**
  23903. * Sets the parent of the physics imposter
  23904. */
  23905. set parent(value: Nullable<PhysicsImpostor>);
  23906. /**
  23907. * Set the physics body. Used mainly by the physics engine/plugin
  23908. */
  23909. set physicsBody(physicsBody: any);
  23910. /**
  23911. * Resets the update flags
  23912. */
  23913. resetUpdateFlags(): void;
  23914. /**
  23915. * Gets the object extend size
  23916. * @returns the object extend size
  23917. */
  23918. getObjectExtendSize(): Vector3;
  23919. /**
  23920. * Gets the object center
  23921. * @returns The object center
  23922. */
  23923. getObjectCenter(): Vector3;
  23924. /**
  23925. * Get a specific parameter from the options parameters
  23926. * @param paramName The object parameter name
  23927. * @returns The object parameter
  23928. */
  23929. getParam(paramName: string): any;
  23930. /**
  23931. * Sets a specific parameter in the options given to the physics plugin
  23932. * @param paramName The parameter name
  23933. * @param value The value of the parameter
  23934. */
  23935. setParam(paramName: string, value: number): void;
  23936. /**
  23937. * Specifically change the body's mass option. Won't recreate the physics body object
  23938. * @param mass The mass of the physics imposter
  23939. */
  23940. setMass(mass: number): void;
  23941. /**
  23942. * Gets the linear velocity
  23943. * @returns linear velocity or null
  23944. */
  23945. getLinearVelocity(): Nullable<Vector3>;
  23946. /**
  23947. * Sets the linear velocity
  23948. * @param velocity linear velocity or null
  23949. */
  23950. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23951. /**
  23952. * Gets the angular velocity
  23953. * @returns angular velocity or null
  23954. */
  23955. getAngularVelocity(): Nullable<Vector3>;
  23956. /**
  23957. * Sets the angular velocity
  23958. * @param velocity The velocity or null
  23959. */
  23960. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23961. /**
  23962. * Execute a function with the physics plugin native code
  23963. * Provide a function the will have two variables - the world object and the physics body object
  23964. * @param func The function to execute with the physics plugin native code
  23965. */
  23966. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23967. /**
  23968. * Register a function that will be executed before the physics world is stepping forward
  23969. * @param func The function to execute before the physics world is stepped forward
  23970. */
  23971. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23972. /**
  23973. * Unregister a function that will be executed before the physics world is stepping forward
  23974. * @param func The function to execute before the physics world is stepped forward
  23975. */
  23976. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23977. /**
  23978. * Register a function that will be executed after the physics step
  23979. * @param func The function to execute after physics step
  23980. */
  23981. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23982. /**
  23983. * Unregisters a function that will be executed after the physics step
  23984. * @param func The function to execute after physics step
  23985. */
  23986. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23987. /**
  23988. * register a function that will be executed when this impostor collides against a different body
  23989. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23990. * @param func Callback that is executed on collision
  23991. */
  23992. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23993. /**
  23994. * Unregisters the physics imposter on contact
  23995. * @param collideAgainst The physics object to collide against
  23996. * @param func Callback to execute on collision
  23997. */
  23998. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23999. private _tmpQuat;
  24000. private _tmpQuat2;
  24001. /**
  24002. * Get the parent rotation
  24003. * @returns The parent rotation
  24004. */
  24005. getParentsRotation(): Quaternion;
  24006. /**
  24007. * this function is executed by the physics engine.
  24008. */
  24009. beforeStep: () => void;
  24010. /**
  24011. * this function is executed by the physics engine
  24012. */
  24013. afterStep: () => void;
  24014. /**
  24015. * Legacy collision detection event support
  24016. */
  24017. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24018. /**
  24019. * event and body object due to cannon's event-based architecture.
  24020. */
  24021. onCollide: (e: {
  24022. body: any;
  24023. }) => void;
  24024. /**
  24025. * Apply a force
  24026. * @param force The force to apply
  24027. * @param contactPoint The contact point for the force
  24028. * @returns The physics imposter
  24029. */
  24030. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24031. /**
  24032. * Apply an impulse
  24033. * @param force The impulse force
  24034. * @param contactPoint The contact point for the impulse force
  24035. * @returns The physics imposter
  24036. */
  24037. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24038. /**
  24039. * A help function to create a joint
  24040. * @param otherImpostor A physics imposter used to create a joint
  24041. * @param jointType The type of joint
  24042. * @param jointData The data for the joint
  24043. * @returns The physics imposter
  24044. */
  24045. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24046. /**
  24047. * Add a joint to this impostor with a different impostor
  24048. * @param otherImpostor A physics imposter used to add a joint
  24049. * @param joint The joint to add
  24050. * @returns The physics imposter
  24051. */
  24052. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24053. /**
  24054. * Add an anchor to a cloth impostor
  24055. * @param otherImpostor rigid impostor to anchor to
  24056. * @param width ratio across width from 0 to 1
  24057. * @param height ratio up height from 0 to 1
  24058. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24059. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24060. * @returns impostor the soft imposter
  24061. */
  24062. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24063. /**
  24064. * Add a hook to a rope impostor
  24065. * @param otherImpostor rigid impostor to anchor to
  24066. * @param length ratio across rope from 0 to 1
  24067. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24068. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24069. * @returns impostor the rope imposter
  24070. */
  24071. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24072. /**
  24073. * Will keep this body still, in a sleep mode.
  24074. * @returns the physics imposter
  24075. */
  24076. sleep(): PhysicsImpostor;
  24077. /**
  24078. * Wake the body up.
  24079. * @returns The physics imposter
  24080. */
  24081. wakeUp(): PhysicsImpostor;
  24082. /**
  24083. * Clones the physics imposter
  24084. * @param newObject The physics imposter clones to this physics-enabled object
  24085. * @returns A nullable physics imposter
  24086. */
  24087. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24088. /**
  24089. * Disposes the physics imposter
  24090. */
  24091. dispose(): void;
  24092. /**
  24093. * Sets the delta position
  24094. * @param position The delta position amount
  24095. */
  24096. setDeltaPosition(position: Vector3): void;
  24097. /**
  24098. * Sets the delta rotation
  24099. * @param rotation The delta rotation amount
  24100. */
  24101. setDeltaRotation(rotation: Quaternion): void;
  24102. /**
  24103. * Gets the box size of the physics imposter and stores the result in the input parameter
  24104. * @param result Stores the box size
  24105. * @returns The physics imposter
  24106. */
  24107. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24108. /**
  24109. * Gets the radius of the physics imposter
  24110. * @returns Radius of the physics imposter
  24111. */
  24112. getRadius(): number;
  24113. /**
  24114. * Sync a bone with this impostor
  24115. * @param bone The bone to sync to the impostor.
  24116. * @param boneMesh The mesh that the bone is influencing.
  24117. * @param jointPivot The pivot of the joint / bone in local space.
  24118. * @param distToJoint Optional distance from the impostor to the joint.
  24119. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24120. */
  24121. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24122. /**
  24123. * Sync impostor to a bone
  24124. * @param bone The bone that the impostor will be synced to.
  24125. * @param boneMesh The mesh that the bone is influencing.
  24126. * @param jointPivot The pivot of the joint / bone in local space.
  24127. * @param distToJoint Optional distance from the impostor to the joint.
  24128. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24129. * @param boneAxis Optional vector3 axis the bone is aligned with
  24130. */
  24131. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24132. /**
  24133. * No-Imposter type
  24134. */
  24135. static NoImpostor: number;
  24136. /**
  24137. * Sphere-Imposter type
  24138. */
  24139. static SphereImpostor: number;
  24140. /**
  24141. * Box-Imposter type
  24142. */
  24143. static BoxImpostor: number;
  24144. /**
  24145. * Plane-Imposter type
  24146. */
  24147. static PlaneImpostor: number;
  24148. /**
  24149. * Mesh-imposter type
  24150. */
  24151. static MeshImpostor: number;
  24152. /**
  24153. * Capsule-Impostor type (Ammo.js plugin only)
  24154. */
  24155. static CapsuleImpostor: number;
  24156. /**
  24157. * Cylinder-Imposter type
  24158. */
  24159. static CylinderImpostor: number;
  24160. /**
  24161. * Particle-Imposter type
  24162. */
  24163. static ParticleImpostor: number;
  24164. /**
  24165. * Heightmap-Imposter type
  24166. */
  24167. static HeightmapImpostor: number;
  24168. /**
  24169. * ConvexHull-Impostor type (Ammo.js plugin only)
  24170. */
  24171. static ConvexHullImpostor: number;
  24172. /**
  24173. * Custom-Imposter type (Ammo.js plugin only)
  24174. */
  24175. static CustomImpostor: number;
  24176. /**
  24177. * Rope-Imposter type
  24178. */
  24179. static RopeImpostor: number;
  24180. /**
  24181. * Cloth-Imposter type
  24182. */
  24183. static ClothImpostor: number;
  24184. /**
  24185. * Softbody-Imposter type
  24186. */
  24187. static SoftbodyImpostor: number;
  24188. }
  24189. }
  24190. declare module BABYLON {
  24191. /**
  24192. * @hidden
  24193. **/
  24194. export class _CreationDataStorage {
  24195. closePath?: boolean;
  24196. closeArray?: boolean;
  24197. idx: number[];
  24198. dashSize: number;
  24199. gapSize: number;
  24200. path3D: Path3D;
  24201. pathArray: Vector3[][];
  24202. arc: number;
  24203. radius: number;
  24204. cap: number;
  24205. tessellation: number;
  24206. }
  24207. /**
  24208. * @hidden
  24209. **/
  24210. class _InstanceDataStorage {
  24211. visibleInstances: any;
  24212. batchCache: _InstancesBatch;
  24213. instancesBufferSize: number;
  24214. instancesBuffer: Nullable<Buffer>;
  24215. instancesData: Float32Array;
  24216. overridenInstanceCount: number;
  24217. isFrozen: boolean;
  24218. previousBatch: Nullable<_InstancesBatch>;
  24219. hardwareInstancedRendering: boolean;
  24220. sideOrientation: number;
  24221. manualUpdate: boolean;
  24222. }
  24223. /**
  24224. * @hidden
  24225. **/
  24226. export class _InstancesBatch {
  24227. mustReturn: boolean;
  24228. visibleInstances: Nullable<InstancedMesh[]>[];
  24229. renderSelf: boolean[];
  24230. hardwareInstancedRendering: boolean[];
  24231. }
  24232. /**
  24233. * Class used to represent renderable models
  24234. */
  24235. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24236. /**
  24237. * Mesh side orientation : usually the external or front surface
  24238. */
  24239. static readonly FRONTSIDE: number;
  24240. /**
  24241. * Mesh side orientation : usually the internal or back surface
  24242. */
  24243. static readonly BACKSIDE: number;
  24244. /**
  24245. * Mesh side orientation : both internal and external or front and back surfaces
  24246. */
  24247. static readonly DOUBLESIDE: number;
  24248. /**
  24249. * Mesh side orientation : by default, `FRONTSIDE`
  24250. */
  24251. static readonly DEFAULTSIDE: number;
  24252. /**
  24253. * Mesh cap setting : no cap
  24254. */
  24255. static readonly NO_CAP: number;
  24256. /**
  24257. * Mesh cap setting : one cap at the beginning of the mesh
  24258. */
  24259. static readonly CAP_START: number;
  24260. /**
  24261. * Mesh cap setting : one cap at the end of the mesh
  24262. */
  24263. static readonly CAP_END: number;
  24264. /**
  24265. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24266. */
  24267. static readonly CAP_ALL: number;
  24268. /**
  24269. * Mesh pattern setting : no flip or rotate
  24270. */
  24271. static readonly NO_FLIP: number;
  24272. /**
  24273. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24274. */
  24275. static readonly FLIP_TILE: number;
  24276. /**
  24277. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24278. */
  24279. static readonly ROTATE_TILE: number;
  24280. /**
  24281. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24282. */
  24283. static readonly FLIP_ROW: number;
  24284. /**
  24285. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24286. */
  24287. static readonly ROTATE_ROW: number;
  24288. /**
  24289. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24290. */
  24291. static readonly FLIP_N_ROTATE_TILE: number;
  24292. /**
  24293. * Mesh pattern setting : rotate pattern and rotate
  24294. */
  24295. static readonly FLIP_N_ROTATE_ROW: number;
  24296. /**
  24297. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24298. */
  24299. static readonly CENTER: number;
  24300. /**
  24301. * Mesh tile positioning : part tiles on left
  24302. */
  24303. static readonly LEFT: number;
  24304. /**
  24305. * Mesh tile positioning : part tiles on right
  24306. */
  24307. static readonly RIGHT: number;
  24308. /**
  24309. * Mesh tile positioning : part tiles on top
  24310. */
  24311. static readonly TOP: number;
  24312. /**
  24313. * Mesh tile positioning : part tiles on bottom
  24314. */
  24315. static readonly BOTTOM: number;
  24316. /**
  24317. * Gets the default side orientation.
  24318. * @param orientation the orientation to value to attempt to get
  24319. * @returns the default orientation
  24320. * @hidden
  24321. */
  24322. static _GetDefaultSideOrientation(orientation?: number): number;
  24323. private _internalMeshDataInfo;
  24324. /**
  24325. * An event triggered before rendering the mesh
  24326. */
  24327. get onBeforeRenderObservable(): Observable<Mesh>;
  24328. /**
  24329. * An event triggered before binding the mesh
  24330. */
  24331. get onBeforeBindObservable(): Observable<Mesh>;
  24332. /**
  24333. * An event triggered after rendering the mesh
  24334. */
  24335. get onAfterRenderObservable(): Observable<Mesh>;
  24336. /**
  24337. * An event triggered before drawing the mesh
  24338. */
  24339. get onBeforeDrawObservable(): Observable<Mesh>;
  24340. private _onBeforeDrawObserver;
  24341. /**
  24342. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24343. */
  24344. set onBeforeDraw(callback: () => void);
  24345. get hasInstances(): boolean;
  24346. /**
  24347. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24348. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24349. */
  24350. delayLoadState: number;
  24351. /**
  24352. * Gets the list of instances created from this mesh
  24353. * it is not supposed to be modified manually.
  24354. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24355. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24356. */
  24357. instances: InstancedMesh[];
  24358. /**
  24359. * Gets the file containing delay loading data for this mesh
  24360. */
  24361. delayLoadingFile: string;
  24362. /** @hidden */
  24363. _binaryInfo: any;
  24364. /**
  24365. * User defined function used to change how LOD level selection is done
  24366. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24367. */
  24368. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24369. /**
  24370. * Gets or sets the morph target manager
  24371. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24372. */
  24373. get morphTargetManager(): Nullable<MorphTargetManager>;
  24374. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24375. /** @hidden */
  24376. _creationDataStorage: Nullable<_CreationDataStorage>;
  24377. /** @hidden */
  24378. _geometry: Nullable<Geometry>;
  24379. /** @hidden */
  24380. _delayInfo: Array<string>;
  24381. /** @hidden */
  24382. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24383. /** @hidden */
  24384. _instanceDataStorage: _InstanceDataStorage;
  24385. private _effectiveMaterial;
  24386. /** @hidden */
  24387. _shouldGenerateFlatShading: boolean;
  24388. /** @hidden */
  24389. _originalBuilderSideOrientation: number;
  24390. /**
  24391. * Use this property to change the original side orientation defined at construction time
  24392. */
  24393. overrideMaterialSideOrientation: Nullable<number>;
  24394. /**
  24395. * Gets the source mesh (the one used to clone this one from)
  24396. */
  24397. get source(): Nullable<Mesh>;
  24398. /**
  24399. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24400. */
  24401. get isUnIndexed(): boolean;
  24402. set isUnIndexed(value: boolean);
  24403. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24404. get worldMatrixInstancedBuffer(): Float32Array;
  24405. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24406. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24407. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24408. /**
  24409. * @constructor
  24410. * @param name The value used by scene.getMeshByName() to do a lookup.
  24411. * @param scene The scene to add this mesh to.
  24412. * @param parent The parent of this mesh, if it has one
  24413. * @param source An optional Mesh from which geometry is shared, cloned.
  24414. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24415. * When false, achieved by calling a clone(), also passing False.
  24416. * This will make creation of children, recursive.
  24417. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24418. */
  24419. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24420. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24421. doNotInstantiate: boolean;
  24422. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24423. /**
  24424. * Gets the class name
  24425. * @returns the string "Mesh".
  24426. */
  24427. getClassName(): string;
  24428. /** @hidden */
  24429. get _isMesh(): boolean;
  24430. /**
  24431. * Returns a description of this mesh
  24432. * @param fullDetails define if full details about this mesh must be used
  24433. * @returns a descriptive string representing this mesh
  24434. */
  24435. toString(fullDetails?: boolean): string;
  24436. /** @hidden */
  24437. _unBindEffect(): void;
  24438. /**
  24439. * Gets a boolean indicating if this mesh has LOD
  24440. */
  24441. get hasLODLevels(): boolean;
  24442. /**
  24443. * Gets the list of MeshLODLevel associated with the current mesh
  24444. * @returns an array of MeshLODLevel
  24445. */
  24446. getLODLevels(): MeshLODLevel[];
  24447. private _sortLODLevels;
  24448. /**
  24449. * Add a mesh as LOD level triggered at the given distance.
  24450. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24451. * @param distance The distance from the center of the object to show this level
  24452. * @param mesh The mesh to be added as LOD level (can be null)
  24453. * @return This mesh (for chaining)
  24454. */
  24455. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24456. /**
  24457. * Returns the LOD level mesh at the passed distance or null if not found.
  24458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24459. * @param distance The distance from the center of the object to show this level
  24460. * @returns a Mesh or `null`
  24461. */
  24462. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24463. /**
  24464. * Remove a mesh from the LOD array
  24465. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24466. * @param mesh defines the mesh to be removed
  24467. * @return This mesh (for chaining)
  24468. */
  24469. removeLODLevel(mesh: Mesh): Mesh;
  24470. /**
  24471. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24472. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24473. * @param camera defines the camera to use to compute distance
  24474. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24475. * @return This mesh (for chaining)
  24476. */
  24477. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24478. /**
  24479. * Gets the mesh internal Geometry object
  24480. */
  24481. get geometry(): Nullable<Geometry>;
  24482. /**
  24483. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24484. * @returns the total number of vertices
  24485. */
  24486. getTotalVertices(): number;
  24487. /**
  24488. * Returns the content of an associated vertex buffer
  24489. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24490. * - VertexBuffer.PositionKind
  24491. * - VertexBuffer.UVKind
  24492. * - VertexBuffer.UV2Kind
  24493. * - VertexBuffer.UV3Kind
  24494. * - VertexBuffer.UV4Kind
  24495. * - VertexBuffer.UV5Kind
  24496. * - VertexBuffer.UV6Kind
  24497. * - VertexBuffer.ColorKind
  24498. * - VertexBuffer.MatricesIndicesKind
  24499. * - VertexBuffer.MatricesIndicesExtraKind
  24500. * - VertexBuffer.MatricesWeightsKind
  24501. * - VertexBuffer.MatricesWeightsExtraKind
  24502. * @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
  24503. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24504. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24505. */
  24506. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24507. /**
  24508. * Returns the mesh VertexBuffer object from the requested `kind`
  24509. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24510. * - VertexBuffer.PositionKind
  24511. * - VertexBuffer.NormalKind
  24512. * - VertexBuffer.UVKind
  24513. * - VertexBuffer.UV2Kind
  24514. * - VertexBuffer.UV3Kind
  24515. * - VertexBuffer.UV4Kind
  24516. * - VertexBuffer.UV5Kind
  24517. * - VertexBuffer.UV6Kind
  24518. * - VertexBuffer.ColorKind
  24519. * - VertexBuffer.MatricesIndicesKind
  24520. * - VertexBuffer.MatricesIndicesExtraKind
  24521. * - VertexBuffer.MatricesWeightsKind
  24522. * - VertexBuffer.MatricesWeightsExtraKind
  24523. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24524. */
  24525. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24526. /**
  24527. * Tests if a specific vertex buffer is associated with this mesh
  24528. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24529. * - VertexBuffer.PositionKind
  24530. * - VertexBuffer.NormalKind
  24531. * - VertexBuffer.UVKind
  24532. * - VertexBuffer.UV2Kind
  24533. * - VertexBuffer.UV3Kind
  24534. * - VertexBuffer.UV4Kind
  24535. * - VertexBuffer.UV5Kind
  24536. * - VertexBuffer.UV6Kind
  24537. * - VertexBuffer.ColorKind
  24538. * - VertexBuffer.MatricesIndicesKind
  24539. * - VertexBuffer.MatricesIndicesExtraKind
  24540. * - VertexBuffer.MatricesWeightsKind
  24541. * - VertexBuffer.MatricesWeightsExtraKind
  24542. * @returns a boolean
  24543. */
  24544. isVerticesDataPresent(kind: string): boolean;
  24545. /**
  24546. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24547. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24548. * - VertexBuffer.PositionKind
  24549. * - VertexBuffer.UVKind
  24550. * - VertexBuffer.UV2Kind
  24551. * - VertexBuffer.UV3Kind
  24552. * - VertexBuffer.UV4Kind
  24553. * - VertexBuffer.UV5Kind
  24554. * - VertexBuffer.UV6Kind
  24555. * - VertexBuffer.ColorKind
  24556. * - VertexBuffer.MatricesIndicesKind
  24557. * - VertexBuffer.MatricesIndicesExtraKind
  24558. * - VertexBuffer.MatricesWeightsKind
  24559. * - VertexBuffer.MatricesWeightsExtraKind
  24560. * @returns a boolean
  24561. */
  24562. isVertexBufferUpdatable(kind: string): boolean;
  24563. /**
  24564. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24565. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24566. * - VertexBuffer.PositionKind
  24567. * - VertexBuffer.NormalKind
  24568. * - VertexBuffer.UVKind
  24569. * - VertexBuffer.UV2Kind
  24570. * - VertexBuffer.UV3Kind
  24571. * - VertexBuffer.UV4Kind
  24572. * - VertexBuffer.UV5Kind
  24573. * - VertexBuffer.UV6Kind
  24574. * - VertexBuffer.ColorKind
  24575. * - VertexBuffer.MatricesIndicesKind
  24576. * - VertexBuffer.MatricesIndicesExtraKind
  24577. * - VertexBuffer.MatricesWeightsKind
  24578. * - VertexBuffer.MatricesWeightsExtraKind
  24579. * @returns an array of strings
  24580. */
  24581. getVerticesDataKinds(): string[];
  24582. /**
  24583. * Returns a positive integer : the total number of indices in this mesh geometry.
  24584. * @returns the numner of indices or zero if the mesh has no geometry.
  24585. */
  24586. getTotalIndices(): number;
  24587. /**
  24588. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24589. * @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.
  24590. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24591. * @returns the indices array or an empty array if the mesh has no geometry
  24592. */
  24593. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24594. get isBlocked(): boolean;
  24595. /**
  24596. * Determine if the current mesh is ready to be rendered
  24597. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24598. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24599. * @returns true if all associated assets are ready (material, textures, shaders)
  24600. */
  24601. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24602. /**
  24603. * 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.
  24604. */
  24605. get areNormalsFrozen(): boolean;
  24606. /**
  24607. * 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.
  24608. * @returns the current mesh
  24609. */
  24610. freezeNormals(): Mesh;
  24611. /**
  24612. * 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
  24613. * @returns the current mesh
  24614. */
  24615. unfreezeNormals(): Mesh;
  24616. /**
  24617. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24618. */
  24619. set overridenInstanceCount(count: number);
  24620. /** @hidden */
  24621. _preActivate(): Mesh;
  24622. /** @hidden */
  24623. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24624. /** @hidden */
  24625. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24626. /**
  24627. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24628. * This means the mesh underlying bounding box and sphere are recomputed.
  24629. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24630. * @returns the current mesh
  24631. */
  24632. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24633. /** @hidden */
  24634. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24635. /**
  24636. * This function will subdivide the mesh into multiple submeshes
  24637. * @param count defines the expected number of submeshes
  24638. */
  24639. subdivide(count: number): void;
  24640. /**
  24641. * Copy a FloatArray into a specific associated vertex buffer
  24642. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24643. * - VertexBuffer.PositionKind
  24644. * - VertexBuffer.UVKind
  24645. * - VertexBuffer.UV2Kind
  24646. * - VertexBuffer.UV3Kind
  24647. * - VertexBuffer.UV4Kind
  24648. * - VertexBuffer.UV5Kind
  24649. * - VertexBuffer.UV6Kind
  24650. * - VertexBuffer.ColorKind
  24651. * - VertexBuffer.MatricesIndicesKind
  24652. * - VertexBuffer.MatricesIndicesExtraKind
  24653. * - VertexBuffer.MatricesWeightsKind
  24654. * - VertexBuffer.MatricesWeightsExtraKind
  24655. * @param data defines the data source
  24656. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24657. * @param stride defines the data stride size (can be null)
  24658. * @returns the current mesh
  24659. */
  24660. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24661. /**
  24662. * Delete a vertex buffer associated with this mesh
  24663. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24664. * - VertexBuffer.PositionKind
  24665. * - VertexBuffer.UVKind
  24666. * - VertexBuffer.UV2Kind
  24667. * - VertexBuffer.UV3Kind
  24668. * - VertexBuffer.UV4Kind
  24669. * - VertexBuffer.UV5Kind
  24670. * - VertexBuffer.UV6Kind
  24671. * - VertexBuffer.ColorKind
  24672. * - VertexBuffer.MatricesIndicesKind
  24673. * - VertexBuffer.MatricesIndicesExtraKind
  24674. * - VertexBuffer.MatricesWeightsKind
  24675. * - VertexBuffer.MatricesWeightsExtraKind
  24676. */
  24677. removeVerticesData(kind: string): void;
  24678. /**
  24679. * Flags an associated vertex buffer as updatable
  24680. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24681. * - VertexBuffer.PositionKind
  24682. * - VertexBuffer.UVKind
  24683. * - VertexBuffer.UV2Kind
  24684. * - VertexBuffer.UV3Kind
  24685. * - VertexBuffer.UV4Kind
  24686. * - VertexBuffer.UV5Kind
  24687. * - VertexBuffer.UV6Kind
  24688. * - VertexBuffer.ColorKind
  24689. * - VertexBuffer.MatricesIndicesKind
  24690. * - VertexBuffer.MatricesIndicesExtraKind
  24691. * - VertexBuffer.MatricesWeightsKind
  24692. * - VertexBuffer.MatricesWeightsExtraKind
  24693. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24694. */
  24695. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24696. /**
  24697. * Sets the mesh global Vertex Buffer
  24698. * @param buffer defines the buffer to use
  24699. * @returns the current mesh
  24700. */
  24701. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24702. /**
  24703. * Update a specific associated vertex buffer
  24704. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24705. * - VertexBuffer.PositionKind
  24706. * - VertexBuffer.UVKind
  24707. * - VertexBuffer.UV2Kind
  24708. * - VertexBuffer.UV3Kind
  24709. * - VertexBuffer.UV4Kind
  24710. * - VertexBuffer.UV5Kind
  24711. * - VertexBuffer.UV6Kind
  24712. * - VertexBuffer.ColorKind
  24713. * - VertexBuffer.MatricesIndicesKind
  24714. * - VertexBuffer.MatricesIndicesExtraKind
  24715. * - VertexBuffer.MatricesWeightsKind
  24716. * - VertexBuffer.MatricesWeightsExtraKind
  24717. * @param data defines the data source
  24718. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24719. * @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)
  24720. * @returns the current mesh
  24721. */
  24722. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24723. /**
  24724. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24725. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24726. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24727. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24728. * @returns the current mesh
  24729. */
  24730. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24731. /**
  24732. * Creates a un-shared specific occurence of the geometry for the mesh.
  24733. * @returns the current mesh
  24734. */
  24735. makeGeometryUnique(): Mesh;
  24736. /**
  24737. * Set the index buffer of this mesh
  24738. * @param indices defines the source data
  24739. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24740. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24741. * @returns the current mesh
  24742. */
  24743. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24744. /**
  24745. * Update the current index buffer
  24746. * @param indices defines the source data
  24747. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24748. * @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)
  24749. * @returns the current mesh
  24750. */
  24751. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24752. /**
  24753. * Invert the geometry to move from a right handed system to a left handed one.
  24754. * @returns the current mesh
  24755. */
  24756. toLeftHanded(): Mesh;
  24757. /** @hidden */
  24758. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24759. /** @hidden */
  24760. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24761. /**
  24762. * Registers for this mesh a javascript function called just before the rendering process
  24763. * @param func defines the function to call before rendering this mesh
  24764. * @returns the current mesh
  24765. */
  24766. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24767. /**
  24768. * Disposes a previously registered javascript function called before the rendering
  24769. * @param func defines the function to remove
  24770. * @returns the current mesh
  24771. */
  24772. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24773. /**
  24774. * Registers for this mesh a javascript function called just after the rendering is complete
  24775. * @param func defines the function to call after rendering this mesh
  24776. * @returns the current mesh
  24777. */
  24778. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24779. /**
  24780. * Disposes a previously registered javascript function called after the rendering.
  24781. * @param func defines the function to remove
  24782. * @returns the current mesh
  24783. */
  24784. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24785. /** @hidden */
  24786. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24787. /** @hidden */
  24788. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24789. /** @hidden */
  24790. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24791. /** @hidden */
  24792. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24793. /** @hidden */
  24794. _rebuild(): void;
  24795. /** @hidden */
  24796. _freeze(): void;
  24797. /** @hidden */
  24798. _unFreeze(): void;
  24799. /**
  24800. * 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
  24801. * @param subMesh defines the subMesh to render
  24802. * @param enableAlphaMode defines if alpha mode can be changed
  24803. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24804. * @returns the current mesh
  24805. */
  24806. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24807. private _onBeforeDraw;
  24808. /**
  24809. * Renormalize the mesh and patch it up if there are no weights
  24810. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24811. * However in the case of zero weights then we set just a single influence to 1.
  24812. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24813. */
  24814. cleanMatrixWeights(): void;
  24815. private normalizeSkinFourWeights;
  24816. private normalizeSkinWeightsAndExtra;
  24817. /**
  24818. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24819. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24820. * the user know there was an issue with importing the mesh
  24821. * @returns a validation object with skinned, valid and report string
  24822. */
  24823. validateSkinning(): {
  24824. skinned: boolean;
  24825. valid: boolean;
  24826. report: string;
  24827. };
  24828. /** @hidden */
  24829. _checkDelayState(): Mesh;
  24830. private _queueLoad;
  24831. /**
  24832. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24833. * A mesh is in the frustum if its bounding box intersects the frustum
  24834. * @param frustumPlanes defines the frustum to test
  24835. * @returns true if the mesh is in the frustum planes
  24836. */
  24837. isInFrustum(frustumPlanes: Plane[]): boolean;
  24838. /**
  24839. * Sets the mesh material by the material or multiMaterial `id` property
  24840. * @param id is a string identifying the material or the multiMaterial
  24841. * @returns the current mesh
  24842. */
  24843. setMaterialByID(id: string): Mesh;
  24844. /**
  24845. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24846. * @returns an array of IAnimatable
  24847. */
  24848. getAnimatables(): IAnimatable[];
  24849. /**
  24850. * Modifies the mesh geometry according to the passed transformation matrix.
  24851. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24852. * The mesh normals are modified using the same transformation.
  24853. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24854. * @param transform defines the transform matrix to use
  24855. * @see http://doc.babylonjs.com/resources/baking_transformations
  24856. * @returns the current mesh
  24857. */
  24858. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24859. /**
  24860. * Modifies the mesh geometry according to its own current World Matrix.
  24861. * The mesh World Matrix is then reset.
  24862. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24863. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24864. * @see http://doc.babylonjs.com/resources/baking_transformations
  24865. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24866. * @returns the current mesh
  24867. */
  24868. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24869. /** @hidden */
  24870. get _positions(): Nullable<Vector3[]>;
  24871. /** @hidden */
  24872. _resetPointsArrayCache(): Mesh;
  24873. /** @hidden */
  24874. _generatePointsArray(): boolean;
  24875. /**
  24876. * Returns a new Mesh object generated from the current mesh properties.
  24877. * This method must not get confused with createInstance()
  24878. * @param name is a string, the name given to the new mesh
  24879. * @param newParent can be any Node object (default `null`)
  24880. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24881. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24882. * @returns a new mesh
  24883. */
  24884. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24885. /**
  24886. * Releases resources associated with this mesh.
  24887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24889. */
  24890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24891. /** @hidden */
  24892. _disposeInstanceSpecificData(): void;
  24893. /**
  24894. * Modifies the mesh geometry according to a displacement map.
  24895. * 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.
  24896. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24897. * @param url is a string, the URL from the image file is to be downloaded.
  24898. * @param minHeight is the lower limit of the displacement.
  24899. * @param maxHeight is the upper limit of the displacement.
  24900. * @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.
  24901. * @param uvOffset is an optional vector2 used to offset UV.
  24902. * @param uvScale is an optional vector2 used to scale UV.
  24903. * @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.
  24904. * @returns the Mesh.
  24905. */
  24906. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24907. /**
  24908. * Modifies the mesh geometry according to a displacementMap buffer.
  24909. * 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.
  24910. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24911. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24912. * @param heightMapWidth is the width of the buffer image.
  24913. * @param heightMapHeight is the height of the buffer image.
  24914. * @param minHeight is the lower limit of the displacement.
  24915. * @param maxHeight is the upper limit of the displacement.
  24916. * @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.
  24917. * @param uvOffset is an optional vector2 used to offset UV.
  24918. * @param uvScale is an optional vector2 used to scale UV.
  24919. * @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.
  24920. * @returns the Mesh.
  24921. */
  24922. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24923. /**
  24924. * Modify the mesh to get a flat shading rendering.
  24925. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24926. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24927. * @returns current mesh
  24928. */
  24929. convertToFlatShadedMesh(): Mesh;
  24930. /**
  24931. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24932. * In other words, more vertices, no more indices and a single bigger VBO.
  24933. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24934. * @returns current mesh
  24935. */
  24936. convertToUnIndexedMesh(): Mesh;
  24937. /**
  24938. * Inverses facet orientations.
  24939. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24940. * @param flipNormals will also inverts the normals
  24941. * @returns current mesh
  24942. */
  24943. flipFaces(flipNormals?: boolean): Mesh;
  24944. /**
  24945. * Increase the number of facets and hence vertices in a mesh
  24946. * Vertex normals are interpolated from existing vertex normals
  24947. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24948. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24949. */
  24950. increaseVertices(numberPerEdge: number): void;
  24951. /**
  24952. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24953. * This will undo any application of covertToFlatShadedMesh
  24954. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24955. */
  24956. forceSharedVertices(): void;
  24957. /** @hidden */
  24958. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24959. /** @hidden */
  24960. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24961. /**
  24962. * Creates a new InstancedMesh object from the mesh model.
  24963. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24964. * @param name defines the name of the new instance
  24965. * @returns a new InstancedMesh
  24966. */
  24967. createInstance(name: string): InstancedMesh;
  24968. /**
  24969. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24970. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24971. * @returns the current mesh
  24972. */
  24973. synchronizeInstances(): Mesh;
  24974. /**
  24975. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24976. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24977. * This should be used together with the simplification to avoid disappearing triangles.
  24978. * @param successCallback an optional success callback to be called after the optimization finished.
  24979. * @returns the current mesh
  24980. */
  24981. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24982. /**
  24983. * Serialize current mesh
  24984. * @param serializationObject defines the object which will receive the serialization data
  24985. */
  24986. serialize(serializationObject: any): void;
  24987. /** @hidden */
  24988. _syncGeometryWithMorphTargetManager(): void;
  24989. /** @hidden */
  24990. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24991. /**
  24992. * Returns a new Mesh object parsed from the source provided.
  24993. * @param parsedMesh is the source
  24994. * @param scene defines the hosting scene
  24995. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24996. * @returns a new Mesh
  24997. */
  24998. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24999. /**
  25000. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25001. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25002. * @param name defines the name of the mesh to create
  25003. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25004. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25005. * @param closePath creates a seam between the first and the last points of each path of the path array
  25006. * @param offset is taken in account only if the `pathArray` is containing a single path
  25007. * @param scene defines the hosting scene
  25008. * @param updatable defines if the mesh must be flagged as updatable
  25009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25010. * @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)
  25011. * @returns a new Mesh
  25012. */
  25013. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25014. /**
  25015. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25016. * @param name defines the name of the mesh to create
  25017. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25018. * @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
  25019. * @param scene defines the hosting scene
  25020. * @param updatable defines if the mesh must be flagged as updatable
  25021. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25022. * @returns a new Mesh
  25023. */
  25024. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25025. /**
  25026. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25027. * @param name defines the name of the mesh to create
  25028. * @param size sets the size (float) of each box side (default 1)
  25029. * @param scene defines the hosting scene
  25030. * @param updatable defines if the mesh must be flagged as updatable
  25031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25032. * @returns a new Mesh
  25033. */
  25034. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25035. /**
  25036. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25037. * @param name defines the name of the mesh to create
  25038. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25039. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25040. * @param scene defines the hosting scene
  25041. * @param updatable defines if the mesh must be flagged as updatable
  25042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25043. * @returns a new Mesh
  25044. */
  25045. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25046. /**
  25047. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25048. * @param name defines the name of the mesh to create
  25049. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25050. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25051. * @param scene defines the hosting scene
  25052. * @returns a new Mesh
  25053. */
  25054. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25055. /**
  25056. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25057. * @param name defines the name of the mesh to create
  25058. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25059. * @param diameterTop set the top cap diameter (floats, default 1)
  25060. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25061. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25062. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25063. * @param scene defines the hosting scene
  25064. * @param updatable defines if the mesh must be flagged as updatable
  25065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25069. /**
  25070. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param diameter sets the diameter size (float) of the torus (default 1)
  25073. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25074. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25075. * @param scene defines the hosting scene
  25076. * @param updatable defines if the mesh must be flagged as updatable
  25077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25078. * @returns a new Mesh
  25079. */
  25080. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25081. /**
  25082. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25083. * @param name defines the name of the mesh to create
  25084. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25085. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25086. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25087. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25088. * @param p the number of windings on X axis (positive integers, default 2)
  25089. * @param q the number of windings on Y axis (positive integers, default 3)
  25090. * @param scene defines the hosting scene
  25091. * @param updatable defines if the mesh must be flagged as updatable
  25092. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25093. * @returns a new Mesh
  25094. */
  25095. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25096. /**
  25097. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25098. * @param name defines the name of the mesh to create
  25099. * @param points is an array successive Vector3
  25100. * @param scene defines the hosting scene
  25101. * @param updatable defines if the mesh must be flagged as updatable
  25102. * @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).
  25103. * @returns a new Mesh
  25104. */
  25105. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25106. /**
  25107. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25108. * @param name defines the name of the mesh to create
  25109. * @param points is an array successive Vector3
  25110. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25111. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25112. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25113. * @param scene defines the hosting scene
  25114. * @param updatable defines if the mesh must be flagged as updatable
  25115. * @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)
  25116. * @returns a new Mesh
  25117. */
  25118. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25119. /**
  25120. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25121. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25122. * 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.
  25123. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25124. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25125. * Remember you can only change the shape positions, not their number when updating a polygon.
  25126. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25127. * @param name defines the name of the mesh to create
  25128. * @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
  25129. * @param scene defines the hosting scene
  25130. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25131. * @param updatable defines if the mesh must be flagged as updatable
  25132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25133. * @param earcutInjection can be used to inject your own earcut reference
  25134. * @returns a new Mesh
  25135. */
  25136. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25137. /**
  25138. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25139. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25140. * @param name defines the name of the mesh to create
  25141. * @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
  25142. * @param depth defines the height of extrusion
  25143. * @param scene defines the hosting scene
  25144. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25145. * @param updatable defines if the mesh must be flagged as updatable
  25146. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25147. * @param earcutInjection can be used to inject your own earcut reference
  25148. * @returns a new Mesh
  25149. */
  25150. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25151. /**
  25152. * Creates an extruded shape mesh.
  25153. * 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
  25154. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25155. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25156. * @param name defines the name of the mesh to create
  25157. * @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
  25158. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25159. * @param scale is the value to scale the shape
  25160. * @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
  25161. * @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
  25162. * @param scene defines the hosting scene
  25163. * @param updatable defines if the mesh must be flagged as updatable
  25164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25165. * @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)
  25166. * @returns a new Mesh
  25167. */
  25168. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25169. /**
  25170. * Creates an custom extruded shape mesh.
  25171. * The custom extrusion is a parametric shape.
  25172. * It has no predefined shape. Its final shape will depend on the input parameters.
  25173. * Please consider using the same method from the MeshBuilder class instead
  25174. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25175. * @param name defines the name of the mesh to create
  25176. * @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
  25177. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25178. * @param scaleFunction is a custom Javascript function called on each path point
  25179. * @param rotationFunction is a custom Javascript function called on each path point
  25180. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25181. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25182. * @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
  25183. * @param scene defines the hosting scene
  25184. * @param updatable defines if the mesh must be flagged as updatable
  25185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25186. * @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)
  25187. * @returns a new Mesh
  25188. */
  25189. 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;
  25190. /**
  25191. * Creates lathe mesh.
  25192. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25193. * Please consider using the same method from the MeshBuilder class instead
  25194. * @param name defines the name of the mesh to create
  25195. * @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
  25196. * @param radius is the radius value of the lathe
  25197. * @param tessellation is the side number of the lathe.
  25198. * @param scene defines the hosting scene
  25199. * @param updatable defines if the mesh must be flagged as updatable
  25200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25201. * @returns a new Mesh
  25202. */
  25203. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25204. /**
  25205. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25206. * @param name defines the name of the mesh to create
  25207. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25208. * @param scene defines the hosting scene
  25209. * @param updatable defines if the mesh must be flagged as updatable
  25210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25211. * @returns a new Mesh
  25212. */
  25213. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25214. /**
  25215. * Creates a ground mesh.
  25216. * Please consider using the same method from the MeshBuilder class instead
  25217. * @param name defines the name of the mesh to create
  25218. * @param width set the width of the ground
  25219. * @param height set the height of the ground
  25220. * @param subdivisions sets the number of subdivisions per side
  25221. * @param scene defines the hosting scene
  25222. * @param updatable defines if the mesh must be flagged as updatable
  25223. * @returns a new Mesh
  25224. */
  25225. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25226. /**
  25227. * Creates a tiled ground mesh.
  25228. * Please consider using the same method from the MeshBuilder class instead
  25229. * @param name defines the name of the mesh to create
  25230. * @param xmin set the ground minimum X coordinate
  25231. * @param zmin set the ground minimum Y coordinate
  25232. * @param xmax set the ground maximum X coordinate
  25233. * @param zmax set the ground maximum Z coordinate
  25234. * @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
  25235. * @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
  25236. * @param scene defines the hosting scene
  25237. * @param updatable defines if the mesh must be flagged as updatable
  25238. * @returns a new Mesh
  25239. */
  25240. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25241. w: number;
  25242. h: number;
  25243. }, precision: {
  25244. w: number;
  25245. h: number;
  25246. }, scene: Scene, updatable?: boolean): Mesh;
  25247. /**
  25248. * Creates a ground mesh from a height map.
  25249. * Please consider using the same method from the MeshBuilder class instead
  25250. * @see http://doc.babylonjs.com/babylon101/height_map
  25251. * @param name defines the name of the mesh to create
  25252. * @param url sets the URL of the height map image resource
  25253. * @param width set the ground width size
  25254. * @param height set the ground height size
  25255. * @param subdivisions sets the number of subdivision per side
  25256. * @param minHeight is the minimum altitude on the ground
  25257. * @param maxHeight is the maximum altitude on the ground
  25258. * @param scene defines the hosting scene
  25259. * @param updatable defines if the mesh must be flagged as updatable
  25260. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25261. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25262. * @returns a new Mesh
  25263. */
  25264. 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;
  25265. /**
  25266. * Creates a tube mesh.
  25267. * The tube is a parametric shape.
  25268. * It has no predefined shape. Its final shape will depend on the input parameters.
  25269. * Please consider using the same method from the MeshBuilder class instead
  25270. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25271. * @param name defines the name of the mesh to create
  25272. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25273. * @param radius sets the tube radius size
  25274. * @param tessellation is the number of sides on the tubular surface
  25275. * @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
  25276. * @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
  25277. * @param scene defines the hosting scene
  25278. * @param updatable defines if the mesh must be flagged as updatable
  25279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25280. * @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)
  25281. * @returns a new Mesh
  25282. */
  25283. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25284. (i: number, distance: number): number;
  25285. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25286. /**
  25287. * Creates a polyhedron mesh.
  25288. * Please consider using the same method from the MeshBuilder class instead.
  25289. * * 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
  25290. * * The parameter `size` (positive float, default 1) sets the polygon size
  25291. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25292. * * 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`
  25293. * * 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
  25294. * * 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)`)
  25295. * * 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
  25296. * * 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
  25297. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25298. * * 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
  25299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25300. * @param name defines the name of the mesh to create
  25301. * @param options defines the options used to create the mesh
  25302. * @param scene defines the hosting scene
  25303. * @returns a new Mesh
  25304. */
  25305. static CreatePolyhedron(name: string, options: {
  25306. type?: number;
  25307. size?: number;
  25308. sizeX?: number;
  25309. sizeY?: number;
  25310. sizeZ?: number;
  25311. custom?: any;
  25312. faceUV?: Vector4[];
  25313. faceColors?: Color4[];
  25314. updatable?: boolean;
  25315. sideOrientation?: number;
  25316. }, scene: Scene): Mesh;
  25317. /**
  25318. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25319. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25320. * * 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`)
  25321. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25322. * * 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
  25323. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25324. * * 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
  25325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25326. * @param name defines the name of the mesh
  25327. * @param options defines the options used to create the mesh
  25328. * @param scene defines the hosting scene
  25329. * @returns a new Mesh
  25330. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25331. */
  25332. static CreateIcoSphere(name: string, options: {
  25333. radius?: number;
  25334. flat?: boolean;
  25335. subdivisions?: number;
  25336. sideOrientation?: number;
  25337. updatable?: boolean;
  25338. }, scene: Scene): Mesh;
  25339. /**
  25340. * Creates a decal mesh.
  25341. * Please consider using the same method from the MeshBuilder class instead.
  25342. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25343. * @param name defines the name of the mesh
  25344. * @param sourceMesh defines the mesh receiving the decal
  25345. * @param position sets the position of the decal in world coordinates
  25346. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25347. * @param size sets the decal scaling
  25348. * @param angle sets the angle to rotate the decal
  25349. * @returns a new Mesh
  25350. */
  25351. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25352. /**
  25353. * Prepare internal position array for software CPU skinning
  25354. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25355. */
  25356. setPositionsForCPUSkinning(): Float32Array;
  25357. /**
  25358. * Prepare internal normal array for software CPU skinning
  25359. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25360. */
  25361. setNormalsForCPUSkinning(): Float32Array;
  25362. /**
  25363. * Updates the vertex buffer by applying transformation from the bones
  25364. * @param skeleton defines the skeleton to apply to current mesh
  25365. * @returns the current mesh
  25366. */
  25367. applySkeleton(skeleton: Skeleton): Mesh;
  25368. /**
  25369. * 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
  25370. * @param meshes defines the list of meshes to scan
  25371. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25372. */
  25373. static MinMax(meshes: AbstractMesh[]): {
  25374. min: Vector3;
  25375. max: Vector3;
  25376. };
  25377. /**
  25378. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25379. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25380. * @returns a vector3
  25381. */
  25382. static Center(meshesOrMinMaxVector: {
  25383. min: Vector3;
  25384. max: Vector3;
  25385. } | AbstractMesh[]): Vector3;
  25386. /**
  25387. * Merge the array of meshes into a single mesh for performance reasons.
  25388. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25389. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25390. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25391. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25392. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25393. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25394. * @returns a new mesh
  25395. */
  25396. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25397. /** @hidden */
  25398. addInstance(instance: InstancedMesh): void;
  25399. /** @hidden */
  25400. removeInstance(instance: InstancedMesh): void;
  25401. }
  25402. }
  25403. declare module BABYLON {
  25404. /**
  25405. * This is the base class of all the camera used in the application.
  25406. * @see http://doc.babylonjs.com/features/cameras
  25407. */
  25408. export class Camera extends Node {
  25409. /** @hidden */
  25410. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25411. /**
  25412. * This is the default projection mode used by the cameras.
  25413. * It helps recreating a feeling of perspective and better appreciate depth.
  25414. * This is the best way to simulate real life cameras.
  25415. */
  25416. static readonly PERSPECTIVE_CAMERA: number;
  25417. /**
  25418. * This helps creating camera with an orthographic mode.
  25419. * 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.
  25420. */
  25421. static readonly ORTHOGRAPHIC_CAMERA: number;
  25422. /**
  25423. * This is the default FOV mode for perspective cameras.
  25424. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25425. */
  25426. static readonly FOVMODE_VERTICAL_FIXED: number;
  25427. /**
  25428. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25429. */
  25430. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25431. /**
  25432. * This specifies ther is no need for a camera rig.
  25433. * Basically only one eye is rendered corresponding to the camera.
  25434. */
  25435. static readonly RIG_MODE_NONE: number;
  25436. /**
  25437. * Simulates a camera Rig with one blue eye and one red eye.
  25438. * This can be use with 3d blue and red glasses.
  25439. */
  25440. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25441. /**
  25442. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25443. */
  25444. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25445. /**
  25446. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25447. */
  25448. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25449. /**
  25450. * Defines that both eyes of the camera will be rendered over under each other.
  25451. */
  25452. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25453. /**
  25454. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25455. */
  25456. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25457. /**
  25458. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25459. */
  25460. static readonly RIG_MODE_VR: number;
  25461. /**
  25462. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25463. */
  25464. static readonly RIG_MODE_WEBVR: number;
  25465. /**
  25466. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25467. */
  25468. static readonly RIG_MODE_CUSTOM: number;
  25469. /**
  25470. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25471. */
  25472. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25473. /**
  25474. * Define the input manager associated with the camera.
  25475. */
  25476. inputs: CameraInputsManager<Camera>;
  25477. /** @hidden */
  25478. _position: Vector3;
  25479. /**
  25480. * Define the current local position of the camera in the scene
  25481. */
  25482. get position(): Vector3;
  25483. set position(newPosition: Vector3);
  25484. /**
  25485. * The vector the camera should consider as up.
  25486. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25487. */
  25488. upVector: Vector3;
  25489. /**
  25490. * Define the current limit on the left side for an orthographic camera
  25491. * In scene unit
  25492. */
  25493. orthoLeft: Nullable<number>;
  25494. /**
  25495. * Define the current limit on the right side for an orthographic camera
  25496. * In scene unit
  25497. */
  25498. orthoRight: Nullable<number>;
  25499. /**
  25500. * Define the current limit on the bottom side for an orthographic camera
  25501. * In scene unit
  25502. */
  25503. orthoBottom: Nullable<number>;
  25504. /**
  25505. * Define the current limit on the top side for an orthographic camera
  25506. * In scene unit
  25507. */
  25508. orthoTop: Nullable<number>;
  25509. /**
  25510. * Field Of View is set in Radians. (default is 0.8)
  25511. */
  25512. fov: number;
  25513. /**
  25514. * Define the minimum distance the camera can see from.
  25515. * This is important to note that the depth buffer are not infinite and the closer it starts
  25516. * the more your scene might encounter depth fighting issue.
  25517. */
  25518. minZ: number;
  25519. /**
  25520. * Define the maximum distance the camera can see to.
  25521. * This is important to note that the depth buffer are not infinite and the further it end
  25522. * the more your scene might encounter depth fighting issue.
  25523. */
  25524. maxZ: number;
  25525. /**
  25526. * Define the default inertia of the camera.
  25527. * This helps giving a smooth feeling to the camera movement.
  25528. */
  25529. inertia: number;
  25530. /**
  25531. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25532. */
  25533. mode: number;
  25534. /**
  25535. * Define whether the camera is intermediate.
  25536. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25537. */
  25538. isIntermediate: boolean;
  25539. /**
  25540. * Define the viewport of the camera.
  25541. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25542. */
  25543. viewport: Viewport;
  25544. /**
  25545. * Restricts the camera to viewing objects with the same layerMask.
  25546. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25547. */
  25548. layerMask: number;
  25549. /**
  25550. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25551. */
  25552. fovMode: number;
  25553. /**
  25554. * Rig mode of the camera.
  25555. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25556. * This is normally controlled byt the camera themselves as internal use.
  25557. */
  25558. cameraRigMode: number;
  25559. /**
  25560. * Defines the distance between both "eyes" in case of a RIG
  25561. */
  25562. interaxialDistance: number;
  25563. /**
  25564. * Defines if stereoscopic rendering is done side by side or over under.
  25565. */
  25566. isStereoscopicSideBySide: boolean;
  25567. /**
  25568. * 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
  25569. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25570. * else in the scene. (Eg. security camera)
  25571. *
  25572. * 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)
  25573. */
  25574. customRenderTargets: RenderTargetTexture[];
  25575. /**
  25576. * When set, the camera will render to this render target instead of the default canvas
  25577. *
  25578. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25579. */
  25580. outputRenderTarget: Nullable<RenderTargetTexture>;
  25581. /**
  25582. * Observable triggered when the camera view matrix has changed.
  25583. */
  25584. onViewMatrixChangedObservable: Observable<Camera>;
  25585. /**
  25586. * Observable triggered when the camera Projection matrix has changed.
  25587. */
  25588. onProjectionMatrixChangedObservable: Observable<Camera>;
  25589. /**
  25590. * Observable triggered when the inputs have been processed.
  25591. */
  25592. onAfterCheckInputsObservable: Observable<Camera>;
  25593. /**
  25594. * Observable triggered when reset has been called and applied to the camera.
  25595. */
  25596. onRestoreStateObservable: Observable<Camera>;
  25597. /**
  25598. * Is this camera a part of a rig system?
  25599. */
  25600. isRigCamera: boolean;
  25601. /**
  25602. * If isRigCamera set to true this will be set with the parent camera.
  25603. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25604. */
  25605. rigParent?: Camera;
  25606. /** @hidden */
  25607. _cameraRigParams: any;
  25608. /** @hidden */
  25609. _rigCameras: Camera[];
  25610. /** @hidden */
  25611. _rigPostProcess: Nullable<PostProcess>;
  25612. protected _webvrViewMatrix: Matrix;
  25613. /** @hidden */
  25614. _skipRendering: boolean;
  25615. /** @hidden */
  25616. _projectionMatrix: Matrix;
  25617. /** @hidden */
  25618. _postProcesses: Nullable<PostProcess>[];
  25619. /** @hidden */
  25620. _activeMeshes: SmartArray<AbstractMesh>;
  25621. protected _globalPosition: Vector3;
  25622. /** @hidden */
  25623. _computedViewMatrix: Matrix;
  25624. private _doNotComputeProjectionMatrix;
  25625. private _transformMatrix;
  25626. private _frustumPlanes;
  25627. private _refreshFrustumPlanes;
  25628. private _storedFov;
  25629. private _stateStored;
  25630. /**
  25631. * Instantiates a new camera object.
  25632. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25633. * @see http://doc.babylonjs.com/features/cameras
  25634. * @param name Defines the name of the camera in the scene
  25635. * @param position Defines the position of the camera
  25636. * @param scene Defines the scene the camera belongs too
  25637. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25638. */
  25639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25640. /**
  25641. * Store current camera state (fov, position, etc..)
  25642. * @returns the camera
  25643. */
  25644. storeState(): Camera;
  25645. /**
  25646. * Restores the camera state values if it has been stored. You must call storeState() first
  25647. */
  25648. protected _restoreStateValues(): boolean;
  25649. /**
  25650. * Restored camera state. You must call storeState() first.
  25651. * @returns true if restored and false otherwise
  25652. */
  25653. restoreState(): boolean;
  25654. /**
  25655. * Gets the class name of the camera.
  25656. * @returns the class name
  25657. */
  25658. getClassName(): string;
  25659. /** @hidden */
  25660. readonly _isCamera: boolean;
  25661. /**
  25662. * Gets a string representation of the camera useful for debug purpose.
  25663. * @param fullDetails Defines that a more verboe level of logging is required
  25664. * @returns the string representation
  25665. */
  25666. toString(fullDetails?: boolean): string;
  25667. /**
  25668. * Gets the current world space position of the camera.
  25669. */
  25670. get globalPosition(): Vector3;
  25671. /**
  25672. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25673. * @returns the active meshe list
  25674. */
  25675. getActiveMeshes(): SmartArray<AbstractMesh>;
  25676. /**
  25677. * Check whether a mesh is part of the current active mesh list of the camera
  25678. * @param mesh Defines the mesh to check
  25679. * @returns true if active, false otherwise
  25680. */
  25681. isActiveMesh(mesh: Mesh): boolean;
  25682. /**
  25683. * Is this camera ready to be used/rendered
  25684. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25685. * @return true if the camera is ready
  25686. */
  25687. isReady(completeCheck?: boolean): boolean;
  25688. /** @hidden */
  25689. _initCache(): void;
  25690. /** @hidden */
  25691. _updateCache(ignoreParentClass?: boolean): void;
  25692. /** @hidden */
  25693. _isSynchronized(): boolean;
  25694. /** @hidden */
  25695. _isSynchronizedViewMatrix(): boolean;
  25696. /** @hidden */
  25697. _isSynchronizedProjectionMatrix(): boolean;
  25698. /**
  25699. * Attach the input controls to a specific dom element to get the input from.
  25700. * @param element Defines the element the controls should be listened from
  25701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25702. */
  25703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25704. /**
  25705. * Detach the current controls from the specified dom element.
  25706. * @param element Defines the element to stop listening the inputs from
  25707. */
  25708. detachControl(element: HTMLElement): void;
  25709. /**
  25710. * Update the camera state according to the different inputs gathered during the frame.
  25711. */
  25712. update(): void;
  25713. /** @hidden */
  25714. _checkInputs(): void;
  25715. /** @hidden */
  25716. get rigCameras(): Camera[];
  25717. /**
  25718. * Gets the post process used by the rig cameras
  25719. */
  25720. get rigPostProcess(): Nullable<PostProcess>;
  25721. /**
  25722. * Internal, gets the first post proces.
  25723. * @returns the first post process to be run on this camera.
  25724. */
  25725. _getFirstPostProcess(): Nullable<PostProcess>;
  25726. private _cascadePostProcessesToRigCams;
  25727. /**
  25728. * Attach a post process to the camera.
  25729. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25730. * @param postProcess The post process to attach to the camera
  25731. * @param insertAt The position of the post process in case several of them are in use in the scene
  25732. * @returns the position the post process has been inserted at
  25733. */
  25734. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25735. /**
  25736. * Detach a post process to the camera.
  25737. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25738. * @param postProcess The post process to detach from the camera
  25739. */
  25740. detachPostProcess(postProcess: PostProcess): void;
  25741. /**
  25742. * Gets the current world matrix of the camera
  25743. */
  25744. getWorldMatrix(): Matrix;
  25745. /** @hidden */
  25746. _getViewMatrix(): Matrix;
  25747. /**
  25748. * Gets the current view matrix of the camera.
  25749. * @param force forces the camera to recompute the matrix without looking at the cached state
  25750. * @returns the view matrix
  25751. */
  25752. getViewMatrix(force?: boolean): Matrix;
  25753. /**
  25754. * Freeze the projection matrix.
  25755. * It will prevent the cache check of the camera projection compute and can speed up perf
  25756. * if no parameter of the camera are meant to change
  25757. * @param projection Defines manually a projection if necessary
  25758. */
  25759. freezeProjectionMatrix(projection?: Matrix): void;
  25760. /**
  25761. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25762. */
  25763. unfreezeProjectionMatrix(): void;
  25764. /**
  25765. * Gets the current projection matrix of the camera.
  25766. * @param force forces the camera to recompute the matrix without looking at the cached state
  25767. * @returns the projection matrix
  25768. */
  25769. getProjectionMatrix(force?: boolean): Matrix;
  25770. /**
  25771. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25772. * @returns a Matrix
  25773. */
  25774. getTransformationMatrix(): Matrix;
  25775. private _updateFrustumPlanes;
  25776. /**
  25777. * Checks if a cullable object (mesh...) is in the camera frustum
  25778. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25779. * @param target The object to check
  25780. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25781. * @returns true if the object is in frustum otherwise false
  25782. */
  25783. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25784. /**
  25785. * Checks if a cullable object (mesh...) is in the camera frustum
  25786. * Unlike isInFrustum this cheks the full bounding box
  25787. * @param target The object to check
  25788. * @returns true if the object is in frustum otherwise false
  25789. */
  25790. isCompletelyInFrustum(target: ICullable): boolean;
  25791. /**
  25792. * Gets a ray in the forward direction from the camera.
  25793. * @param length Defines the length of the ray to create
  25794. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25795. * @param origin Defines the start point of the ray which defaults to the camera position
  25796. * @returns the forward ray
  25797. */
  25798. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25799. /**
  25800. * Releases resources associated with this node.
  25801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25803. */
  25804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25805. /** @hidden */
  25806. _isLeftCamera: boolean;
  25807. /**
  25808. * Gets the left camera of a rig setup in case of Rigged Camera
  25809. */
  25810. get isLeftCamera(): boolean;
  25811. /** @hidden */
  25812. _isRightCamera: boolean;
  25813. /**
  25814. * Gets the right camera of a rig setup in case of Rigged Camera
  25815. */
  25816. get isRightCamera(): boolean;
  25817. /**
  25818. * Gets the left camera of a rig setup in case of Rigged Camera
  25819. */
  25820. get leftCamera(): Nullable<FreeCamera>;
  25821. /**
  25822. * Gets the right camera of a rig setup in case of Rigged Camera
  25823. */
  25824. get rightCamera(): Nullable<FreeCamera>;
  25825. /**
  25826. * Gets the left camera target of a rig setup in case of Rigged Camera
  25827. * @returns the target position
  25828. */
  25829. getLeftTarget(): Nullable<Vector3>;
  25830. /**
  25831. * Gets the right camera target of a rig setup in case of Rigged Camera
  25832. * @returns the target position
  25833. */
  25834. getRightTarget(): Nullable<Vector3>;
  25835. /**
  25836. * @hidden
  25837. */
  25838. setCameraRigMode(mode: number, rigParams: any): void;
  25839. /** @hidden */
  25840. static _setStereoscopicRigMode(camera: Camera): void;
  25841. /** @hidden */
  25842. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25843. /** @hidden */
  25844. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25845. /** @hidden */
  25846. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25847. /** @hidden */
  25848. _getVRProjectionMatrix(): Matrix;
  25849. protected _updateCameraRotationMatrix(): void;
  25850. protected _updateWebVRCameraRotationMatrix(): void;
  25851. /**
  25852. * This function MUST be overwritten by the different WebVR cameras available.
  25853. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25854. * @hidden
  25855. */
  25856. _getWebVRProjectionMatrix(): Matrix;
  25857. /**
  25858. * This function MUST be overwritten by the different WebVR cameras available.
  25859. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25860. * @hidden
  25861. */
  25862. _getWebVRViewMatrix(): Matrix;
  25863. /** @hidden */
  25864. setCameraRigParameter(name: string, value: any): void;
  25865. /**
  25866. * needs to be overridden by children so sub has required properties to be copied
  25867. * @hidden
  25868. */
  25869. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25870. /**
  25871. * May need to be overridden by children
  25872. * @hidden
  25873. */
  25874. _updateRigCameras(): void;
  25875. /** @hidden */
  25876. _setupInputs(): void;
  25877. /**
  25878. * Serialiaze the camera setup to a json represention
  25879. * @returns the JSON representation
  25880. */
  25881. serialize(): any;
  25882. /**
  25883. * Clones the current camera.
  25884. * @param name The cloned camera name
  25885. * @returns the cloned camera
  25886. */
  25887. clone(name: string): Camera;
  25888. /**
  25889. * Gets the direction of the camera relative to a given local axis.
  25890. * @param localAxis Defines the reference axis to provide a relative direction.
  25891. * @return the direction
  25892. */
  25893. getDirection(localAxis: Vector3): Vector3;
  25894. /**
  25895. * Returns the current camera absolute rotation
  25896. */
  25897. get absoluteRotation(): Quaternion;
  25898. /**
  25899. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25900. * @param localAxis Defines the reference axis to provide a relative direction.
  25901. * @param result Defines the vector to store the result in
  25902. */
  25903. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25904. /**
  25905. * Gets a camera constructor for a given camera type
  25906. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25907. * @param name The name of the camera the result will be able to instantiate
  25908. * @param scene The scene the result will construct the camera in
  25909. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25910. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25911. * @returns a factory method to construc the camera
  25912. */
  25913. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25914. /**
  25915. * Compute the world matrix of the camera.
  25916. * @returns the camera world matrix
  25917. */
  25918. computeWorldMatrix(): Matrix;
  25919. /**
  25920. * Parse a JSON and creates the camera from the parsed information
  25921. * @param parsedCamera The JSON to parse
  25922. * @param scene The scene to instantiate the camera in
  25923. * @returns the newly constructed camera
  25924. */
  25925. static Parse(parsedCamera: any, scene: Scene): Camera;
  25926. }
  25927. }
  25928. declare module BABYLON {
  25929. /**
  25930. * Class containing static functions to help procedurally build meshes
  25931. */
  25932. export class DiscBuilder {
  25933. /**
  25934. * Creates a plane polygonal mesh. By default, this is a disc
  25935. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25936. * * 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
  25937. * * 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
  25938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25939. * * 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
  25940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25941. * @param name defines the name of the mesh
  25942. * @param options defines the options used to create the mesh
  25943. * @param scene defines the hosting scene
  25944. * @returns the plane polygonal mesh
  25945. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25946. */
  25947. static CreateDisc(name: string, options: {
  25948. radius?: number;
  25949. tessellation?: number;
  25950. arc?: number;
  25951. updatable?: boolean;
  25952. sideOrientation?: number;
  25953. frontUVs?: Vector4;
  25954. backUVs?: Vector4;
  25955. }, scene?: Nullable<Scene>): Mesh;
  25956. }
  25957. }
  25958. declare module BABYLON {
  25959. /**
  25960. * This represents all the required information to add a fresnel effect on a material:
  25961. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25962. */
  25963. export class FresnelParameters {
  25964. private _isEnabled;
  25965. /**
  25966. * Define if the fresnel effect is enable or not.
  25967. */
  25968. get isEnabled(): boolean;
  25969. set isEnabled(value: boolean);
  25970. /**
  25971. * Define the color used on edges (grazing angle)
  25972. */
  25973. leftColor: Color3;
  25974. /**
  25975. * Define the color used on center
  25976. */
  25977. rightColor: Color3;
  25978. /**
  25979. * Define bias applied to computed fresnel term
  25980. */
  25981. bias: number;
  25982. /**
  25983. * Defined the power exponent applied to fresnel term
  25984. */
  25985. power: number;
  25986. /**
  25987. * Clones the current fresnel and its valuues
  25988. * @returns a clone fresnel configuration
  25989. */
  25990. clone(): FresnelParameters;
  25991. /**
  25992. * Serializes the current fresnel parameters to a JSON representation.
  25993. * @return the JSON serialization
  25994. */
  25995. serialize(): any;
  25996. /**
  25997. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25998. * @param parsedFresnelParameters Define the JSON representation
  25999. * @returns the parsed parameters
  26000. */
  26001. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26002. }
  26003. }
  26004. declare module BABYLON {
  26005. /**
  26006. * Base class of materials working in push mode in babylon JS
  26007. * @hidden
  26008. */
  26009. export class PushMaterial extends Material {
  26010. protected _activeEffect: Effect;
  26011. protected _normalMatrix: Matrix;
  26012. /**
  26013. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26014. * This means that the material can keep using a previous shader while a new one is being compiled.
  26015. * This is mostly used when shader parallel compilation is supported (true by default)
  26016. */
  26017. allowShaderHotSwapping: boolean;
  26018. constructor(name: string, scene: Scene);
  26019. getEffect(): Effect;
  26020. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26021. /**
  26022. * Binds the given world matrix to the active effect
  26023. *
  26024. * @param world the matrix to bind
  26025. */
  26026. bindOnlyWorldMatrix(world: Matrix): void;
  26027. /**
  26028. * Binds the given normal matrix to the active effect
  26029. *
  26030. * @param normalMatrix the matrix to bind
  26031. */
  26032. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26033. bind(world: Matrix, mesh?: Mesh): void;
  26034. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26035. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26036. }
  26037. }
  26038. declare module BABYLON {
  26039. /**
  26040. * This groups all the flags used to control the materials channel.
  26041. */
  26042. export class MaterialFlags {
  26043. private static _DiffuseTextureEnabled;
  26044. /**
  26045. * Are diffuse textures enabled in the application.
  26046. */
  26047. static get DiffuseTextureEnabled(): boolean;
  26048. static set DiffuseTextureEnabled(value: boolean);
  26049. private static _AmbientTextureEnabled;
  26050. /**
  26051. * Are ambient textures enabled in the application.
  26052. */
  26053. static get AmbientTextureEnabled(): boolean;
  26054. static set AmbientTextureEnabled(value: boolean);
  26055. private static _OpacityTextureEnabled;
  26056. /**
  26057. * Are opacity textures enabled in the application.
  26058. */
  26059. static get OpacityTextureEnabled(): boolean;
  26060. static set OpacityTextureEnabled(value: boolean);
  26061. private static _ReflectionTextureEnabled;
  26062. /**
  26063. * Are reflection textures enabled in the application.
  26064. */
  26065. static get ReflectionTextureEnabled(): boolean;
  26066. static set ReflectionTextureEnabled(value: boolean);
  26067. private static _EmissiveTextureEnabled;
  26068. /**
  26069. * Are emissive textures enabled in the application.
  26070. */
  26071. static get EmissiveTextureEnabled(): boolean;
  26072. static set EmissiveTextureEnabled(value: boolean);
  26073. private static _SpecularTextureEnabled;
  26074. /**
  26075. * Are specular textures enabled in the application.
  26076. */
  26077. static get SpecularTextureEnabled(): boolean;
  26078. static set SpecularTextureEnabled(value: boolean);
  26079. private static _BumpTextureEnabled;
  26080. /**
  26081. * Are bump textures enabled in the application.
  26082. */
  26083. static get BumpTextureEnabled(): boolean;
  26084. static set BumpTextureEnabled(value: boolean);
  26085. private static _LightmapTextureEnabled;
  26086. /**
  26087. * Are lightmap textures enabled in the application.
  26088. */
  26089. static get LightmapTextureEnabled(): boolean;
  26090. static set LightmapTextureEnabled(value: boolean);
  26091. private static _RefractionTextureEnabled;
  26092. /**
  26093. * Are refraction textures enabled in the application.
  26094. */
  26095. static get RefractionTextureEnabled(): boolean;
  26096. static set RefractionTextureEnabled(value: boolean);
  26097. private static _ColorGradingTextureEnabled;
  26098. /**
  26099. * Are color grading textures enabled in the application.
  26100. */
  26101. static get ColorGradingTextureEnabled(): boolean;
  26102. static set ColorGradingTextureEnabled(value: boolean);
  26103. private static _FresnelEnabled;
  26104. /**
  26105. * Are fresnels enabled in the application.
  26106. */
  26107. static get FresnelEnabled(): boolean;
  26108. static set FresnelEnabled(value: boolean);
  26109. private static _ClearCoatTextureEnabled;
  26110. /**
  26111. * Are clear coat textures enabled in the application.
  26112. */
  26113. static get ClearCoatTextureEnabled(): boolean;
  26114. static set ClearCoatTextureEnabled(value: boolean);
  26115. private static _ClearCoatBumpTextureEnabled;
  26116. /**
  26117. * Are clear coat bump textures enabled in the application.
  26118. */
  26119. static get ClearCoatBumpTextureEnabled(): boolean;
  26120. static set ClearCoatBumpTextureEnabled(value: boolean);
  26121. private static _ClearCoatTintTextureEnabled;
  26122. /**
  26123. * Are clear coat tint textures enabled in the application.
  26124. */
  26125. static get ClearCoatTintTextureEnabled(): boolean;
  26126. static set ClearCoatTintTextureEnabled(value: boolean);
  26127. private static _SheenTextureEnabled;
  26128. /**
  26129. * Are sheen textures enabled in the application.
  26130. */
  26131. static get SheenTextureEnabled(): boolean;
  26132. static set SheenTextureEnabled(value: boolean);
  26133. private static _AnisotropicTextureEnabled;
  26134. /**
  26135. * Are anisotropic textures enabled in the application.
  26136. */
  26137. static get AnisotropicTextureEnabled(): boolean;
  26138. static set AnisotropicTextureEnabled(value: boolean);
  26139. private static _ThicknessTextureEnabled;
  26140. /**
  26141. * Are thickness textures enabled in the application.
  26142. */
  26143. static get ThicknessTextureEnabled(): boolean;
  26144. static set ThicknessTextureEnabled(value: boolean);
  26145. }
  26146. }
  26147. declare module BABYLON {
  26148. /** @hidden */
  26149. export var defaultFragmentDeclaration: {
  26150. name: string;
  26151. shader: string;
  26152. };
  26153. }
  26154. declare module BABYLON {
  26155. /** @hidden */
  26156. export var defaultUboDeclaration: {
  26157. name: string;
  26158. shader: string;
  26159. };
  26160. }
  26161. declare module BABYLON {
  26162. /** @hidden */
  26163. export var lightFragmentDeclaration: {
  26164. name: string;
  26165. shader: string;
  26166. };
  26167. }
  26168. declare module BABYLON {
  26169. /** @hidden */
  26170. export var lightUboDeclaration: {
  26171. name: string;
  26172. shader: string;
  26173. };
  26174. }
  26175. declare module BABYLON {
  26176. /** @hidden */
  26177. export var lightsFragmentFunctions: {
  26178. name: string;
  26179. shader: string;
  26180. };
  26181. }
  26182. declare module BABYLON {
  26183. /** @hidden */
  26184. export var shadowsFragmentFunctions: {
  26185. name: string;
  26186. shader: string;
  26187. };
  26188. }
  26189. declare module BABYLON {
  26190. /** @hidden */
  26191. export var fresnelFunction: {
  26192. name: string;
  26193. shader: string;
  26194. };
  26195. }
  26196. declare module BABYLON {
  26197. /** @hidden */
  26198. export var reflectionFunction: {
  26199. name: string;
  26200. shader: string;
  26201. };
  26202. }
  26203. declare module BABYLON {
  26204. /** @hidden */
  26205. export var bumpFragmentFunctions: {
  26206. name: string;
  26207. shader: string;
  26208. };
  26209. }
  26210. declare module BABYLON {
  26211. /** @hidden */
  26212. export var logDepthDeclaration: {
  26213. name: string;
  26214. shader: string;
  26215. };
  26216. }
  26217. declare module BABYLON {
  26218. /** @hidden */
  26219. export var bumpFragment: {
  26220. name: string;
  26221. shader: string;
  26222. };
  26223. }
  26224. declare module BABYLON {
  26225. /** @hidden */
  26226. export var depthPrePass: {
  26227. name: string;
  26228. shader: string;
  26229. };
  26230. }
  26231. declare module BABYLON {
  26232. /** @hidden */
  26233. export var lightFragment: {
  26234. name: string;
  26235. shader: string;
  26236. };
  26237. }
  26238. declare module BABYLON {
  26239. /** @hidden */
  26240. export var logDepthFragment: {
  26241. name: string;
  26242. shader: string;
  26243. };
  26244. }
  26245. declare module BABYLON {
  26246. /** @hidden */
  26247. export var defaultPixelShader: {
  26248. name: string;
  26249. shader: string;
  26250. };
  26251. }
  26252. declare module BABYLON {
  26253. /** @hidden */
  26254. export var defaultVertexDeclaration: {
  26255. name: string;
  26256. shader: string;
  26257. };
  26258. }
  26259. declare module BABYLON {
  26260. /** @hidden */
  26261. export var bumpVertexDeclaration: {
  26262. name: string;
  26263. shader: string;
  26264. };
  26265. }
  26266. declare module BABYLON {
  26267. /** @hidden */
  26268. export var bumpVertex: {
  26269. name: string;
  26270. shader: string;
  26271. };
  26272. }
  26273. declare module BABYLON {
  26274. /** @hidden */
  26275. export var fogVertex: {
  26276. name: string;
  26277. shader: string;
  26278. };
  26279. }
  26280. declare module BABYLON {
  26281. /** @hidden */
  26282. export var shadowsVertex: {
  26283. name: string;
  26284. shader: string;
  26285. };
  26286. }
  26287. declare module BABYLON {
  26288. /** @hidden */
  26289. export var pointCloudVertex: {
  26290. name: string;
  26291. shader: string;
  26292. };
  26293. }
  26294. declare module BABYLON {
  26295. /** @hidden */
  26296. export var logDepthVertex: {
  26297. name: string;
  26298. shader: string;
  26299. };
  26300. }
  26301. declare module BABYLON {
  26302. /** @hidden */
  26303. export var defaultVertexShader: {
  26304. name: string;
  26305. shader: string;
  26306. };
  26307. }
  26308. declare module BABYLON {
  26309. /** @hidden */
  26310. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26311. MAINUV1: boolean;
  26312. MAINUV2: boolean;
  26313. DIFFUSE: boolean;
  26314. DIFFUSEDIRECTUV: number;
  26315. AMBIENT: boolean;
  26316. AMBIENTDIRECTUV: number;
  26317. OPACITY: boolean;
  26318. OPACITYDIRECTUV: number;
  26319. OPACITYRGB: boolean;
  26320. REFLECTION: boolean;
  26321. EMISSIVE: boolean;
  26322. EMISSIVEDIRECTUV: number;
  26323. SPECULAR: boolean;
  26324. SPECULARDIRECTUV: number;
  26325. BUMP: boolean;
  26326. BUMPDIRECTUV: number;
  26327. PARALLAX: boolean;
  26328. PARALLAXOCCLUSION: boolean;
  26329. SPECULAROVERALPHA: boolean;
  26330. CLIPPLANE: boolean;
  26331. CLIPPLANE2: boolean;
  26332. CLIPPLANE3: boolean;
  26333. CLIPPLANE4: boolean;
  26334. CLIPPLANE5: boolean;
  26335. CLIPPLANE6: boolean;
  26336. ALPHATEST: boolean;
  26337. DEPTHPREPASS: boolean;
  26338. ALPHAFROMDIFFUSE: boolean;
  26339. POINTSIZE: boolean;
  26340. FOG: boolean;
  26341. SPECULARTERM: boolean;
  26342. DIFFUSEFRESNEL: boolean;
  26343. OPACITYFRESNEL: boolean;
  26344. REFLECTIONFRESNEL: boolean;
  26345. REFRACTIONFRESNEL: boolean;
  26346. EMISSIVEFRESNEL: boolean;
  26347. FRESNEL: boolean;
  26348. NORMAL: boolean;
  26349. UV1: boolean;
  26350. UV2: boolean;
  26351. VERTEXCOLOR: boolean;
  26352. VERTEXALPHA: boolean;
  26353. NUM_BONE_INFLUENCERS: number;
  26354. BonesPerMesh: number;
  26355. BONETEXTURE: boolean;
  26356. INSTANCES: boolean;
  26357. GLOSSINESS: boolean;
  26358. ROUGHNESS: boolean;
  26359. EMISSIVEASILLUMINATION: boolean;
  26360. LINKEMISSIVEWITHDIFFUSE: boolean;
  26361. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26362. LIGHTMAP: boolean;
  26363. LIGHTMAPDIRECTUV: number;
  26364. OBJECTSPACE_NORMALMAP: boolean;
  26365. USELIGHTMAPASSHADOWMAP: boolean;
  26366. REFLECTIONMAP_3D: boolean;
  26367. REFLECTIONMAP_SPHERICAL: boolean;
  26368. REFLECTIONMAP_PLANAR: boolean;
  26369. REFLECTIONMAP_CUBIC: boolean;
  26370. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26371. REFLECTIONMAP_PROJECTION: boolean;
  26372. REFLECTIONMAP_SKYBOX: boolean;
  26373. REFLECTIONMAP_EXPLICIT: boolean;
  26374. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26375. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26376. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26377. INVERTCUBICMAP: boolean;
  26378. LOGARITHMICDEPTH: boolean;
  26379. REFRACTION: boolean;
  26380. REFRACTIONMAP_3D: boolean;
  26381. REFLECTIONOVERALPHA: boolean;
  26382. TWOSIDEDLIGHTING: boolean;
  26383. SHADOWFLOAT: boolean;
  26384. MORPHTARGETS: boolean;
  26385. MORPHTARGETS_NORMAL: boolean;
  26386. MORPHTARGETS_TANGENT: boolean;
  26387. MORPHTARGETS_UV: boolean;
  26388. NUM_MORPH_INFLUENCERS: number;
  26389. NONUNIFORMSCALING: boolean;
  26390. PREMULTIPLYALPHA: boolean;
  26391. IMAGEPROCESSING: boolean;
  26392. VIGNETTE: boolean;
  26393. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26394. VIGNETTEBLENDMODEOPAQUE: boolean;
  26395. TONEMAPPING: boolean;
  26396. TONEMAPPING_ACES: boolean;
  26397. CONTRAST: boolean;
  26398. COLORCURVES: boolean;
  26399. COLORGRADING: boolean;
  26400. COLORGRADING3D: boolean;
  26401. SAMPLER3DGREENDEPTH: boolean;
  26402. SAMPLER3DBGRMAP: boolean;
  26403. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26404. MULTIVIEW: boolean;
  26405. /**
  26406. * If the reflection texture on this material is in linear color space
  26407. * @hidden
  26408. */
  26409. IS_REFLECTION_LINEAR: boolean;
  26410. /**
  26411. * If the refraction texture on this material is in linear color space
  26412. * @hidden
  26413. */
  26414. IS_REFRACTION_LINEAR: boolean;
  26415. EXPOSURE: boolean;
  26416. constructor();
  26417. setReflectionMode(modeToEnable: string): void;
  26418. }
  26419. /**
  26420. * This is the default material used in Babylon. It is the best trade off between quality
  26421. * and performances.
  26422. * @see http://doc.babylonjs.com/babylon101/materials
  26423. */
  26424. export class StandardMaterial extends PushMaterial {
  26425. private _diffuseTexture;
  26426. /**
  26427. * The basic texture of the material as viewed under a light.
  26428. */
  26429. diffuseTexture: Nullable<BaseTexture>;
  26430. private _ambientTexture;
  26431. /**
  26432. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26433. */
  26434. ambientTexture: Nullable<BaseTexture>;
  26435. private _opacityTexture;
  26436. /**
  26437. * Define the transparency of the material from a texture.
  26438. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26439. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26440. */
  26441. opacityTexture: Nullable<BaseTexture>;
  26442. private _reflectionTexture;
  26443. /**
  26444. * Define the texture used to display the reflection.
  26445. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26446. */
  26447. reflectionTexture: Nullable<BaseTexture>;
  26448. private _emissiveTexture;
  26449. /**
  26450. * Define texture of the material as if self lit.
  26451. * This will be mixed in the final result even in the absence of light.
  26452. */
  26453. emissiveTexture: Nullable<BaseTexture>;
  26454. private _specularTexture;
  26455. /**
  26456. * Define how the color and intensity of the highlight given by the light in the material.
  26457. */
  26458. specularTexture: Nullable<BaseTexture>;
  26459. private _bumpTexture;
  26460. /**
  26461. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26462. * 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.
  26463. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26464. */
  26465. bumpTexture: Nullable<BaseTexture>;
  26466. private _lightmapTexture;
  26467. /**
  26468. * Complex lighting can be computationally expensive to compute at runtime.
  26469. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26470. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26471. */
  26472. lightmapTexture: Nullable<BaseTexture>;
  26473. private _refractionTexture;
  26474. /**
  26475. * Define the texture used to display the refraction.
  26476. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26477. */
  26478. refractionTexture: Nullable<BaseTexture>;
  26479. /**
  26480. * The color of the material lit by the environmental background lighting.
  26481. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26482. */
  26483. ambientColor: Color3;
  26484. /**
  26485. * The basic color of the material as viewed under a light.
  26486. */
  26487. diffuseColor: Color3;
  26488. /**
  26489. * Define how the color and intensity of the highlight given by the light in the material.
  26490. */
  26491. specularColor: Color3;
  26492. /**
  26493. * Define the color of the material as if self lit.
  26494. * This will be mixed in the final result even in the absence of light.
  26495. */
  26496. emissiveColor: Color3;
  26497. /**
  26498. * Defines how sharp are the highlights in the material.
  26499. * The bigger the value the sharper giving a more glossy feeling to the result.
  26500. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26501. */
  26502. specularPower: number;
  26503. private _useAlphaFromDiffuseTexture;
  26504. /**
  26505. * Does the transparency come from the diffuse texture alpha channel.
  26506. */
  26507. useAlphaFromDiffuseTexture: boolean;
  26508. private _useEmissiveAsIllumination;
  26509. /**
  26510. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26511. */
  26512. useEmissiveAsIllumination: boolean;
  26513. private _linkEmissiveWithDiffuse;
  26514. /**
  26515. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26516. * the emissive level when the final color is close to one.
  26517. */
  26518. linkEmissiveWithDiffuse: boolean;
  26519. private _useSpecularOverAlpha;
  26520. /**
  26521. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26522. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26523. */
  26524. useSpecularOverAlpha: boolean;
  26525. private _useReflectionOverAlpha;
  26526. /**
  26527. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26528. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26529. */
  26530. useReflectionOverAlpha: boolean;
  26531. private _disableLighting;
  26532. /**
  26533. * Does lights from the scene impacts this material.
  26534. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26535. */
  26536. disableLighting: boolean;
  26537. private _useObjectSpaceNormalMap;
  26538. /**
  26539. * Allows using an object space normal map (instead of tangent space).
  26540. */
  26541. useObjectSpaceNormalMap: boolean;
  26542. private _useParallax;
  26543. /**
  26544. * Is parallax enabled or not.
  26545. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26546. */
  26547. useParallax: boolean;
  26548. private _useParallaxOcclusion;
  26549. /**
  26550. * Is parallax occlusion enabled or not.
  26551. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26552. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26553. */
  26554. useParallaxOcclusion: boolean;
  26555. /**
  26556. * 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.
  26557. */
  26558. parallaxScaleBias: number;
  26559. private _roughness;
  26560. /**
  26561. * Helps to define how blurry the reflections should appears in the material.
  26562. */
  26563. roughness: number;
  26564. /**
  26565. * In case of refraction, define the value of the index of refraction.
  26566. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26567. */
  26568. indexOfRefraction: number;
  26569. /**
  26570. * Invert the refraction texture alongside the y axis.
  26571. * It can be useful with procedural textures or probe for instance.
  26572. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26573. */
  26574. invertRefractionY: boolean;
  26575. /**
  26576. * Defines the alpha limits in alpha test mode.
  26577. */
  26578. alphaCutOff: number;
  26579. private _useLightmapAsShadowmap;
  26580. /**
  26581. * In case of light mapping, define whether the map contains light or shadow informations.
  26582. */
  26583. useLightmapAsShadowmap: boolean;
  26584. private _diffuseFresnelParameters;
  26585. /**
  26586. * Define the diffuse fresnel parameters of the material.
  26587. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26588. */
  26589. diffuseFresnelParameters: FresnelParameters;
  26590. private _opacityFresnelParameters;
  26591. /**
  26592. * Define the opacity fresnel parameters of the material.
  26593. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26594. */
  26595. opacityFresnelParameters: FresnelParameters;
  26596. private _reflectionFresnelParameters;
  26597. /**
  26598. * Define the reflection fresnel parameters of the material.
  26599. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26600. */
  26601. reflectionFresnelParameters: FresnelParameters;
  26602. private _refractionFresnelParameters;
  26603. /**
  26604. * Define the refraction fresnel parameters of the material.
  26605. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26606. */
  26607. refractionFresnelParameters: FresnelParameters;
  26608. private _emissiveFresnelParameters;
  26609. /**
  26610. * Define the emissive fresnel parameters of the material.
  26611. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26612. */
  26613. emissiveFresnelParameters: FresnelParameters;
  26614. private _useReflectionFresnelFromSpecular;
  26615. /**
  26616. * If true automatically deducts the fresnels values from the material specularity.
  26617. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26618. */
  26619. useReflectionFresnelFromSpecular: boolean;
  26620. private _useGlossinessFromSpecularMapAlpha;
  26621. /**
  26622. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26623. */
  26624. useGlossinessFromSpecularMapAlpha: boolean;
  26625. private _maxSimultaneousLights;
  26626. /**
  26627. * Defines the maximum number of lights that can be used in the material
  26628. */
  26629. maxSimultaneousLights: number;
  26630. private _invertNormalMapX;
  26631. /**
  26632. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26633. */
  26634. invertNormalMapX: boolean;
  26635. private _invertNormalMapY;
  26636. /**
  26637. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26638. */
  26639. invertNormalMapY: boolean;
  26640. private _twoSidedLighting;
  26641. /**
  26642. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26643. */
  26644. twoSidedLighting: boolean;
  26645. /**
  26646. * Default configuration related to image processing available in the standard Material.
  26647. */
  26648. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26649. /**
  26650. * Gets the image processing configuration used either in this material.
  26651. */
  26652. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26653. /**
  26654. * Sets the Default image processing configuration used either in the this material.
  26655. *
  26656. * If sets to null, the scene one is in use.
  26657. */
  26658. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26659. /**
  26660. * Keep track of the image processing observer to allow dispose and replace.
  26661. */
  26662. private _imageProcessingObserver;
  26663. /**
  26664. * Attaches a new image processing configuration to the Standard Material.
  26665. * @param configuration
  26666. */
  26667. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26668. /**
  26669. * Gets wether the color curves effect is enabled.
  26670. */
  26671. get cameraColorCurvesEnabled(): boolean;
  26672. /**
  26673. * Sets wether the color curves effect is enabled.
  26674. */
  26675. set cameraColorCurvesEnabled(value: boolean);
  26676. /**
  26677. * Gets wether the color grading effect is enabled.
  26678. */
  26679. get cameraColorGradingEnabled(): boolean;
  26680. /**
  26681. * Gets wether the color grading effect is enabled.
  26682. */
  26683. set cameraColorGradingEnabled(value: boolean);
  26684. /**
  26685. * Gets wether tonemapping is enabled or not.
  26686. */
  26687. get cameraToneMappingEnabled(): boolean;
  26688. /**
  26689. * Sets wether tonemapping is enabled or not
  26690. */
  26691. set cameraToneMappingEnabled(value: boolean);
  26692. /**
  26693. * The camera exposure used on this material.
  26694. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26695. * This corresponds to a photographic exposure.
  26696. */
  26697. get cameraExposure(): number;
  26698. /**
  26699. * The camera exposure used on this material.
  26700. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26701. * This corresponds to a photographic exposure.
  26702. */
  26703. set cameraExposure(value: number);
  26704. /**
  26705. * Gets The camera contrast used on this material.
  26706. */
  26707. get cameraContrast(): number;
  26708. /**
  26709. * Sets The camera contrast used on this material.
  26710. */
  26711. set cameraContrast(value: number);
  26712. /**
  26713. * Gets the Color Grading 2D Lookup Texture.
  26714. */
  26715. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26716. /**
  26717. * Sets the Color Grading 2D Lookup Texture.
  26718. */
  26719. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26720. /**
  26721. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26722. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26723. * 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;
  26724. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26725. */
  26726. get cameraColorCurves(): Nullable<ColorCurves>;
  26727. /**
  26728. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26729. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26730. * 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;
  26731. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26732. */
  26733. set cameraColorCurves(value: Nullable<ColorCurves>);
  26734. /**
  26735. * Custom callback helping to override the default shader used in the material.
  26736. */
  26737. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26738. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26739. protected _worldViewProjectionMatrix: Matrix;
  26740. protected _globalAmbientColor: Color3;
  26741. protected _useLogarithmicDepth: boolean;
  26742. protected _rebuildInParallel: boolean;
  26743. /**
  26744. * Instantiates a new standard material.
  26745. * This is the default material used in Babylon. It is the best trade off between quality
  26746. * and performances.
  26747. * @see http://doc.babylonjs.com/babylon101/materials
  26748. * @param name Define the name of the material in the scene
  26749. * @param scene Define the scene the material belong to
  26750. */
  26751. constructor(name: string, scene: Scene);
  26752. /**
  26753. * Gets a boolean indicating that current material needs to register RTT
  26754. */
  26755. get hasRenderTargetTextures(): boolean;
  26756. /**
  26757. * Gets the current class name of the material e.g. "StandardMaterial"
  26758. * Mainly use in serialization.
  26759. * @returns the class name
  26760. */
  26761. getClassName(): string;
  26762. /**
  26763. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26764. * You can try switching to logarithmic depth.
  26765. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26766. */
  26767. get useLogarithmicDepth(): boolean;
  26768. set useLogarithmicDepth(value: boolean);
  26769. /**
  26770. * Specifies if the material will require alpha blending
  26771. * @returns a boolean specifying if alpha blending is needed
  26772. */
  26773. needAlphaBlending(): boolean;
  26774. /**
  26775. * Specifies if this material should be rendered in alpha test mode
  26776. * @returns a boolean specifying if an alpha test is needed.
  26777. */
  26778. needAlphaTesting(): boolean;
  26779. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26780. /**
  26781. * Get the texture used for alpha test purpose.
  26782. * @returns the diffuse texture in case of the standard material.
  26783. */
  26784. getAlphaTestTexture(): Nullable<BaseTexture>;
  26785. /**
  26786. * Get if the submesh is ready to be used and all its information available.
  26787. * Child classes can use it to update shaders
  26788. * @param mesh defines the mesh to check
  26789. * @param subMesh defines which submesh to check
  26790. * @param useInstances specifies that instances should be used
  26791. * @returns a boolean indicating that the submesh is ready or not
  26792. */
  26793. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26794. /**
  26795. * Builds the material UBO layouts.
  26796. * Used internally during the effect preparation.
  26797. */
  26798. buildUniformLayout(): void;
  26799. /**
  26800. * Unbinds the material from the mesh
  26801. */
  26802. unbind(): void;
  26803. /**
  26804. * Binds the submesh to this material by preparing the effect and shader to draw
  26805. * @param world defines the world transformation matrix
  26806. * @param mesh defines the mesh containing the submesh
  26807. * @param subMesh defines the submesh to bind the material to
  26808. */
  26809. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26810. /**
  26811. * Get the list of animatables in the material.
  26812. * @returns the list of animatables object used in the material
  26813. */
  26814. getAnimatables(): IAnimatable[];
  26815. /**
  26816. * Gets the active textures from the material
  26817. * @returns an array of textures
  26818. */
  26819. getActiveTextures(): BaseTexture[];
  26820. /**
  26821. * Specifies if the material uses a texture
  26822. * @param texture defines the texture to check against the material
  26823. * @returns a boolean specifying if the material uses the texture
  26824. */
  26825. hasTexture(texture: BaseTexture): boolean;
  26826. /**
  26827. * Disposes the material
  26828. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26829. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26830. */
  26831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26832. /**
  26833. * Makes a duplicate of the material, and gives it a new name
  26834. * @param name defines the new name for the duplicated material
  26835. * @returns the cloned material
  26836. */
  26837. clone(name: string): StandardMaterial;
  26838. /**
  26839. * Serializes this material in a JSON representation
  26840. * @returns the serialized material object
  26841. */
  26842. serialize(): any;
  26843. /**
  26844. * Creates a standard material from parsed material data
  26845. * @param source defines the JSON representation of the material
  26846. * @param scene defines the hosting scene
  26847. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26848. * @returns a new standard material
  26849. */
  26850. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26851. /**
  26852. * Are diffuse textures enabled in the application.
  26853. */
  26854. static get DiffuseTextureEnabled(): boolean;
  26855. static set DiffuseTextureEnabled(value: boolean);
  26856. /**
  26857. * Are ambient textures enabled in the application.
  26858. */
  26859. static get AmbientTextureEnabled(): boolean;
  26860. static set AmbientTextureEnabled(value: boolean);
  26861. /**
  26862. * Are opacity textures enabled in the application.
  26863. */
  26864. static get OpacityTextureEnabled(): boolean;
  26865. static set OpacityTextureEnabled(value: boolean);
  26866. /**
  26867. * Are reflection textures enabled in the application.
  26868. */
  26869. static get ReflectionTextureEnabled(): boolean;
  26870. static set ReflectionTextureEnabled(value: boolean);
  26871. /**
  26872. * Are emissive textures enabled in the application.
  26873. */
  26874. static get EmissiveTextureEnabled(): boolean;
  26875. static set EmissiveTextureEnabled(value: boolean);
  26876. /**
  26877. * Are specular textures enabled in the application.
  26878. */
  26879. static get SpecularTextureEnabled(): boolean;
  26880. static set SpecularTextureEnabled(value: boolean);
  26881. /**
  26882. * Are bump textures enabled in the application.
  26883. */
  26884. static get BumpTextureEnabled(): boolean;
  26885. static set BumpTextureEnabled(value: boolean);
  26886. /**
  26887. * Are lightmap textures enabled in the application.
  26888. */
  26889. static get LightmapTextureEnabled(): boolean;
  26890. static set LightmapTextureEnabled(value: boolean);
  26891. /**
  26892. * Are refraction textures enabled in the application.
  26893. */
  26894. static get RefractionTextureEnabled(): boolean;
  26895. static set RefractionTextureEnabled(value: boolean);
  26896. /**
  26897. * Are color grading textures enabled in the application.
  26898. */
  26899. static get ColorGradingTextureEnabled(): boolean;
  26900. static set ColorGradingTextureEnabled(value: boolean);
  26901. /**
  26902. * Are fresnels enabled in the application.
  26903. */
  26904. static get FresnelEnabled(): boolean;
  26905. static set FresnelEnabled(value: boolean);
  26906. }
  26907. }
  26908. declare module BABYLON {
  26909. /**
  26910. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26911. *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.
  26912. * The SPS is also a particle system. It provides some methods to manage the particles.
  26913. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26914. *
  26915. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26916. */
  26917. export class SolidParticleSystem implements IDisposable {
  26918. /**
  26919. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26920. * Example : var p = SPS.particles[i];
  26921. */
  26922. particles: SolidParticle[];
  26923. /**
  26924. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26925. */
  26926. nbParticles: number;
  26927. /**
  26928. * If the particles must ever face the camera (default false). Useful for planar particles.
  26929. */
  26930. billboard: boolean;
  26931. /**
  26932. * Recompute normals when adding a shape
  26933. */
  26934. recomputeNormals: boolean;
  26935. /**
  26936. * This a counter ofr your own usage. It's not set by any SPS functions.
  26937. */
  26938. counter: number;
  26939. /**
  26940. * The SPS name. This name is also given to the underlying mesh.
  26941. */
  26942. name: string;
  26943. /**
  26944. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26945. */
  26946. mesh: Mesh;
  26947. /**
  26948. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26949. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26950. */
  26951. vars: any;
  26952. /**
  26953. * This array is populated when the SPS is set as 'pickable'.
  26954. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26955. * Each element of this array is an object `{idx: int, faceId: int}`.
  26956. * `idx` is the picked particle index in the `SPS.particles` array
  26957. * `faceId` is the picked face index counted within this particle.
  26958. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26959. */
  26960. pickedParticles: {
  26961. idx: number;
  26962. faceId: number;
  26963. }[];
  26964. /**
  26965. * This array is populated when `enableDepthSort` is set to true.
  26966. * Each element of this array is an instance of the class DepthSortedParticle.
  26967. */
  26968. depthSortedParticles: DepthSortedParticle[];
  26969. /**
  26970. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26971. * @hidden
  26972. */
  26973. _bSphereOnly: boolean;
  26974. /**
  26975. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26976. * @hidden
  26977. */
  26978. _bSphereRadiusFactor: number;
  26979. private _scene;
  26980. private _positions;
  26981. private _indices;
  26982. private _normals;
  26983. private _colors;
  26984. private _uvs;
  26985. private _indices32;
  26986. private _positions32;
  26987. private _normals32;
  26988. private _fixedNormal32;
  26989. private _colors32;
  26990. private _uvs32;
  26991. private _index;
  26992. private _updatable;
  26993. private _pickable;
  26994. private _isVisibilityBoxLocked;
  26995. private _alwaysVisible;
  26996. private _depthSort;
  26997. private _expandable;
  26998. private _shapeCounter;
  26999. private _copy;
  27000. private _color;
  27001. private _computeParticleColor;
  27002. private _computeParticleTexture;
  27003. private _computeParticleRotation;
  27004. private _computeParticleVertex;
  27005. private _computeBoundingBox;
  27006. private _depthSortParticles;
  27007. private _camera;
  27008. private _mustUnrotateFixedNormals;
  27009. private _particlesIntersect;
  27010. private _needs32Bits;
  27011. private _isNotBuilt;
  27012. private _lastParticleId;
  27013. private _idxOfId;
  27014. private _multimaterialEnabled;
  27015. private _useModelMaterial;
  27016. private _indicesByMaterial;
  27017. private _materialIndexes;
  27018. private _depthSortFunction;
  27019. private _materialSortFunction;
  27020. private _materials;
  27021. private _multimaterial;
  27022. private _materialIndexesById;
  27023. private _defaultMaterial;
  27024. private _autoUpdateSubMeshes;
  27025. /**
  27026. * Creates a SPS (Solid Particle System) object.
  27027. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27028. * @param scene (Scene) is the scene in which the SPS is added.
  27029. * @param options defines the options of the sps e.g.
  27030. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27031. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27032. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27033. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27034. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27035. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27036. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27037. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27038. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27039. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27040. */
  27041. constructor(name: string, scene: Scene, options?: {
  27042. updatable?: boolean;
  27043. isPickable?: boolean;
  27044. enableDepthSort?: boolean;
  27045. particleIntersection?: boolean;
  27046. boundingSphereOnly?: boolean;
  27047. bSphereRadiusFactor?: number;
  27048. expandable?: boolean;
  27049. useModelMaterial?: boolean;
  27050. enableMultiMaterial?: boolean;
  27051. });
  27052. /**
  27053. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27054. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27055. * @returns the created mesh
  27056. */
  27057. buildMesh(): Mesh;
  27058. /**
  27059. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27060. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27061. * Thus the particles generated from `digest()` have their property `position` set yet.
  27062. * @param mesh ( Mesh ) is the mesh to be digested
  27063. * @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
  27064. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27065. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27066. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27067. * @returns the current SPS
  27068. */
  27069. digest(mesh: Mesh, options?: {
  27070. facetNb?: number;
  27071. number?: number;
  27072. delta?: number;
  27073. storage?: [];
  27074. }): SolidParticleSystem;
  27075. /**
  27076. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27077. * @hidden
  27078. */
  27079. private _unrotateFixedNormals;
  27080. /**
  27081. * Resets the temporary working copy particle
  27082. * @hidden
  27083. */
  27084. private _resetCopy;
  27085. /**
  27086. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27087. * @param p the current index in the positions array to be updated
  27088. * @param ind the current index in the indices array
  27089. * @param shape a Vector3 array, the shape geometry
  27090. * @param positions the positions array to be updated
  27091. * @param meshInd the shape indices array
  27092. * @param indices the indices array to be updated
  27093. * @param meshUV the shape uv array
  27094. * @param uvs the uv array to be updated
  27095. * @param meshCol the shape color array
  27096. * @param colors the color array to be updated
  27097. * @param meshNor the shape normals array
  27098. * @param normals the normals array to be updated
  27099. * @param idx the particle index
  27100. * @param idxInShape the particle index in its shape
  27101. * @param options the addShape() method passed options
  27102. * @model the particle model
  27103. * @hidden
  27104. */
  27105. private _meshBuilder;
  27106. /**
  27107. * Returns a shape Vector3 array from positions float array
  27108. * @param positions float array
  27109. * @returns a vector3 array
  27110. * @hidden
  27111. */
  27112. private _posToShape;
  27113. /**
  27114. * Returns a shapeUV array from a float uvs (array deep copy)
  27115. * @param uvs as a float array
  27116. * @returns a shapeUV array
  27117. * @hidden
  27118. */
  27119. private _uvsToShapeUV;
  27120. /**
  27121. * Adds a new particle object in the particles array
  27122. * @param idx particle index in particles array
  27123. * @param id particle id
  27124. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27125. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27126. * @param model particle ModelShape object
  27127. * @param shapeId model shape identifier
  27128. * @param idxInShape index of the particle in the current model
  27129. * @param bInfo model bounding info object
  27130. * @param storage target storage array, if any
  27131. * @hidden
  27132. */
  27133. private _addParticle;
  27134. /**
  27135. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27136. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27137. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27138. * @param nb (positive integer) the number of particles to be created from this model
  27139. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27140. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27141. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27142. * @returns the number of shapes in the system
  27143. */
  27144. addShape(mesh: Mesh, nb: number, options?: {
  27145. positionFunction?: any;
  27146. vertexFunction?: any;
  27147. storage?: [];
  27148. }): number;
  27149. /**
  27150. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27151. * @hidden
  27152. */
  27153. private _rebuildParticle;
  27154. /**
  27155. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27156. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27157. * @returns the SPS.
  27158. */
  27159. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27160. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27161. * Returns an array with the removed particles.
  27162. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27163. * The SPS can't be empty so at least one particle needs to remain in place.
  27164. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27165. * @param start index of the first particle to remove
  27166. * @param end index of the last particle to remove (included)
  27167. * @returns an array populated with the removed particles
  27168. */
  27169. removeParticles(start: number, end: number): SolidParticle[];
  27170. /**
  27171. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27172. * @param solidParticleArray an array populated with Solid Particles objects
  27173. * @returns the SPS
  27174. */
  27175. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27176. /**
  27177. * Creates a new particle and modifies the SPS mesh geometry :
  27178. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27179. * - calls _addParticle() to populate the particle array
  27180. * factorized code from addShape() and insertParticlesFromArray()
  27181. * @param idx particle index in the particles array
  27182. * @param i particle index in its shape
  27183. * @param modelShape particle ModelShape object
  27184. * @param shape shape vertex array
  27185. * @param meshInd shape indices array
  27186. * @param meshUV shape uv array
  27187. * @param meshCol shape color array
  27188. * @param meshNor shape normals array
  27189. * @param bbInfo shape bounding info
  27190. * @param storage target particle storage
  27191. * @options addShape() passed options
  27192. * @hidden
  27193. */
  27194. private _insertNewParticle;
  27195. /**
  27196. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27197. * This method calls `updateParticle()` for each particle of the SPS.
  27198. * For an animated SPS, it is usually called within the render loop.
  27199. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27200. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27201. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27202. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27203. * @returns the SPS.
  27204. */
  27205. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27206. /**
  27207. * Disposes the SPS.
  27208. */
  27209. dispose(): void;
  27210. /**
  27211. * Returns a SolidParticle object from its identifier : particle.id
  27212. * @param id (integer) the particle Id
  27213. * @returns the searched particle or null if not found in the SPS.
  27214. */
  27215. getParticleById(id: number): Nullable<SolidParticle>;
  27216. /**
  27217. * Returns a new array populated with the particles having the passed shapeId.
  27218. * @param shapeId (integer) the shape identifier
  27219. * @returns a new solid particle array
  27220. */
  27221. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27222. /**
  27223. * Populates the passed array "ref" with the particles having the passed shapeId.
  27224. * @param shapeId the shape identifier
  27225. * @returns the SPS
  27226. * @param ref
  27227. */
  27228. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27229. /**
  27230. * Computes the required SubMeshes according the materials assigned to the particles.
  27231. * @returns the solid particle system.
  27232. * Does nothing if called before the SPS mesh is built.
  27233. */
  27234. computeSubMeshes(): SolidParticleSystem;
  27235. /**
  27236. * Sorts the solid particles by material when MultiMaterial is enabled.
  27237. * Updates the indices32 array.
  27238. * Updates the indicesByMaterial array.
  27239. * Updates the mesh indices array.
  27240. * @returns the SPS
  27241. * @hidden
  27242. */
  27243. private _sortParticlesByMaterial;
  27244. /**
  27245. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27246. * @hidden
  27247. */
  27248. private _setMaterialIndexesById;
  27249. /**
  27250. * Returns an array with unique values of Materials from the passed array
  27251. * @param array the material array to be checked and filtered
  27252. * @hidden
  27253. */
  27254. private _filterUniqueMaterialId;
  27255. /**
  27256. * Sets a new Standard Material as _defaultMaterial if not already set.
  27257. * @hidden
  27258. */
  27259. private _setDefaultMaterial;
  27260. /**
  27261. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27263. * @returns the SPS.
  27264. */
  27265. refreshVisibleSize(): SolidParticleSystem;
  27266. /**
  27267. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27268. * @param size the size (float) of the visibility box
  27269. * note : this doesn't lock the SPS mesh bounding box.
  27270. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27271. */
  27272. setVisibilityBox(size: number): void;
  27273. /**
  27274. * Gets whether the SPS as always visible or not
  27275. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27276. */
  27277. get isAlwaysVisible(): boolean;
  27278. /**
  27279. * Sets the SPS as always visible or not
  27280. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27281. */
  27282. set isAlwaysVisible(val: boolean);
  27283. /**
  27284. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27285. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27286. */
  27287. set isVisibilityBoxLocked(val: boolean);
  27288. /**
  27289. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27290. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27291. */
  27292. get isVisibilityBoxLocked(): boolean;
  27293. /**
  27294. * Tells to `setParticles()` to compute the particle rotations or not.
  27295. * Default value : true. The SPS is faster when it's set to false.
  27296. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27297. */
  27298. set computeParticleRotation(val: boolean);
  27299. /**
  27300. * Tells to `setParticles()` to compute the particle colors or not.
  27301. * Default value : true. The SPS is faster when it's set to false.
  27302. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27303. */
  27304. set computeParticleColor(val: boolean);
  27305. set computeParticleTexture(val: boolean);
  27306. /**
  27307. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27308. * Default value : false. The SPS is faster when it's set to false.
  27309. * Note : the particle custom vertex positions aren't stored values.
  27310. */
  27311. set computeParticleVertex(val: boolean);
  27312. /**
  27313. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27314. */
  27315. set computeBoundingBox(val: boolean);
  27316. /**
  27317. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27318. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27319. * Default : `true`
  27320. */
  27321. set depthSortParticles(val: boolean);
  27322. /**
  27323. * Gets if `setParticles()` computes the particle rotations or not.
  27324. * Default value : true. The SPS is faster when it's set to false.
  27325. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27326. */
  27327. get computeParticleRotation(): boolean;
  27328. /**
  27329. * Gets if `setParticles()` computes the particle colors or not.
  27330. * Default value : true. The SPS is faster when it's set to false.
  27331. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27332. */
  27333. get computeParticleColor(): boolean;
  27334. /**
  27335. * Gets if `setParticles()` computes the particle textures or not.
  27336. * Default value : true. The SPS is faster when it's set to false.
  27337. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27338. */
  27339. get computeParticleTexture(): boolean;
  27340. /**
  27341. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27342. * Default value : false. The SPS is faster when it's set to false.
  27343. * Note : the particle custom vertex positions aren't stored values.
  27344. */
  27345. get computeParticleVertex(): boolean;
  27346. /**
  27347. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27348. */
  27349. get computeBoundingBox(): boolean;
  27350. /**
  27351. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27352. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27353. * Default : `true`
  27354. */
  27355. get depthSortParticles(): boolean;
  27356. /**
  27357. * Gets if the SPS is created as expandable at construction time.
  27358. * Default : `false`
  27359. */
  27360. get expandable(): boolean;
  27361. /**
  27362. * Gets if the SPS supports the Multi Materials
  27363. */
  27364. get multimaterialEnabled(): boolean;
  27365. /**
  27366. * Gets if the SPS uses the model materials for its own multimaterial.
  27367. */
  27368. get useModelMaterial(): boolean;
  27369. /**
  27370. * The SPS used material array.
  27371. */
  27372. get materials(): Material[];
  27373. /**
  27374. * Sets the SPS MultiMaterial from the passed materials.
  27375. * Note : the passed array is internally copied and not used then by reference.
  27376. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27377. */
  27378. setMultiMaterial(materials: Material[]): void;
  27379. /**
  27380. * The SPS computed multimaterial object
  27381. */
  27382. get multimaterial(): MultiMaterial;
  27383. set multimaterial(mm: MultiMaterial);
  27384. /**
  27385. * If the subMeshes must be updated on the next call to setParticles()
  27386. */
  27387. get autoUpdateSubMeshes(): boolean;
  27388. set autoUpdateSubMeshes(val: boolean);
  27389. /**
  27390. * This function does nothing. It may be overwritten to set all the particle first values.
  27391. * The SPS doesn't call this function, you may have to call it by your own.
  27392. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27393. */
  27394. initParticles(): void;
  27395. /**
  27396. * This function does nothing. It may be overwritten to recycle a particle.
  27397. * The SPS doesn't call this function, you may have to call it by your own.
  27398. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27399. * @param particle The particle to recycle
  27400. * @returns the recycled particle
  27401. */
  27402. recycleParticle(particle: SolidParticle): SolidParticle;
  27403. /**
  27404. * Updates a particle : this function should be overwritten by the user.
  27405. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27406. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27407. * @example : just set a particle position or velocity and recycle conditions
  27408. * @param particle The particle to update
  27409. * @returns the updated particle
  27410. */
  27411. updateParticle(particle: SolidParticle): SolidParticle;
  27412. /**
  27413. * Updates a vertex of a particle : it can be overwritten by the user.
  27414. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27415. * @param particle the current particle
  27416. * @param vertex the current index of the current particle
  27417. * @param pt the index of the current vertex in the particle shape
  27418. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27419. * @example : just set a vertex particle position
  27420. * @returns the updated vertex
  27421. */
  27422. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27423. /**
  27424. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27425. * This does nothing and may be overwritten by the user.
  27426. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27427. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27428. * @param update the boolean update value actually passed to setParticles()
  27429. */
  27430. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27431. /**
  27432. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27433. * This will be passed three parameters.
  27434. * This does nothing and may be overwritten by the user.
  27435. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27436. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27437. * @param update the boolean update value actually passed to setParticles()
  27438. */
  27439. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27440. }
  27441. }
  27442. declare module BABYLON {
  27443. /**
  27444. * Represents one particle of a solid particle system.
  27445. */
  27446. export class SolidParticle {
  27447. /**
  27448. * particle global index
  27449. */
  27450. idx: number;
  27451. /**
  27452. * particle identifier
  27453. */
  27454. id: number;
  27455. /**
  27456. * The color of the particle
  27457. */
  27458. color: Nullable<Color4>;
  27459. /**
  27460. * The world space position of the particle.
  27461. */
  27462. position: Vector3;
  27463. /**
  27464. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27465. */
  27466. rotation: Vector3;
  27467. /**
  27468. * The world space rotation quaternion of the particle.
  27469. */
  27470. rotationQuaternion: Nullable<Quaternion>;
  27471. /**
  27472. * The scaling of the particle.
  27473. */
  27474. scaling: Vector3;
  27475. /**
  27476. * The uvs of the particle.
  27477. */
  27478. uvs: Vector4;
  27479. /**
  27480. * The current speed of the particle.
  27481. */
  27482. velocity: Vector3;
  27483. /**
  27484. * The pivot point in the particle local space.
  27485. */
  27486. pivot: Vector3;
  27487. /**
  27488. * Must the particle be translated from its pivot point in its local space ?
  27489. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27490. * Default : false
  27491. */
  27492. translateFromPivot: boolean;
  27493. /**
  27494. * Is the particle active or not ?
  27495. */
  27496. alive: boolean;
  27497. /**
  27498. * Is the particle visible or not ?
  27499. */
  27500. isVisible: boolean;
  27501. /**
  27502. * Index of this particle in the global "positions" array (Internal use)
  27503. * @hidden
  27504. */
  27505. _pos: number;
  27506. /**
  27507. * @hidden Index of this particle in the global "indices" array (Internal use)
  27508. */
  27509. _ind: number;
  27510. /**
  27511. * @hidden ModelShape of this particle (Internal use)
  27512. */
  27513. _model: ModelShape;
  27514. /**
  27515. * ModelShape id of this particle
  27516. */
  27517. shapeId: number;
  27518. /**
  27519. * Index of the particle in its shape id
  27520. */
  27521. idxInShape: number;
  27522. /**
  27523. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27524. */
  27525. _modelBoundingInfo: BoundingInfo;
  27526. /**
  27527. * @hidden Particle BoundingInfo object (Internal use)
  27528. */
  27529. _boundingInfo: BoundingInfo;
  27530. /**
  27531. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27532. */
  27533. _sps: SolidParticleSystem;
  27534. /**
  27535. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27536. */
  27537. _stillInvisible: boolean;
  27538. /**
  27539. * @hidden Last computed particle rotation matrix
  27540. */
  27541. _rotationMatrix: number[];
  27542. /**
  27543. * Parent particle Id, if any.
  27544. * Default null.
  27545. */
  27546. parentId: Nullable<number>;
  27547. /**
  27548. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27549. */
  27550. materialIndex: Nullable<number>;
  27551. /**
  27552. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27553. * The possible values are :
  27554. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27555. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27557. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27558. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27559. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27560. * */
  27561. cullingStrategy: number;
  27562. /**
  27563. * @hidden Internal global position in the SPS.
  27564. */
  27565. _globalPosition: Vector3;
  27566. /**
  27567. * Creates a Solid Particle object.
  27568. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27569. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27570. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27571. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27572. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27573. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27574. * @param shapeId (integer) is the model shape identifier in the SPS.
  27575. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27576. * @param sps defines the sps it is associated to
  27577. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27578. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27579. */
  27580. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27581. /**
  27582. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27583. * @param target the particle target
  27584. * @returns the current particle
  27585. */
  27586. copyToRef(target: SolidParticle): SolidParticle;
  27587. /**
  27588. * Legacy support, changed scale to scaling
  27589. */
  27590. get scale(): Vector3;
  27591. /**
  27592. * Legacy support, changed scale to scaling
  27593. */
  27594. set scale(scale: Vector3);
  27595. /**
  27596. * Legacy support, changed quaternion to rotationQuaternion
  27597. */
  27598. get quaternion(): Nullable<Quaternion>;
  27599. /**
  27600. * Legacy support, changed quaternion to rotationQuaternion
  27601. */
  27602. set quaternion(q: Nullable<Quaternion>);
  27603. /**
  27604. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27605. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27606. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27607. * @returns true if it intersects
  27608. */
  27609. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27610. /**
  27611. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27612. * A particle is in the frustum if its bounding box intersects the frustum
  27613. * @param frustumPlanes defines the frustum to test
  27614. * @returns true if the particle is in the frustum planes
  27615. */
  27616. isInFrustum(frustumPlanes: Plane[]): boolean;
  27617. /**
  27618. * get the rotation matrix of the particle
  27619. * @hidden
  27620. */
  27621. getRotationMatrix(m: Matrix): void;
  27622. }
  27623. /**
  27624. * Represents the shape of the model used by one particle of a solid particle system.
  27625. * SPS internal tool, don't use it manually.
  27626. */
  27627. export class ModelShape {
  27628. /**
  27629. * The shape id
  27630. * @hidden
  27631. */
  27632. shapeID: number;
  27633. /**
  27634. * flat array of model positions (internal use)
  27635. * @hidden
  27636. */
  27637. _shape: Vector3[];
  27638. /**
  27639. * flat array of model UVs (internal use)
  27640. * @hidden
  27641. */
  27642. _shapeUV: number[];
  27643. /**
  27644. * color array of the model
  27645. * @hidden
  27646. */
  27647. _shapeColors: number[];
  27648. /**
  27649. * indices array of the model
  27650. * @hidden
  27651. */
  27652. _indices: number[];
  27653. /**
  27654. * normals array of the model
  27655. * @hidden
  27656. */
  27657. _normals: number[];
  27658. /**
  27659. * length of the shape in the model indices array (internal use)
  27660. * @hidden
  27661. */
  27662. _indicesLength: number;
  27663. /**
  27664. * Custom position function (internal use)
  27665. * @hidden
  27666. */
  27667. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27668. /**
  27669. * Custom vertex function (internal use)
  27670. * @hidden
  27671. */
  27672. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27673. /**
  27674. * Model material (internal use)
  27675. * @hidden
  27676. */
  27677. _material: Nullable<Material>;
  27678. /**
  27679. * 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.
  27680. * SPS internal tool, don't use it manually.
  27681. * @hidden
  27682. */
  27683. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  27684. }
  27685. /**
  27686. * Represents a Depth Sorted Particle in the solid particle system.
  27687. * @hidden
  27688. */
  27689. export class DepthSortedParticle {
  27690. /**
  27691. * Index of the particle in the "indices" array
  27692. */
  27693. ind: number;
  27694. /**
  27695. * Length of the particle shape in the "indices" array
  27696. */
  27697. indicesLength: number;
  27698. /**
  27699. * Squared distance from the particle to the camera
  27700. */
  27701. sqDistance: number;
  27702. /**
  27703. * Material index when used with MultiMaterials
  27704. */
  27705. materialIndex: number;
  27706. /**
  27707. * Creates a new sorted particle
  27708. * @param materialIndex
  27709. */
  27710. constructor(ind: number, indLength: number, materialIndex: number);
  27711. }
  27712. }
  27713. declare module BABYLON {
  27714. /**
  27715. * @hidden
  27716. */
  27717. export class _MeshCollisionData {
  27718. _checkCollisions: boolean;
  27719. _collisionMask: number;
  27720. _collisionGroup: number;
  27721. _collider: Nullable<Collider>;
  27722. _oldPositionForCollisions: Vector3;
  27723. _diffPositionForCollisions: Vector3;
  27724. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27725. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27726. }
  27727. }
  27728. declare module BABYLON {
  27729. /** @hidden */
  27730. class _FacetDataStorage {
  27731. facetPositions: Vector3[];
  27732. facetNormals: Vector3[];
  27733. facetPartitioning: number[][];
  27734. facetNb: number;
  27735. partitioningSubdivisions: number;
  27736. partitioningBBoxRatio: number;
  27737. facetDataEnabled: boolean;
  27738. facetParameters: any;
  27739. bbSize: Vector3;
  27740. subDiv: {
  27741. max: number;
  27742. X: number;
  27743. Y: number;
  27744. Z: number;
  27745. };
  27746. facetDepthSort: boolean;
  27747. facetDepthSortEnabled: boolean;
  27748. depthSortedIndices: IndicesArray;
  27749. depthSortedFacets: {
  27750. ind: number;
  27751. sqDistance: number;
  27752. }[];
  27753. facetDepthSortFunction: (f1: {
  27754. ind: number;
  27755. sqDistance: number;
  27756. }, f2: {
  27757. ind: number;
  27758. sqDistance: number;
  27759. }) => number;
  27760. facetDepthSortFrom: Vector3;
  27761. facetDepthSortOrigin: Vector3;
  27762. invertedMatrix: Matrix;
  27763. }
  27764. /**
  27765. * @hidden
  27766. **/
  27767. class _InternalAbstractMeshDataInfo {
  27768. _hasVertexAlpha: boolean;
  27769. _useVertexColors: boolean;
  27770. _numBoneInfluencers: number;
  27771. _applyFog: boolean;
  27772. _receiveShadows: boolean;
  27773. _facetData: _FacetDataStorage;
  27774. _visibility: number;
  27775. _skeleton: Nullable<Skeleton>;
  27776. _layerMask: number;
  27777. _computeBonesUsingShaders: boolean;
  27778. _isActive: boolean;
  27779. _onlyForInstances: boolean;
  27780. _isActiveIntermediate: boolean;
  27781. _onlyForInstancesIntermediate: boolean;
  27782. _actAsRegularMesh: boolean;
  27783. }
  27784. /**
  27785. * Class used to store all common mesh properties
  27786. */
  27787. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27788. /** No occlusion */
  27789. static OCCLUSION_TYPE_NONE: number;
  27790. /** Occlusion set to optimisitic */
  27791. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27792. /** Occlusion set to strict */
  27793. static OCCLUSION_TYPE_STRICT: number;
  27794. /** Use an accurante occlusion algorithm */
  27795. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27796. /** Use a conservative occlusion algorithm */
  27797. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27798. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27799. * Test order :
  27800. * Is the bounding sphere outside the frustum ?
  27801. * If not, are the bounding box vertices outside the frustum ?
  27802. * It not, then the cullable object is in the frustum.
  27803. */
  27804. static readonly CULLINGSTRATEGY_STANDARD: number;
  27805. /** Culling strategy : Bounding Sphere Only.
  27806. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27807. * It's also less accurate than the standard because some not visible objects can still be selected.
  27808. * Test : is the bounding sphere outside the frustum ?
  27809. * If not, then the cullable object is in the frustum.
  27810. */
  27811. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27812. /** Culling strategy : Optimistic Inclusion.
  27813. * This in an inclusion test first, then the standard exclusion test.
  27814. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27815. * 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.
  27816. * Anyway, it's as accurate as the standard strategy.
  27817. * Test :
  27818. * Is the cullable object bounding sphere center in the frustum ?
  27819. * If not, apply the default culling strategy.
  27820. */
  27821. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27822. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27823. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27824. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27825. * 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.
  27826. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27827. * Test :
  27828. * Is the cullable object bounding sphere center in the frustum ?
  27829. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27830. */
  27831. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27832. /**
  27833. * No billboard
  27834. */
  27835. static get BILLBOARDMODE_NONE(): number;
  27836. /** Billboard on X axis */
  27837. static get BILLBOARDMODE_X(): number;
  27838. /** Billboard on Y axis */
  27839. static get BILLBOARDMODE_Y(): number;
  27840. /** Billboard on Z axis */
  27841. static get BILLBOARDMODE_Z(): number;
  27842. /** Billboard on all axes */
  27843. static get BILLBOARDMODE_ALL(): number;
  27844. /** Billboard on using position instead of orientation */
  27845. static get BILLBOARDMODE_USE_POSITION(): number;
  27846. /** @hidden */
  27847. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27848. /**
  27849. * The culling strategy to use to check whether the mesh must be rendered or not.
  27850. * This value can be changed at any time and will be used on the next render mesh selection.
  27851. * The possible values are :
  27852. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27853. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27854. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27855. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27856. * Please read each static variable documentation to get details about the culling process.
  27857. * */
  27858. cullingStrategy: number;
  27859. /**
  27860. * Gets the number of facets in the mesh
  27861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27862. */
  27863. get facetNb(): number;
  27864. /**
  27865. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27866. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27867. */
  27868. get partitioningSubdivisions(): number;
  27869. set partitioningSubdivisions(nb: number);
  27870. /**
  27871. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27872. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27874. */
  27875. get partitioningBBoxRatio(): number;
  27876. set partitioningBBoxRatio(ratio: number);
  27877. /**
  27878. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27879. * Works only for updatable meshes.
  27880. * Doesn't work with multi-materials
  27881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27882. */
  27883. get mustDepthSortFacets(): boolean;
  27884. set mustDepthSortFacets(sort: boolean);
  27885. /**
  27886. * The location (Vector3) where the facet depth sort must be computed from.
  27887. * By default, the active camera position.
  27888. * Used only when facet depth sort is enabled
  27889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27890. */
  27891. get facetDepthSortFrom(): Vector3;
  27892. set facetDepthSortFrom(location: Vector3);
  27893. /**
  27894. * gets a boolean indicating if facetData is enabled
  27895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27896. */
  27897. get isFacetDataEnabled(): boolean;
  27898. /** @hidden */
  27899. _updateNonUniformScalingState(value: boolean): boolean;
  27900. /**
  27901. * An event triggered when this mesh collides with another one
  27902. */
  27903. onCollideObservable: Observable<AbstractMesh>;
  27904. /** Set a function to call when this mesh collides with another one */
  27905. set onCollide(callback: () => void);
  27906. /**
  27907. * An event triggered when the collision's position changes
  27908. */
  27909. onCollisionPositionChangeObservable: Observable<Vector3>;
  27910. /** Set a function to call when the collision's position changes */
  27911. set onCollisionPositionChange(callback: () => void);
  27912. /**
  27913. * An event triggered when material is changed
  27914. */
  27915. onMaterialChangedObservable: Observable<AbstractMesh>;
  27916. /**
  27917. * Gets or sets the orientation for POV movement & rotation
  27918. */
  27919. definedFacingForward: boolean;
  27920. /** @hidden */
  27921. _occlusionQuery: Nullable<WebGLQuery>;
  27922. /** @hidden */
  27923. _renderingGroup: Nullable<RenderingGroup>;
  27924. /**
  27925. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27926. */
  27927. get visibility(): number;
  27928. /**
  27929. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27930. */
  27931. set visibility(value: number);
  27932. /** Gets or sets the alpha index used to sort transparent meshes
  27933. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27934. */
  27935. alphaIndex: number;
  27936. /**
  27937. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27938. */
  27939. isVisible: boolean;
  27940. /**
  27941. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27942. */
  27943. isPickable: boolean;
  27944. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27945. showSubMeshesBoundingBox: boolean;
  27946. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27947. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27948. */
  27949. isBlocker: boolean;
  27950. /**
  27951. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27952. */
  27953. enablePointerMoveEvents: boolean;
  27954. /**
  27955. * Specifies the rendering group id for this mesh (0 by default)
  27956. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27957. */
  27958. renderingGroupId: number;
  27959. private _material;
  27960. /** Gets or sets current material */
  27961. get material(): Nullable<Material>;
  27962. set material(value: Nullable<Material>);
  27963. /**
  27964. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27965. * @see http://doc.babylonjs.com/babylon101/shadows
  27966. */
  27967. get receiveShadows(): boolean;
  27968. set receiveShadows(value: boolean);
  27969. /** Defines color to use when rendering outline */
  27970. outlineColor: Color3;
  27971. /** Define width to use when rendering outline */
  27972. outlineWidth: number;
  27973. /** Defines color to use when rendering overlay */
  27974. overlayColor: Color3;
  27975. /** Defines alpha to use when rendering overlay */
  27976. overlayAlpha: number;
  27977. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27978. get hasVertexAlpha(): boolean;
  27979. set hasVertexAlpha(value: boolean);
  27980. /** 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) */
  27981. get useVertexColors(): boolean;
  27982. set useVertexColors(value: boolean);
  27983. /**
  27984. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27985. */
  27986. get computeBonesUsingShaders(): boolean;
  27987. set computeBonesUsingShaders(value: boolean);
  27988. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27989. get numBoneInfluencers(): number;
  27990. set numBoneInfluencers(value: number);
  27991. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27992. get applyFog(): boolean;
  27993. set applyFog(value: boolean);
  27994. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27995. useOctreeForRenderingSelection: boolean;
  27996. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27997. useOctreeForPicking: boolean;
  27998. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27999. useOctreeForCollisions: boolean;
  28000. /**
  28001. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28002. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28003. */
  28004. get layerMask(): number;
  28005. set layerMask(value: number);
  28006. /**
  28007. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28008. */
  28009. alwaysSelectAsActiveMesh: boolean;
  28010. /**
  28011. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28012. */
  28013. doNotSyncBoundingInfo: boolean;
  28014. /**
  28015. * Gets or sets the current action manager
  28016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28017. */
  28018. actionManager: Nullable<AbstractActionManager>;
  28019. private _meshCollisionData;
  28020. /**
  28021. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28022. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28023. */
  28024. ellipsoid: Vector3;
  28025. /**
  28026. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28027. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28028. */
  28029. ellipsoidOffset: Vector3;
  28030. /**
  28031. * Gets or sets a collision mask used to mask collisions (default is -1).
  28032. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28033. */
  28034. get collisionMask(): number;
  28035. set collisionMask(mask: number);
  28036. /**
  28037. * Gets or sets the current collision group mask (-1 by default).
  28038. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28039. */
  28040. get collisionGroup(): number;
  28041. set collisionGroup(mask: number);
  28042. /**
  28043. * Defines edge width used when edgesRenderer is enabled
  28044. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28045. */
  28046. edgesWidth: number;
  28047. /**
  28048. * Defines edge color used when edgesRenderer is enabled
  28049. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28050. */
  28051. edgesColor: Color4;
  28052. /** @hidden */
  28053. _edgesRenderer: Nullable<IEdgesRenderer>;
  28054. /** @hidden */
  28055. _masterMesh: Nullable<AbstractMesh>;
  28056. /** @hidden */
  28057. _boundingInfo: Nullable<BoundingInfo>;
  28058. /** @hidden */
  28059. _renderId: number;
  28060. /**
  28061. * Gets or sets the list of subMeshes
  28062. * @see http://doc.babylonjs.com/how_to/multi_materials
  28063. */
  28064. subMeshes: SubMesh[];
  28065. /** @hidden */
  28066. _intersectionsInProgress: AbstractMesh[];
  28067. /** @hidden */
  28068. _unIndexed: boolean;
  28069. /** @hidden */
  28070. _lightSources: Light[];
  28071. /** Gets the list of lights affecting that mesh */
  28072. get lightSources(): Light[];
  28073. /** @hidden */
  28074. get _positions(): Nullable<Vector3[]>;
  28075. /** @hidden */
  28076. _waitingData: {
  28077. lods: Nullable<any>;
  28078. actions: Nullable<any>;
  28079. freezeWorldMatrix: Nullable<boolean>;
  28080. };
  28081. /** @hidden */
  28082. _bonesTransformMatrices: Nullable<Float32Array>;
  28083. /** @hidden */
  28084. _transformMatrixTexture: Nullable<RawTexture>;
  28085. /**
  28086. * Gets or sets a skeleton to apply skining transformations
  28087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28088. */
  28089. set skeleton(value: Nullable<Skeleton>);
  28090. get skeleton(): Nullable<Skeleton>;
  28091. /**
  28092. * An event triggered when the mesh is rebuilt.
  28093. */
  28094. onRebuildObservable: Observable<AbstractMesh>;
  28095. /**
  28096. * Creates a new AbstractMesh
  28097. * @param name defines the name of the mesh
  28098. * @param scene defines the hosting scene
  28099. */
  28100. constructor(name: string, scene?: Nullable<Scene>);
  28101. /**
  28102. * Returns the string "AbstractMesh"
  28103. * @returns "AbstractMesh"
  28104. */
  28105. getClassName(): string;
  28106. /**
  28107. * Gets a string representation of the current mesh
  28108. * @param fullDetails defines a boolean indicating if full details must be included
  28109. * @returns a string representation of the current mesh
  28110. */
  28111. toString(fullDetails?: boolean): string;
  28112. /**
  28113. * @hidden
  28114. */
  28115. protected _getEffectiveParent(): Nullable<Node>;
  28116. /** @hidden */
  28117. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28118. /** @hidden */
  28119. _rebuild(): void;
  28120. /** @hidden */
  28121. _resyncLightSources(): void;
  28122. /** @hidden */
  28123. _resyncLightSource(light: Light): void;
  28124. /** @hidden */
  28125. _unBindEffect(): void;
  28126. /** @hidden */
  28127. _removeLightSource(light: Light, dispose: boolean): void;
  28128. private _markSubMeshesAsDirty;
  28129. /** @hidden */
  28130. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28131. /** @hidden */
  28132. _markSubMeshesAsAttributesDirty(): void;
  28133. /** @hidden */
  28134. _markSubMeshesAsMiscDirty(): void;
  28135. /**
  28136. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28137. */
  28138. get scaling(): Vector3;
  28139. set scaling(newScaling: Vector3);
  28140. /**
  28141. * Returns true if the mesh is blocked. Implemented by child classes
  28142. */
  28143. get isBlocked(): boolean;
  28144. /**
  28145. * Returns the mesh itself by default. Implemented by child classes
  28146. * @param camera defines the camera to use to pick the right LOD level
  28147. * @returns the currentAbstractMesh
  28148. */
  28149. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28150. /**
  28151. * Returns 0 by default. Implemented by child classes
  28152. * @returns an integer
  28153. */
  28154. getTotalVertices(): number;
  28155. /**
  28156. * Returns a positive integer : the total number of indices in this mesh geometry.
  28157. * @returns the numner of indices or zero if the mesh has no geometry.
  28158. */
  28159. getTotalIndices(): number;
  28160. /**
  28161. * Returns null by default. Implemented by child classes
  28162. * @returns null
  28163. */
  28164. getIndices(): Nullable<IndicesArray>;
  28165. /**
  28166. * Returns the array of the requested vertex data kind. Implemented by child classes
  28167. * @param kind defines the vertex data kind to use
  28168. * @returns null
  28169. */
  28170. getVerticesData(kind: string): Nullable<FloatArray>;
  28171. /**
  28172. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28173. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28174. * Note that a new underlying VertexBuffer object is created each call.
  28175. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28176. * @param kind defines vertex data kind:
  28177. * * VertexBuffer.PositionKind
  28178. * * VertexBuffer.UVKind
  28179. * * VertexBuffer.UV2Kind
  28180. * * VertexBuffer.UV3Kind
  28181. * * VertexBuffer.UV4Kind
  28182. * * VertexBuffer.UV5Kind
  28183. * * VertexBuffer.UV6Kind
  28184. * * VertexBuffer.ColorKind
  28185. * * VertexBuffer.MatricesIndicesKind
  28186. * * VertexBuffer.MatricesIndicesExtraKind
  28187. * * VertexBuffer.MatricesWeightsKind
  28188. * * VertexBuffer.MatricesWeightsExtraKind
  28189. * @param data defines the data source
  28190. * @param updatable defines if the data must be flagged as updatable (or static)
  28191. * @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
  28192. * @returns the current mesh
  28193. */
  28194. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28195. /**
  28196. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28197. * If the mesh has no geometry, it is simply returned as it is.
  28198. * @param kind defines vertex data kind:
  28199. * * VertexBuffer.PositionKind
  28200. * * VertexBuffer.UVKind
  28201. * * VertexBuffer.UV2Kind
  28202. * * VertexBuffer.UV3Kind
  28203. * * VertexBuffer.UV4Kind
  28204. * * VertexBuffer.UV5Kind
  28205. * * VertexBuffer.UV6Kind
  28206. * * VertexBuffer.ColorKind
  28207. * * VertexBuffer.MatricesIndicesKind
  28208. * * VertexBuffer.MatricesIndicesExtraKind
  28209. * * VertexBuffer.MatricesWeightsKind
  28210. * * VertexBuffer.MatricesWeightsExtraKind
  28211. * @param data defines the data source
  28212. * @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
  28213. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28214. * @returns the current mesh
  28215. */
  28216. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28217. /**
  28218. * Sets the mesh indices,
  28219. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28220. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28221. * @param totalVertices Defines the total number of vertices
  28222. * @returns the current mesh
  28223. */
  28224. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28225. /**
  28226. * Gets a boolean indicating if specific vertex data is present
  28227. * @param kind defines the vertex data kind to use
  28228. * @returns true is data kind is present
  28229. */
  28230. isVerticesDataPresent(kind: string): boolean;
  28231. /**
  28232. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28233. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28234. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28235. * @returns a BoundingInfo
  28236. */
  28237. getBoundingInfo(): BoundingInfo;
  28238. /**
  28239. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28240. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28241. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28242. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28243. * @returns the current mesh
  28244. */
  28245. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28246. /**
  28247. * Overwrite the current bounding info
  28248. * @param boundingInfo defines the new bounding info
  28249. * @returns the current mesh
  28250. */
  28251. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28252. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28253. get useBones(): boolean;
  28254. /** @hidden */
  28255. _preActivate(): void;
  28256. /** @hidden */
  28257. _preActivateForIntermediateRendering(renderId: number): void;
  28258. /** @hidden */
  28259. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28260. /** @hidden */
  28261. _postActivate(): void;
  28262. /** @hidden */
  28263. _freeze(): void;
  28264. /** @hidden */
  28265. _unFreeze(): void;
  28266. /**
  28267. * Gets the current world matrix
  28268. * @returns a Matrix
  28269. */
  28270. getWorldMatrix(): Matrix;
  28271. /** @hidden */
  28272. _getWorldMatrixDeterminant(): number;
  28273. /**
  28274. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28275. */
  28276. get isAnInstance(): boolean;
  28277. /**
  28278. * Gets a boolean indicating if this mesh has instances
  28279. */
  28280. get hasInstances(): boolean;
  28281. /**
  28282. * Perform relative position change from the point of view of behind the front of the mesh.
  28283. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28284. * Supports definition of mesh facing forward or backward
  28285. * @param amountRight defines the distance on the right axis
  28286. * @param amountUp defines the distance on the up axis
  28287. * @param amountForward defines the distance on the forward axis
  28288. * @returns the current mesh
  28289. */
  28290. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28291. /**
  28292. * Calculate relative position change from the point of view of behind the front of the mesh.
  28293. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28294. * Supports definition of mesh facing forward or backward
  28295. * @param amountRight defines the distance on the right axis
  28296. * @param amountUp defines the distance on the up axis
  28297. * @param amountForward defines the distance on the forward axis
  28298. * @returns the new displacement vector
  28299. */
  28300. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28301. /**
  28302. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28303. * Supports definition of mesh facing forward or backward
  28304. * @param flipBack defines the flip
  28305. * @param twirlClockwise defines the twirl
  28306. * @param tiltRight defines the tilt
  28307. * @returns the current mesh
  28308. */
  28309. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28310. /**
  28311. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28312. * Supports definition of mesh facing forward or backward.
  28313. * @param flipBack defines the flip
  28314. * @param twirlClockwise defines the twirl
  28315. * @param tiltRight defines the tilt
  28316. * @returns the new rotation vector
  28317. */
  28318. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28319. /**
  28320. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28321. * This means the mesh underlying bounding box and sphere are recomputed.
  28322. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28323. * @returns the current mesh
  28324. */
  28325. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28326. /** @hidden */
  28327. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28328. /** @hidden */
  28329. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28330. /** @hidden */
  28331. _updateBoundingInfo(): AbstractMesh;
  28332. /** @hidden */
  28333. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28334. /** @hidden */
  28335. protected _afterComputeWorldMatrix(): void;
  28336. /** @hidden */
  28337. get _effectiveMesh(): AbstractMesh;
  28338. /**
  28339. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28340. * A mesh is in the frustum if its bounding box intersects the frustum
  28341. * @param frustumPlanes defines the frustum to test
  28342. * @returns true if the mesh is in the frustum planes
  28343. */
  28344. isInFrustum(frustumPlanes: Plane[]): boolean;
  28345. /**
  28346. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28347. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28348. * @param frustumPlanes defines the frustum to test
  28349. * @returns true if the mesh is completely in the frustum planes
  28350. */
  28351. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28352. /**
  28353. * True if the mesh intersects another mesh or a SolidParticle object
  28354. * @param mesh defines a target mesh or SolidParticle to test
  28355. * @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)
  28356. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28357. * @returns true if there is an intersection
  28358. */
  28359. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28360. /**
  28361. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28362. * @param point defines the point to test
  28363. * @returns true if there is an intersection
  28364. */
  28365. intersectsPoint(point: Vector3): boolean;
  28366. /**
  28367. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28369. */
  28370. get checkCollisions(): boolean;
  28371. set checkCollisions(collisionEnabled: boolean);
  28372. /**
  28373. * Gets Collider object used to compute collisions (not physics)
  28374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28375. */
  28376. get collider(): Nullable<Collider>;
  28377. /**
  28378. * Move the mesh using collision engine
  28379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28380. * @param displacement defines the requested displacement vector
  28381. * @returns the current mesh
  28382. */
  28383. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28384. private _onCollisionPositionChange;
  28385. /** @hidden */
  28386. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28387. /** @hidden */
  28388. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28389. /** @hidden */
  28390. _checkCollision(collider: Collider): AbstractMesh;
  28391. /** @hidden */
  28392. _generatePointsArray(): boolean;
  28393. /**
  28394. * Checks if the passed Ray intersects with the mesh
  28395. * @param ray defines the ray to use
  28396. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28397. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28398. * @returns the picking info
  28399. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28400. */
  28401. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28402. /**
  28403. * Clones the current mesh
  28404. * @param name defines the mesh name
  28405. * @param newParent defines the new mesh parent
  28406. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28407. * @returns the new mesh
  28408. */
  28409. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28410. /**
  28411. * Disposes all the submeshes of the current meshnp
  28412. * @returns the current mesh
  28413. */
  28414. releaseSubMeshes(): AbstractMesh;
  28415. /**
  28416. * Releases resources associated with this abstract mesh.
  28417. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28418. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28419. */
  28420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28421. /**
  28422. * Adds the passed mesh as a child to the current mesh
  28423. * @param mesh defines the child mesh
  28424. * @returns the current mesh
  28425. */
  28426. addChild(mesh: AbstractMesh): AbstractMesh;
  28427. /**
  28428. * Removes the passed mesh from the current mesh children list
  28429. * @param mesh defines the child mesh
  28430. * @returns the current mesh
  28431. */
  28432. removeChild(mesh: AbstractMesh): AbstractMesh;
  28433. /** @hidden */
  28434. private _initFacetData;
  28435. /**
  28436. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28437. * This method can be called within the render loop.
  28438. * 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
  28439. * @returns the current mesh
  28440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28441. */
  28442. updateFacetData(): AbstractMesh;
  28443. /**
  28444. * Returns the facetLocalNormals array.
  28445. * The normals are expressed in the mesh local spac
  28446. * @returns an array of Vector3
  28447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28448. */
  28449. getFacetLocalNormals(): Vector3[];
  28450. /**
  28451. * Returns the facetLocalPositions array.
  28452. * The facet positions are expressed in the mesh local space
  28453. * @returns an array of Vector3
  28454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28455. */
  28456. getFacetLocalPositions(): Vector3[];
  28457. /**
  28458. * Returns the facetLocalPartioning array
  28459. * @returns an array of array of numbers
  28460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28461. */
  28462. getFacetLocalPartitioning(): number[][];
  28463. /**
  28464. * Returns the i-th facet position in the world system.
  28465. * This method allocates a new Vector3 per call
  28466. * @param i defines the facet index
  28467. * @returns a new Vector3
  28468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28469. */
  28470. getFacetPosition(i: number): Vector3;
  28471. /**
  28472. * Sets the reference Vector3 with the i-th facet position in the world system
  28473. * @param i defines the facet index
  28474. * @param ref defines the target vector
  28475. * @returns the current mesh
  28476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28477. */
  28478. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28479. /**
  28480. * Returns the i-th facet normal in the world system.
  28481. * This method allocates a new Vector3 per call
  28482. * @param i defines the facet index
  28483. * @returns a new Vector3
  28484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28485. */
  28486. getFacetNormal(i: number): Vector3;
  28487. /**
  28488. * Sets the reference Vector3 with the i-th facet normal in the world system
  28489. * @param i defines the facet index
  28490. * @param ref defines the target vector
  28491. * @returns the current mesh
  28492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28493. */
  28494. getFacetNormalToRef(i: number, ref: Vector3): this;
  28495. /**
  28496. * 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)
  28497. * @param x defines x coordinate
  28498. * @param y defines y coordinate
  28499. * @param z defines z coordinate
  28500. * @returns the array of facet indexes
  28501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28502. */
  28503. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28504. /**
  28505. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28506. * @param projected sets as the (x,y,z) world projection on the facet
  28507. * @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
  28508. * @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
  28509. * @param x defines x coordinate
  28510. * @param y defines y coordinate
  28511. * @param z defines z coordinate
  28512. * @returns the face index if found (or null instead)
  28513. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28514. */
  28515. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28516. /**
  28517. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28518. * @param projected sets as the (x,y,z) local projection on the facet
  28519. * @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
  28520. * @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
  28521. * @param x defines x coordinate
  28522. * @param y defines y coordinate
  28523. * @param z defines z coordinate
  28524. * @returns the face index if found (or null instead)
  28525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28526. */
  28527. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28528. /**
  28529. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28530. * @returns the parameters
  28531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28532. */
  28533. getFacetDataParameters(): any;
  28534. /**
  28535. * Disables the feature FacetData and frees the related memory
  28536. * @returns the current mesh
  28537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28538. */
  28539. disableFacetData(): AbstractMesh;
  28540. /**
  28541. * Updates the AbstractMesh indices array
  28542. * @param indices defines the data source
  28543. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28544. * @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)
  28545. * @returns the current mesh
  28546. */
  28547. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28548. /**
  28549. * Creates new normals data for the mesh
  28550. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28551. * @returns the current mesh
  28552. */
  28553. createNormals(updatable: boolean): AbstractMesh;
  28554. /**
  28555. * Align the mesh with a normal
  28556. * @param normal defines the normal to use
  28557. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28558. * @returns the current mesh
  28559. */
  28560. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28561. /** @hidden */
  28562. _checkOcclusionQuery(): boolean;
  28563. /**
  28564. * Disables the mesh edge rendering mode
  28565. * @returns the currentAbstractMesh
  28566. */
  28567. disableEdgesRendering(): AbstractMesh;
  28568. /**
  28569. * Enables the edge rendering mode on the mesh.
  28570. * This mode makes the mesh edges visible
  28571. * @param epsilon defines the maximal distance between two angles to detect a face
  28572. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28573. * @returns the currentAbstractMesh
  28574. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28575. */
  28576. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28577. }
  28578. }
  28579. declare module BABYLON {
  28580. /**
  28581. * Interface used to define ActionEvent
  28582. */
  28583. export interface IActionEvent {
  28584. /** The mesh or sprite that triggered the action */
  28585. source: any;
  28586. /** The X mouse cursor position at the time of the event */
  28587. pointerX: number;
  28588. /** The Y mouse cursor position at the time of the event */
  28589. pointerY: number;
  28590. /** The mesh that is currently pointed at (can be null) */
  28591. meshUnderPointer: Nullable<AbstractMesh>;
  28592. /** the original (browser) event that triggered the ActionEvent */
  28593. sourceEvent?: any;
  28594. /** additional data for the event */
  28595. additionalData?: any;
  28596. }
  28597. /**
  28598. * ActionEvent is the event being sent when an action is triggered.
  28599. */
  28600. export class ActionEvent implements IActionEvent {
  28601. /** The mesh or sprite that triggered the action */
  28602. source: any;
  28603. /** The X mouse cursor position at the time of the event */
  28604. pointerX: number;
  28605. /** The Y mouse cursor position at the time of the event */
  28606. pointerY: number;
  28607. /** The mesh that is currently pointed at (can be null) */
  28608. meshUnderPointer: Nullable<AbstractMesh>;
  28609. /** the original (browser) event that triggered the ActionEvent */
  28610. sourceEvent?: any;
  28611. /** additional data for the event */
  28612. additionalData?: any;
  28613. /**
  28614. * Creates a new ActionEvent
  28615. * @param source The mesh or sprite that triggered the action
  28616. * @param pointerX The X mouse cursor position at the time of the event
  28617. * @param pointerY The Y mouse cursor position at the time of the event
  28618. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28619. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28620. * @param additionalData additional data for the event
  28621. */
  28622. constructor(
  28623. /** The mesh or sprite that triggered the action */
  28624. source: any,
  28625. /** The X mouse cursor position at the time of the event */
  28626. pointerX: number,
  28627. /** The Y mouse cursor position at the time of the event */
  28628. pointerY: number,
  28629. /** The mesh that is currently pointed at (can be null) */
  28630. meshUnderPointer: Nullable<AbstractMesh>,
  28631. /** the original (browser) event that triggered the ActionEvent */
  28632. sourceEvent?: any,
  28633. /** additional data for the event */
  28634. additionalData?: any);
  28635. /**
  28636. * Helper function to auto-create an ActionEvent from a source mesh.
  28637. * @param source The source mesh that triggered the event
  28638. * @param evt The original (browser) event
  28639. * @param additionalData additional data for the event
  28640. * @returns the new ActionEvent
  28641. */
  28642. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28643. /**
  28644. * Helper function to auto-create an ActionEvent from a source sprite
  28645. * @param source The source sprite that triggered the event
  28646. * @param scene Scene associated with the sprite
  28647. * @param evt The original (browser) event
  28648. * @param additionalData additional data for the event
  28649. * @returns the new ActionEvent
  28650. */
  28651. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28652. /**
  28653. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28654. * @param scene the scene where the event occurred
  28655. * @param evt The original (browser) event
  28656. * @returns the new ActionEvent
  28657. */
  28658. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28659. /**
  28660. * Helper function to auto-create an ActionEvent from a primitive
  28661. * @param prim defines the target primitive
  28662. * @param pointerPos defines the pointer position
  28663. * @param evt The original (browser) event
  28664. * @param additionalData additional data for the event
  28665. * @returns the new ActionEvent
  28666. */
  28667. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28668. }
  28669. }
  28670. declare module BABYLON {
  28671. /**
  28672. * Abstract class used to decouple action Manager from scene and meshes.
  28673. * Do not instantiate.
  28674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28675. */
  28676. export abstract class AbstractActionManager implements IDisposable {
  28677. /** Gets the list of active triggers */
  28678. static Triggers: {
  28679. [key: string]: number;
  28680. };
  28681. /** Gets the cursor to use when hovering items */
  28682. hoverCursor: string;
  28683. /** Gets the list of actions */
  28684. actions: IAction[];
  28685. /**
  28686. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28687. */
  28688. isRecursive: boolean;
  28689. /**
  28690. * Releases all associated resources
  28691. */
  28692. abstract dispose(): void;
  28693. /**
  28694. * Does this action manager has pointer triggers
  28695. */
  28696. abstract get hasPointerTriggers(): boolean;
  28697. /**
  28698. * Does this action manager has pick triggers
  28699. */
  28700. abstract get hasPickTriggers(): boolean;
  28701. /**
  28702. * Process a specific trigger
  28703. * @param trigger defines the trigger to process
  28704. * @param evt defines the event details to be processed
  28705. */
  28706. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28707. /**
  28708. * Does this action manager handles actions of any of the given triggers
  28709. * @param triggers defines the triggers to be tested
  28710. * @return a boolean indicating whether one (or more) of the triggers is handled
  28711. */
  28712. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28713. /**
  28714. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28715. * speed.
  28716. * @param triggerA defines the trigger to be tested
  28717. * @param triggerB defines the trigger to be tested
  28718. * @return a boolean indicating whether one (or more) of the triggers is handled
  28719. */
  28720. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28721. /**
  28722. * Does this action manager handles actions of a given trigger
  28723. * @param trigger defines the trigger to be tested
  28724. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28725. * @return whether the trigger is handled
  28726. */
  28727. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28728. /**
  28729. * Serialize this manager to a JSON object
  28730. * @param name defines the property name to store this manager
  28731. * @returns a JSON representation of this manager
  28732. */
  28733. abstract serialize(name: string): any;
  28734. /**
  28735. * Registers an action to this action manager
  28736. * @param action defines the action to be registered
  28737. * @return the action amended (prepared) after registration
  28738. */
  28739. abstract registerAction(action: IAction): Nullable<IAction>;
  28740. /**
  28741. * Unregisters an action to this action manager
  28742. * @param action defines the action to be unregistered
  28743. * @return a boolean indicating whether the action has been unregistered
  28744. */
  28745. abstract unregisterAction(action: IAction): Boolean;
  28746. /**
  28747. * Does exist one action manager with at least one trigger
  28748. **/
  28749. static get HasTriggers(): boolean;
  28750. /**
  28751. * Does exist one action manager with at least one pick trigger
  28752. **/
  28753. static get HasPickTriggers(): boolean;
  28754. /**
  28755. * Does exist one action manager that handles actions of a given trigger
  28756. * @param trigger defines the trigger to be tested
  28757. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28758. **/
  28759. static HasSpecificTrigger(trigger: number): boolean;
  28760. }
  28761. }
  28762. declare module BABYLON {
  28763. /**
  28764. * Defines how a node can be built from a string name.
  28765. */
  28766. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28767. /**
  28768. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28769. */
  28770. export class Node implements IBehaviorAware<Node> {
  28771. /** @hidden */
  28772. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28773. private static _NodeConstructors;
  28774. /**
  28775. * Add a new node constructor
  28776. * @param type defines the type name of the node to construct
  28777. * @param constructorFunc defines the constructor function
  28778. */
  28779. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28780. /**
  28781. * Returns a node constructor based on type name
  28782. * @param type defines the type name
  28783. * @param name defines the new node name
  28784. * @param scene defines the hosting scene
  28785. * @param options defines optional options to transmit to constructors
  28786. * @returns the new constructor or null
  28787. */
  28788. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28789. /**
  28790. * Gets or sets the name of the node
  28791. */
  28792. name: string;
  28793. /**
  28794. * Gets or sets the id of the node
  28795. */
  28796. id: string;
  28797. /**
  28798. * Gets or sets the unique id of the node
  28799. */
  28800. uniqueId: number;
  28801. /**
  28802. * Gets or sets a string used to store user defined state for the node
  28803. */
  28804. state: string;
  28805. /**
  28806. * Gets or sets an object used to store user defined information for the node
  28807. */
  28808. metadata: any;
  28809. /**
  28810. * For internal use only. Please do not use.
  28811. */
  28812. reservedDataStore: any;
  28813. /**
  28814. * List of inspectable custom properties (used by the Inspector)
  28815. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28816. */
  28817. inspectableCustomProperties: IInspectable[];
  28818. private _doNotSerialize;
  28819. /**
  28820. * Gets or sets a boolean used to define if the node must be serialized
  28821. */
  28822. get doNotSerialize(): boolean;
  28823. set doNotSerialize(value: boolean);
  28824. /** @hidden */
  28825. _isDisposed: boolean;
  28826. /**
  28827. * Gets a list of Animations associated with the node
  28828. */
  28829. animations: Animation[];
  28830. protected _ranges: {
  28831. [name: string]: Nullable<AnimationRange>;
  28832. };
  28833. /**
  28834. * Callback raised when the node is ready to be used
  28835. */
  28836. onReady: Nullable<(node: Node) => void>;
  28837. private _isEnabled;
  28838. private _isParentEnabled;
  28839. private _isReady;
  28840. /** @hidden */
  28841. _currentRenderId: number;
  28842. private _parentUpdateId;
  28843. /** @hidden */
  28844. _childUpdateId: number;
  28845. /** @hidden */
  28846. _waitingParentId: Nullable<string>;
  28847. /** @hidden */
  28848. _scene: Scene;
  28849. /** @hidden */
  28850. _cache: any;
  28851. private _parentNode;
  28852. private _children;
  28853. /** @hidden */
  28854. _worldMatrix: Matrix;
  28855. /** @hidden */
  28856. _worldMatrixDeterminant: number;
  28857. /** @hidden */
  28858. _worldMatrixDeterminantIsDirty: boolean;
  28859. /** @hidden */
  28860. private _sceneRootNodesIndex;
  28861. /**
  28862. * Gets a boolean indicating if the node has been disposed
  28863. * @returns true if the node was disposed
  28864. */
  28865. isDisposed(): boolean;
  28866. /**
  28867. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28868. * @see https://doc.babylonjs.com/how_to/parenting
  28869. */
  28870. set parent(parent: Nullable<Node>);
  28871. get parent(): Nullable<Node>;
  28872. /** @hidden */
  28873. _addToSceneRootNodes(): void;
  28874. /** @hidden */
  28875. _removeFromSceneRootNodes(): void;
  28876. private _animationPropertiesOverride;
  28877. /**
  28878. * Gets or sets the animation properties override
  28879. */
  28880. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28881. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28882. /**
  28883. * Gets a string idenfifying the name of the class
  28884. * @returns "Node" string
  28885. */
  28886. getClassName(): string;
  28887. /** @hidden */
  28888. readonly _isNode: boolean;
  28889. /**
  28890. * An event triggered when the mesh is disposed
  28891. */
  28892. onDisposeObservable: Observable<Node>;
  28893. private _onDisposeObserver;
  28894. /**
  28895. * Sets a callback that will be raised when the node will be disposed
  28896. */
  28897. set onDispose(callback: () => void);
  28898. /**
  28899. * Creates a new Node
  28900. * @param name the name and id to be given to this node
  28901. * @param scene the scene this node will be added to
  28902. */
  28903. constructor(name: string, scene?: Nullable<Scene>);
  28904. /**
  28905. * Gets the scene of the node
  28906. * @returns a scene
  28907. */
  28908. getScene(): Scene;
  28909. /**
  28910. * Gets the engine of the node
  28911. * @returns a Engine
  28912. */
  28913. getEngine(): Engine;
  28914. private _behaviors;
  28915. /**
  28916. * Attach a behavior to the node
  28917. * @see http://doc.babylonjs.com/features/behaviour
  28918. * @param behavior defines the behavior to attach
  28919. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28920. * @returns the current Node
  28921. */
  28922. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28923. /**
  28924. * Remove an attached behavior
  28925. * @see http://doc.babylonjs.com/features/behaviour
  28926. * @param behavior defines the behavior to attach
  28927. * @returns the current Node
  28928. */
  28929. removeBehavior(behavior: Behavior<Node>): Node;
  28930. /**
  28931. * Gets the list of attached behaviors
  28932. * @see http://doc.babylonjs.com/features/behaviour
  28933. */
  28934. get behaviors(): Behavior<Node>[];
  28935. /**
  28936. * Gets an attached behavior by name
  28937. * @param name defines the name of the behavior to look for
  28938. * @see http://doc.babylonjs.com/features/behaviour
  28939. * @returns null if behavior was not found else the requested behavior
  28940. */
  28941. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28942. /**
  28943. * Returns the latest update of the World matrix
  28944. * @returns a Matrix
  28945. */
  28946. getWorldMatrix(): Matrix;
  28947. /** @hidden */
  28948. _getWorldMatrixDeterminant(): number;
  28949. /**
  28950. * Returns directly the latest state of the mesh World matrix.
  28951. * A Matrix is returned.
  28952. */
  28953. get worldMatrixFromCache(): Matrix;
  28954. /** @hidden */
  28955. _initCache(): void;
  28956. /** @hidden */
  28957. updateCache(force?: boolean): void;
  28958. /** @hidden */
  28959. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28960. /** @hidden */
  28961. _updateCache(ignoreParentClass?: boolean): void;
  28962. /** @hidden */
  28963. _isSynchronized(): boolean;
  28964. /** @hidden */
  28965. _markSyncedWithParent(): void;
  28966. /** @hidden */
  28967. isSynchronizedWithParent(): boolean;
  28968. /** @hidden */
  28969. isSynchronized(): boolean;
  28970. /**
  28971. * Is this node ready to be used/rendered
  28972. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28973. * @return true if the node is ready
  28974. */
  28975. isReady(completeCheck?: boolean): boolean;
  28976. /**
  28977. * Is this node enabled?
  28978. * 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
  28979. * @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
  28980. * @return whether this node (and its parent) is enabled
  28981. */
  28982. isEnabled(checkAncestors?: boolean): boolean;
  28983. /** @hidden */
  28984. protected _syncParentEnabledState(): void;
  28985. /**
  28986. * Set the enabled state of this node
  28987. * @param value defines the new enabled state
  28988. */
  28989. setEnabled(value: boolean): void;
  28990. /**
  28991. * Is this node a descendant of the given node?
  28992. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28993. * @param ancestor defines the parent node to inspect
  28994. * @returns a boolean indicating if this node is a descendant of the given node
  28995. */
  28996. isDescendantOf(ancestor: Node): boolean;
  28997. /** @hidden */
  28998. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28999. /**
  29000. * Will return all nodes that have this node as ascendant
  29001. * @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
  29002. * @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
  29003. * @return all children nodes of all types
  29004. */
  29005. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29006. /**
  29007. * Get all child-meshes of this node
  29008. * @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)
  29009. * @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
  29010. * @returns an array of AbstractMesh
  29011. */
  29012. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29013. /**
  29014. * Get all direct children of this node
  29015. * @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
  29016. * @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)
  29017. * @returns an array of Node
  29018. */
  29019. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29020. /** @hidden */
  29021. _setReady(state: boolean): void;
  29022. /**
  29023. * Get an animation by name
  29024. * @param name defines the name of the animation to look for
  29025. * @returns null if not found else the requested animation
  29026. */
  29027. getAnimationByName(name: string): Nullable<Animation>;
  29028. /**
  29029. * Creates an animation range for this node
  29030. * @param name defines the name of the range
  29031. * @param from defines the starting key
  29032. * @param to defines the end key
  29033. */
  29034. createAnimationRange(name: string, from: number, to: number): void;
  29035. /**
  29036. * Delete a specific animation range
  29037. * @param name defines the name of the range to delete
  29038. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29039. */
  29040. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29041. /**
  29042. * Get an animation range by name
  29043. * @param name defines the name of the animation range to look for
  29044. * @returns null if not found else the requested animation range
  29045. */
  29046. getAnimationRange(name: string): Nullable<AnimationRange>;
  29047. /**
  29048. * Gets the list of all animation ranges defined on this node
  29049. * @returns an array
  29050. */
  29051. getAnimationRanges(): Nullable<AnimationRange>[];
  29052. /**
  29053. * Will start the animation sequence
  29054. * @param name defines the range frames for animation sequence
  29055. * @param loop defines if the animation should loop (false by default)
  29056. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29057. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29058. * @returns the object created for this animation. If range does not exist, it will return null
  29059. */
  29060. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29061. /**
  29062. * Serialize animation ranges into a JSON compatible object
  29063. * @returns serialization object
  29064. */
  29065. serializeAnimationRanges(): any;
  29066. /**
  29067. * Computes the world matrix of the node
  29068. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29069. * @returns the world matrix
  29070. */
  29071. computeWorldMatrix(force?: boolean): Matrix;
  29072. /**
  29073. * Releases resources associated with this node.
  29074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29076. */
  29077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29078. /**
  29079. * Parse animation range data from a serialization object and store them into a given node
  29080. * @param node defines where to store the animation ranges
  29081. * @param parsedNode defines the serialization object to read data from
  29082. * @param scene defines the hosting scene
  29083. */
  29084. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29085. /**
  29086. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29087. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29088. * @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
  29089. * @returns the new bounding vectors
  29090. */
  29091. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29092. min: Vector3;
  29093. max: Vector3;
  29094. };
  29095. }
  29096. }
  29097. declare module BABYLON {
  29098. /**
  29099. * @hidden
  29100. */
  29101. export class _IAnimationState {
  29102. key: number;
  29103. repeatCount: number;
  29104. workValue?: any;
  29105. loopMode?: number;
  29106. offsetValue?: any;
  29107. highLimitValue?: any;
  29108. }
  29109. /**
  29110. * Class used to store any kind of animation
  29111. */
  29112. export class Animation {
  29113. /**Name of the animation */
  29114. name: string;
  29115. /**Property to animate */
  29116. targetProperty: string;
  29117. /**The frames per second of the animation */
  29118. framePerSecond: number;
  29119. /**The data type of the animation */
  29120. dataType: number;
  29121. /**The loop mode of the animation */
  29122. loopMode?: number | undefined;
  29123. /**Specifies if blending should be enabled */
  29124. enableBlending?: boolean | undefined;
  29125. /**
  29126. * Use matrix interpolation instead of using direct key value when animating matrices
  29127. */
  29128. static AllowMatricesInterpolation: boolean;
  29129. /**
  29130. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29131. */
  29132. static AllowMatrixDecomposeForInterpolation: boolean;
  29133. /**
  29134. * Stores the key frames of the animation
  29135. */
  29136. private _keys;
  29137. /**
  29138. * Stores the easing function of the animation
  29139. */
  29140. private _easingFunction;
  29141. /**
  29142. * @hidden Internal use only
  29143. */
  29144. _runtimeAnimations: RuntimeAnimation[];
  29145. /**
  29146. * The set of event that will be linked to this animation
  29147. */
  29148. private _events;
  29149. /**
  29150. * Stores an array of target property paths
  29151. */
  29152. targetPropertyPath: string[];
  29153. /**
  29154. * Stores the blending speed of the animation
  29155. */
  29156. blendingSpeed: number;
  29157. /**
  29158. * Stores the animation ranges for the animation
  29159. */
  29160. private _ranges;
  29161. /**
  29162. * @hidden Internal use
  29163. */
  29164. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29165. /**
  29166. * Sets up an animation
  29167. * @param property The property to animate
  29168. * @param animationType The animation type to apply
  29169. * @param framePerSecond The frames per second of the animation
  29170. * @param easingFunction The easing function used in the animation
  29171. * @returns The created animation
  29172. */
  29173. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29174. /**
  29175. * Create and start an animation on a node
  29176. * @param name defines the name of the global animation that will be run on all nodes
  29177. * @param node defines the root node where the animation will take place
  29178. * @param targetProperty defines property to animate
  29179. * @param framePerSecond defines the number of frame per second yo use
  29180. * @param totalFrame defines the number of frames in total
  29181. * @param from defines the initial value
  29182. * @param to defines the final value
  29183. * @param loopMode defines which loop mode you want to use (off by default)
  29184. * @param easingFunction defines the easing function to use (linear by default)
  29185. * @param onAnimationEnd defines the callback to call when animation end
  29186. * @returns the animatable created for this animation
  29187. */
  29188. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29189. /**
  29190. * Create and start an animation on a node and its descendants
  29191. * @param name defines the name of the global animation that will be run on all nodes
  29192. * @param node defines the root node where the animation will take place
  29193. * @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
  29194. * @param targetProperty defines property to animate
  29195. * @param framePerSecond defines the number of frame per second to use
  29196. * @param totalFrame defines the number of frames in total
  29197. * @param from defines the initial value
  29198. * @param to defines the final value
  29199. * @param loopMode defines which loop mode you want to use (off by default)
  29200. * @param easingFunction defines the easing function to use (linear by default)
  29201. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29202. * @returns the list of animatables created for all nodes
  29203. * @example https://www.babylonjs-playground.com/#MH0VLI
  29204. */
  29205. 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[]>;
  29206. /**
  29207. * Creates a new animation, merges it with the existing animations and starts it
  29208. * @param name Name of the animation
  29209. * @param node Node which contains the scene that begins the animations
  29210. * @param targetProperty Specifies which property to animate
  29211. * @param framePerSecond The frames per second of the animation
  29212. * @param totalFrame The total number of frames
  29213. * @param from The frame at the beginning of the animation
  29214. * @param to The frame at the end of the animation
  29215. * @param loopMode Specifies the loop mode of the animation
  29216. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29217. * @param onAnimationEnd Callback to run once the animation is complete
  29218. * @returns Nullable animation
  29219. */
  29220. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29221. /**
  29222. * Transition property of an host to the target Value
  29223. * @param property The property to transition
  29224. * @param targetValue The target Value of the property
  29225. * @param host The object where the property to animate belongs
  29226. * @param scene Scene used to run the animation
  29227. * @param frameRate Framerate (in frame/s) to use
  29228. * @param transition The transition type we want to use
  29229. * @param duration The duration of the animation, in milliseconds
  29230. * @param onAnimationEnd Callback trigger at the end of the animation
  29231. * @returns Nullable animation
  29232. */
  29233. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29234. /**
  29235. * Return the array of runtime animations currently using this animation
  29236. */
  29237. get runtimeAnimations(): RuntimeAnimation[];
  29238. /**
  29239. * Specifies if any of the runtime animations are currently running
  29240. */
  29241. get hasRunningRuntimeAnimations(): boolean;
  29242. /**
  29243. * Initializes the animation
  29244. * @param name Name of the animation
  29245. * @param targetProperty Property to animate
  29246. * @param framePerSecond The frames per second of the animation
  29247. * @param dataType The data type of the animation
  29248. * @param loopMode The loop mode of the animation
  29249. * @param enableBlending Specifies if blending should be enabled
  29250. */
  29251. constructor(
  29252. /**Name of the animation */
  29253. name: string,
  29254. /**Property to animate */
  29255. targetProperty: string,
  29256. /**The frames per second of the animation */
  29257. framePerSecond: number,
  29258. /**The data type of the animation */
  29259. dataType: number,
  29260. /**The loop mode of the animation */
  29261. loopMode?: number | undefined,
  29262. /**Specifies if blending should be enabled */
  29263. enableBlending?: boolean | undefined);
  29264. /**
  29265. * Converts the animation to a string
  29266. * @param fullDetails support for multiple levels of logging within scene loading
  29267. * @returns String form of the animation
  29268. */
  29269. toString(fullDetails?: boolean): string;
  29270. /**
  29271. * Add an event to this animation
  29272. * @param event Event to add
  29273. */
  29274. addEvent(event: AnimationEvent): void;
  29275. /**
  29276. * Remove all events found at the given frame
  29277. * @param frame The frame to remove events from
  29278. */
  29279. removeEvents(frame: number): void;
  29280. /**
  29281. * Retrieves all the events from the animation
  29282. * @returns Events from the animation
  29283. */
  29284. getEvents(): AnimationEvent[];
  29285. /**
  29286. * Creates an animation range
  29287. * @param name Name of the animation range
  29288. * @param from Starting frame of the animation range
  29289. * @param to Ending frame of the animation
  29290. */
  29291. createRange(name: string, from: number, to: number): void;
  29292. /**
  29293. * Deletes an animation range by name
  29294. * @param name Name of the animation range to delete
  29295. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29296. */
  29297. deleteRange(name: string, deleteFrames?: boolean): void;
  29298. /**
  29299. * Gets the animation range by name, or null if not defined
  29300. * @param name Name of the animation range
  29301. * @returns Nullable animation range
  29302. */
  29303. getRange(name: string): Nullable<AnimationRange>;
  29304. /**
  29305. * Gets the key frames from the animation
  29306. * @returns The key frames of the animation
  29307. */
  29308. getKeys(): Array<IAnimationKey>;
  29309. /**
  29310. * Gets the highest frame rate of the animation
  29311. * @returns Highest frame rate of the animation
  29312. */
  29313. getHighestFrame(): number;
  29314. /**
  29315. * Gets the easing function of the animation
  29316. * @returns Easing function of the animation
  29317. */
  29318. getEasingFunction(): IEasingFunction;
  29319. /**
  29320. * Sets the easing function of the animation
  29321. * @param easingFunction A custom mathematical formula for animation
  29322. */
  29323. setEasingFunction(easingFunction: EasingFunction): void;
  29324. /**
  29325. * Interpolates a scalar linearly
  29326. * @param startValue Start value of the animation curve
  29327. * @param endValue End value of the animation curve
  29328. * @param gradient Scalar amount to interpolate
  29329. * @returns Interpolated scalar value
  29330. */
  29331. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29332. /**
  29333. * Interpolates a scalar cubically
  29334. * @param startValue Start value of the animation curve
  29335. * @param outTangent End tangent of the animation
  29336. * @param endValue End value of the animation curve
  29337. * @param inTangent Start tangent of the animation curve
  29338. * @param gradient Scalar amount to interpolate
  29339. * @returns Interpolated scalar value
  29340. */
  29341. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29342. /**
  29343. * Interpolates a quaternion using a spherical linear interpolation
  29344. * @param startValue Start value of the animation curve
  29345. * @param endValue End value of the animation curve
  29346. * @param gradient Scalar amount to interpolate
  29347. * @returns Interpolated quaternion value
  29348. */
  29349. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29350. /**
  29351. * Interpolates a quaternion cubically
  29352. * @param startValue Start value of the animation curve
  29353. * @param outTangent End tangent of the animation curve
  29354. * @param endValue End value of the animation curve
  29355. * @param inTangent Start tangent of the animation curve
  29356. * @param gradient Scalar amount to interpolate
  29357. * @returns Interpolated quaternion value
  29358. */
  29359. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29360. /**
  29361. * Interpolates a Vector3 linearl
  29362. * @param startValue Start value of the animation curve
  29363. * @param endValue End value of the animation curve
  29364. * @param gradient Scalar amount to interpolate
  29365. * @returns Interpolated scalar value
  29366. */
  29367. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29368. /**
  29369. * Interpolates a Vector3 cubically
  29370. * @param startValue Start value of the animation curve
  29371. * @param outTangent End tangent of the animation
  29372. * @param endValue End value of the animation curve
  29373. * @param inTangent Start tangent of the animation curve
  29374. * @param gradient Scalar amount to interpolate
  29375. * @returns InterpolatedVector3 value
  29376. */
  29377. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29378. /**
  29379. * Interpolates a Vector2 linearly
  29380. * @param startValue Start value of the animation curve
  29381. * @param endValue End value of the animation curve
  29382. * @param gradient Scalar amount to interpolate
  29383. * @returns Interpolated Vector2 value
  29384. */
  29385. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29386. /**
  29387. * Interpolates a Vector2 cubically
  29388. * @param startValue Start value of the animation curve
  29389. * @param outTangent End tangent of the animation
  29390. * @param endValue End value of the animation curve
  29391. * @param inTangent Start tangent of the animation curve
  29392. * @param gradient Scalar amount to interpolate
  29393. * @returns Interpolated Vector2 value
  29394. */
  29395. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29396. /**
  29397. * Interpolates a size linearly
  29398. * @param startValue Start value of the animation curve
  29399. * @param endValue End value of the animation curve
  29400. * @param gradient Scalar amount to interpolate
  29401. * @returns Interpolated Size value
  29402. */
  29403. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29404. /**
  29405. * Interpolates a Color3 linearly
  29406. * @param startValue Start value of the animation curve
  29407. * @param endValue End value of the animation curve
  29408. * @param gradient Scalar amount to interpolate
  29409. * @returns Interpolated Color3 value
  29410. */
  29411. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29412. /**
  29413. * Interpolates a Color4 linearly
  29414. * @param startValue Start value of the animation curve
  29415. * @param endValue End value of the animation curve
  29416. * @param gradient Scalar amount to interpolate
  29417. * @returns Interpolated Color3 value
  29418. */
  29419. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29420. /**
  29421. * @hidden Internal use only
  29422. */
  29423. _getKeyValue(value: any): any;
  29424. /**
  29425. * @hidden Internal use only
  29426. */
  29427. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29428. /**
  29429. * Defines the function to use to interpolate matrices
  29430. * @param startValue defines the start matrix
  29431. * @param endValue defines the end matrix
  29432. * @param gradient defines the gradient between both matrices
  29433. * @param result defines an optional target matrix where to store the interpolation
  29434. * @returns the interpolated matrix
  29435. */
  29436. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29437. /**
  29438. * Makes a copy of the animation
  29439. * @returns Cloned animation
  29440. */
  29441. clone(): Animation;
  29442. /**
  29443. * Sets the key frames of the animation
  29444. * @param values The animation key frames to set
  29445. */
  29446. setKeys(values: Array<IAnimationKey>): void;
  29447. /**
  29448. * Serializes the animation to an object
  29449. * @returns Serialized object
  29450. */
  29451. serialize(): any;
  29452. /**
  29453. * Float animation type
  29454. */
  29455. static readonly ANIMATIONTYPE_FLOAT: number;
  29456. /**
  29457. * Vector3 animation type
  29458. */
  29459. static readonly ANIMATIONTYPE_VECTOR3: number;
  29460. /**
  29461. * Quaternion animation type
  29462. */
  29463. static readonly ANIMATIONTYPE_QUATERNION: number;
  29464. /**
  29465. * Matrix animation type
  29466. */
  29467. static readonly ANIMATIONTYPE_MATRIX: number;
  29468. /**
  29469. * Color3 animation type
  29470. */
  29471. static readonly ANIMATIONTYPE_COLOR3: number;
  29472. /**
  29473. * Color3 animation type
  29474. */
  29475. static readonly ANIMATIONTYPE_COLOR4: number;
  29476. /**
  29477. * Vector2 animation type
  29478. */
  29479. static readonly ANIMATIONTYPE_VECTOR2: number;
  29480. /**
  29481. * Size animation type
  29482. */
  29483. static readonly ANIMATIONTYPE_SIZE: number;
  29484. /**
  29485. * Relative Loop Mode
  29486. */
  29487. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29488. /**
  29489. * Cycle Loop Mode
  29490. */
  29491. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29492. /**
  29493. * Constant Loop Mode
  29494. */
  29495. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29496. /** @hidden */
  29497. static _UniversalLerp(left: any, right: any, amount: number): any;
  29498. /**
  29499. * Parses an animation object and creates an animation
  29500. * @param parsedAnimation Parsed animation object
  29501. * @returns Animation object
  29502. */
  29503. static Parse(parsedAnimation: any): Animation;
  29504. /**
  29505. * Appends the serialized animations from the source animations
  29506. * @param source Source containing the animations
  29507. * @param destination Target to store the animations
  29508. */
  29509. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29510. }
  29511. }
  29512. declare module BABYLON {
  29513. /**
  29514. * Interface containing an array of animations
  29515. */
  29516. export interface IAnimatable {
  29517. /**
  29518. * Array of animations
  29519. */
  29520. animations: Nullable<Array<Animation>>;
  29521. }
  29522. }
  29523. declare module BABYLON {
  29524. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29525. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29526. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29527. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29528. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29529. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29530. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29531. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29532. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29533. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29534. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29535. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29536. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29537. /**
  29538. * Decorator used to define property that can be serialized as reference to a camera
  29539. * @param sourceName defines the name of the property to decorate
  29540. */
  29541. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29542. /**
  29543. * Class used to help serialization objects
  29544. */
  29545. export class SerializationHelper {
  29546. /** @hidden */
  29547. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29548. /** @hidden */
  29549. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29550. /** @hidden */
  29551. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29552. /** @hidden */
  29553. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29554. /**
  29555. * Appends the serialized animations from the source animations
  29556. * @param source Source containing the animations
  29557. * @param destination Target to store the animations
  29558. */
  29559. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29560. /**
  29561. * Static function used to serialized a specific entity
  29562. * @param entity defines the entity to serialize
  29563. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29564. * @returns a JSON compatible object representing the serialization of the entity
  29565. */
  29566. static Serialize<T>(entity: T, serializationObject?: any): any;
  29567. /**
  29568. * Creates a new entity from a serialization data object
  29569. * @param creationFunction defines a function used to instanciated the new entity
  29570. * @param source defines the source serialization data
  29571. * @param scene defines the hosting scene
  29572. * @param rootUrl defines the root url for resources
  29573. * @returns a new entity
  29574. */
  29575. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29576. /**
  29577. * Clones an object
  29578. * @param creationFunction defines the function used to instanciate the new object
  29579. * @param source defines the source object
  29580. * @returns the cloned object
  29581. */
  29582. static Clone<T>(creationFunction: () => T, source: T): T;
  29583. /**
  29584. * Instanciates a new object based on a source one (some data will be shared between both object)
  29585. * @param creationFunction defines the function used to instanciate the new object
  29586. * @param source defines the source object
  29587. * @returns the new object
  29588. */
  29589. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29590. }
  29591. }
  29592. declare module BABYLON {
  29593. /**
  29594. * Class used to manipulate GUIDs
  29595. */
  29596. export class GUID {
  29597. /**
  29598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29599. * Be aware Math.random() could cause collisions, but:
  29600. * "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"
  29601. * @returns a pseudo random id
  29602. */
  29603. static RandomId(): string;
  29604. }
  29605. }
  29606. declare module BABYLON {
  29607. /**
  29608. * Base class of all the textures in babylon.
  29609. * It groups all the common properties the materials, post process, lights... might need
  29610. * in order to make a correct use of the texture.
  29611. */
  29612. export class BaseTexture implements IAnimatable {
  29613. /**
  29614. * Default anisotropic filtering level for the application.
  29615. * It is set to 4 as a good tradeoff between perf and quality.
  29616. */
  29617. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29618. /**
  29619. * Gets or sets the unique id of the texture
  29620. */
  29621. uniqueId: number;
  29622. /**
  29623. * Define the name of the texture.
  29624. */
  29625. name: string;
  29626. /**
  29627. * Gets or sets an object used to store user defined information.
  29628. */
  29629. metadata: any;
  29630. /**
  29631. * For internal use only. Please do not use.
  29632. */
  29633. reservedDataStore: any;
  29634. private _hasAlpha;
  29635. /**
  29636. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29637. */
  29638. set hasAlpha(value: boolean);
  29639. get hasAlpha(): boolean;
  29640. /**
  29641. * Defines if the alpha value should be determined via the rgb values.
  29642. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29643. */
  29644. getAlphaFromRGB: boolean;
  29645. /**
  29646. * Intensity or strength of the texture.
  29647. * It is commonly used by materials to fine tune the intensity of the texture
  29648. */
  29649. level: number;
  29650. /**
  29651. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29652. * This is part of the texture as textures usually maps to one uv set.
  29653. */
  29654. coordinatesIndex: number;
  29655. private _coordinatesMode;
  29656. /**
  29657. * How a texture is mapped.
  29658. *
  29659. * | Value | Type | Description |
  29660. * | ----- | ----------------------------------- | ----------- |
  29661. * | 0 | EXPLICIT_MODE | |
  29662. * | 1 | SPHERICAL_MODE | |
  29663. * | 2 | PLANAR_MODE | |
  29664. * | 3 | CUBIC_MODE | |
  29665. * | 4 | PROJECTION_MODE | |
  29666. * | 5 | SKYBOX_MODE | |
  29667. * | 6 | INVCUBIC_MODE | |
  29668. * | 7 | EQUIRECTANGULAR_MODE | |
  29669. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29670. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29671. */
  29672. set coordinatesMode(value: number);
  29673. get coordinatesMode(): number;
  29674. /**
  29675. * | Value | Type | Description |
  29676. * | ----- | ------------------ | ----------- |
  29677. * | 0 | CLAMP_ADDRESSMODE | |
  29678. * | 1 | WRAP_ADDRESSMODE | |
  29679. * | 2 | MIRROR_ADDRESSMODE | |
  29680. */
  29681. wrapU: number;
  29682. /**
  29683. * | Value | Type | Description |
  29684. * | ----- | ------------------ | ----------- |
  29685. * | 0 | CLAMP_ADDRESSMODE | |
  29686. * | 1 | WRAP_ADDRESSMODE | |
  29687. * | 2 | MIRROR_ADDRESSMODE | |
  29688. */
  29689. wrapV: number;
  29690. /**
  29691. * | Value | Type | Description |
  29692. * | ----- | ------------------ | ----------- |
  29693. * | 0 | CLAMP_ADDRESSMODE | |
  29694. * | 1 | WRAP_ADDRESSMODE | |
  29695. * | 2 | MIRROR_ADDRESSMODE | |
  29696. */
  29697. wrapR: number;
  29698. /**
  29699. * With compliant hardware and browser (supporting anisotropic filtering)
  29700. * this defines the level of anisotropic filtering in the texture.
  29701. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29702. */
  29703. anisotropicFilteringLevel: number;
  29704. /**
  29705. * Define if the texture is a cube texture or if false a 2d texture.
  29706. */
  29707. get isCube(): boolean;
  29708. set isCube(value: boolean);
  29709. /**
  29710. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29711. */
  29712. get is3D(): boolean;
  29713. set is3D(value: boolean);
  29714. /**
  29715. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29716. */
  29717. get is2DArray(): boolean;
  29718. set is2DArray(value: boolean);
  29719. /**
  29720. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29721. * HDR texture are usually stored in linear space.
  29722. * This only impacts the PBR and Background materials
  29723. */
  29724. gammaSpace: boolean;
  29725. /**
  29726. * Gets or sets whether or not the texture contains RGBD data.
  29727. */
  29728. get isRGBD(): boolean;
  29729. set isRGBD(value: boolean);
  29730. /**
  29731. * Is Z inverted in the texture (useful in a cube texture).
  29732. */
  29733. invertZ: boolean;
  29734. /**
  29735. * Are mip maps generated for this texture or not.
  29736. */
  29737. get noMipmap(): boolean;
  29738. /**
  29739. * @hidden
  29740. */
  29741. lodLevelInAlpha: boolean;
  29742. /**
  29743. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29744. */
  29745. get lodGenerationOffset(): number;
  29746. set lodGenerationOffset(value: number);
  29747. /**
  29748. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29749. */
  29750. get lodGenerationScale(): number;
  29751. set lodGenerationScale(value: number);
  29752. /**
  29753. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29754. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29755. * average roughness values.
  29756. */
  29757. get linearSpecularLOD(): boolean;
  29758. set linearSpecularLOD(value: boolean);
  29759. /**
  29760. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29761. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29762. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29763. */
  29764. get irradianceTexture(): Nullable<BaseTexture>;
  29765. set irradianceTexture(value: Nullable<BaseTexture>);
  29766. /**
  29767. * Define if the texture is a render target.
  29768. */
  29769. isRenderTarget: boolean;
  29770. /**
  29771. * Define the unique id of the texture in the scene.
  29772. */
  29773. get uid(): string;
  29774. /**
  29775. * Return a string representation of the texture.
  29776. * @returns the texture as a string
  29777. */
  29778. toString(): string;
  29779. /**
  29780. * Get the class name of the texture.
  29781. * @returns "BaseTexture"
  29782. */
  29783. getClassName(): string;
  29784. /**
  29785. * Define the list of animation attached to the texture.
  29786. */
  29787. animations: Animation[];
  29788. /**
  29789. * An event triggered when the texture is disposed.
  29790. */
  29791. onDisposeObservable: Observable<BaseTexture>;
  29792. private _onDisposeObserver;
  29793. /**
  29794. * Callback triggered when the texture has been disposed.
  29795. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29796. */
  29797. set onDispose(callback: () => void);
  29798. /**
  29799. * Define the current state of the loading sequence when in delayed load mode.
  29800. */
  29801. delayLoadState: number;
  29802. private _scene;
  29803. /** @hidden */
  29804. _texture: Nullable<InternalTexture>;
  29805. private _uid;
  29806. /**
  29807. * Define if the texture is preventinga material to render or not.
  29808. * If not and the texture is not ready, the engine will use a default black texture instead.
  29809. */
  29810. get isBlocking(): boolean;
  29811. /**
  29812. * Instantiates a new BaseTexture.
  29813. * Base class of all the textures in babylon.
  29814. * It groups all the common properties the materials, post process, lights... might need
  29815. * in order to make a correct use of the texture.
  29816. * @param scene Define the scene the texture blongs to
  29817. */
  29818. constructor(scene: Nullable<Scene>);
  29819. /**
  29820. * Get the scene the texture belongs to.
  29821. * @returns the scene or null if undefined
  29822. */
  29823. getScene(): Nullable<Scene>;
  29824. /**
  29825. * Get the texture transform matrix used to offset tile the texture for istance.
  29826. * @returns the transformation matrix
  29827. */
  29828. getTextureMatrix(): Matrix;
  29829. /**
  29830. * Get the texture reflection matrix used to rotate/transform the reflection.
  29831. * @returns the reflection matrix
  29832. */
  29833. getReflectionTextureMatrix(): Matrix;
  29834. /**
  29835. * Get the underlying lower level texture from Babylon.
  29836. * @returns the insternal texture
  29837. */
  29838. getInternalTexture(): Nullable<InternalTexture>;
  29839. /**
  29840. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29841. * @returns true if ready or not blocking
  29842. */
  29843. isReadyOrNotBlocking(): boolean;
  29844. /**
  29845. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29846. * @returns true if fully ready
  29847. */
  29848. isReady(): boolean;
  29849. private _cachedSize;
  29850. /**
  29851. * Get the size of the texture.
  29852. * @returns the texture size.
  29853. */
  29854. getSize(): ISize;
  29855. /**
  29856. * Get the base size of the texture.
  29857. * It can be different from the size if the texture has been resized for POT for instance
  29858. * @returns the base size
  29859. */
  29860. getBaseSize(): ISize;
  29861. /**
  29862. * Update the sampling mode of the texture.
  29863. * Default is Trilinear mode.
  29864. *
  29865. * | Value | Type | Description |
  29866. * | ----- | ------------------ | ----------- |
  29867. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29868. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29869. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29870. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29871. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29872. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29873. * | 7 | NEAREST_LINEAR | |
  29874. * | 8 | NEAREST_NEAREST | |
  29875. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29876. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29877. * | 11 | LINEAR_LINEAR | |
  29878. * | 12 | LINEAR_NEAREST | |
  29879. *
  29880. * > _mag_: magnification filter (close to the viewer)
  29881. * > _min_: minification filter (far from the viewer)
  29882. * > _mip_: filter used between mip map levels
  29883. *@param samplingMode Define the new sampling mode of the texture
  29884. */
  29885. updateSamplingMode(samplingMode: number): void;
  29886. /**
  29887. * Scales the texture if is `canRescale()`
  29888. * @param ratio the resize factor we want to use to rescale
  29889. */
  29890. scale(ratio: number): void;
  29891. /**
  29892. * Get if the texture can rescale.
  29893. */
  29894. get canRescale(): boolean;
  29895. /** @hidden */
  29896. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29897. /** @hidden */
  29898. _rebuild(): void;
  29899. /**
  29900. * Triggers the load sequence in delayed load mode.
  29901. */
  29902. delayLoad(): void;
  29903. /**
  29904. * Clones the texture.
  29905. * @returns the cloned texture
  29906. */
  29907. clone(): Nullable<BaseTexture>;
  29908. /**
  29909. * Get the texture underlying type (INT, FLOAT...)
  29910. */
  29911. get textureType(): number;
  29912. /**
  29913. * Get the texture underlying format (RGB, RGBA...)
  29914. */
  29915. get textureFormat(): number;
  29916. /**
  29917. * Indicates that textures need to be re-calculated for all materials
  29918. */
  29919. protected _markAllSubMeshesAsTexturesDirty(): void;
  29920. /**
  29921. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29922. * This will returns an RGBA array buffer containing either in values (0-255) or
  29923. * float values (0-1) depending of the underlying buffer type.
  29924. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29925. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29926. * @param buffer defines a user defined buffer to fill with data (can be null)
  29927. * @returns The Array buffer containing the pixels data.
  29928. */
  29929. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29930. /**
  29931. * Release and destroy the underlying lower level texture aka internalTexture.
  29932. */
  29933. releaseInternalTexture(): void;
  29934. /** @hidden */
  29935. get _lodTextureHigh(): Nullable<BaseTexture>;
  29936. /** @hidden */
  29937. get _lodTextureMid(): Nullable<BaseTexture>;
  29938. /** @hidden */
  29939. get _lodTextureLow(): Nullable<BaseTexture>;
  29940. /**
  29941. * Dispose the texture and release its associated resources.
  29942. */
  29943. dispose(): void;
  29944. /**
  29945. * Serialize the texture into a JSON representation that can be parsed later on.
  29946. * @returns the JSON representation of the texture
  29947. */
  29948. serialize(): any;
  29949. /**
  29950. * Helper function to be called back once a list of texture contains only ready textures.
  29951. * @param textures Define the list of textures to wait for
  29952. * @param callback Define the callback triggered once the entire list will be ready
  29953. */
  29954. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29955. }
  29956. }
  29957. declare module BABYLON {
  29958. /**
  29959. * Options to be used when creating an effect.
  29960. */
  29961. export interface IEffectCreationOptions {
  29962. /**
  29963. * Atrributes that will be used in the shader.
  29964. */
  29965. attributes: string[];
  29966. /**
  29967. * Uniform varible names that will be set in the shader.
  29968. */
  29969. uniformsNames: string[];
  29970. /**
  29971. * Uniform buffer variable names that will be set in the shader.
  29972. */
  29973. uniformBuffersNames: string[];
  29974. /**
  29975. * Sampler texture variable names that will be set in the shader.
  29976. */
  29977. samplers: string[];
  29978. /**
  29979. * Define statements that will be set in the shader.
  29980. */
  29981. defines: any;
  29982. /**
  29983. * Possible fallbacks for this effect to improve performance when needed.
  29984. */
  29985. fallbacks: Nullable<IEffectFallbacks>;
  29986. /**
  29987. * Callback that will be called when the shader is compiled.
  29988. */
  29989. onCompiled: Nullable<(effect: Effect) => void>;
  29990. /**
  29991. * Callback that will be called if an error occurs during shader compilation.
  29992. */
  29993. onError: Nullable<(effect: Effect, errors: string) => void>;
  29994. /**
  29995. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29996. */
  29997. indexParameters?: any;
  29998. /**
  29999. * Max number of lights that can be used in the shader.
  30000. */
  30001. maxSimultaneousLights?: number;
  30002. /**
  30003. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30004. */
  30005. transformFeedbackVaryings?: Nullable<string[]>;
  30006. }
  30007. /**
  30008. * Effect containing vertex and fragment shader that can be executed on an object.
  30009. */
  30010. export class Effect implements IDisposable {
  30011. /**
  30012. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30013. */
  30014. static ShadersRepository: string;
  30015. /**
  30016. * Enable logging of the shader code when a compilation error occurs
  30017. */
  30018. static LogShaderCodeOnCompilationError: boolean;
  30019. /**
  30020. * Name of the effect.
  30021. */
  30022. name: any;
  30023. /**
  30024. * String container all the define statements that should be set on the shader.
  30025. */
  30026. defines: string;
  30027. /**
  30028. * Callback that will be called when the shader is compiled.
  30029. */
  30030. onCompiled: Nullable<(effect: Effect) => void>;
  30031. /**
  30032. * Callback that will be called if an error occurs during shader compilation.
  30033. */
  30034. onError: Nullable<(effect: Effect, errors: string) => void>;
  30035. /**
  30036. * Callback that will be called when effect is bound.
  30037. */
  30038. onBind: Nullable<(effect: Effect) => void>;
  30039. /**
  30040. * Unique ID of the effect.
  30041. */
  30042. uniqueId: number;
  30043. /**
  30044. * Observable that will be called when the shader is compiled.
  30045. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30046. */
  30047. onCompileObservable: Observable<Effect>;
  30048. /**
  30049. * Observable that will be called if an error occurs during shader compilation.
  30050. */
  30051. onErrorObservable: Observable<Effect>;
  30052. /** @hidden */
  30053. _onBindObservable: Nullable<Observable<Effect>>;
  30054. /**
  30055. * @hidden
  30056. * Specifies if the effect was previously ready
  30057. */
  30058. _wasPreviouslyReady: boolean;
  30059. /**
  30060. * Observable that will be called when effect is bound.
  30061. */
  30062. get onBindObservable(): Observable<Effect>;
  30063. /** @hidden */
  30064. _bonesComputationForcedToCPU: boolean;
  30065. private static _uniqueIdSeed;
  30066. private _engine;
  30067. private _uniformBuffersNames;
  30068. private _uniformsNames;
  30069. private _samplerList;
  30070. private _samplers;
  30071. private _isReady;
  30072. private _compilationError;
  30073. private _allFallbacksProcessed;
  30074. private _attributesNames;
  30075. private _attributes;
  30076. private _attributeLocationByName;
  30077. private _uniforms;
  30078. /**
  30079. * Key for the effect.
  30080. * @hidden
  30081. */
  30082. _key: string;
  30083. private _indexParameters;
  30084. private _fallbacks;
  30085. private _vertexSourceCode;
  30086. private _fragmentSourceCode;
  30087. private _vertexSourceCodeOverride;
  30088. private _fragmentSourceCodeOverride;
  30089. private _transformFeedbackVaryings;
  30090. /**
  30091. * Compiled shader to webGL program.
  30092. * @hidden
  30093. */
  30094. _pipelineContext: Nullable<IPipelineContext>;
  30095. private _valueCache;
  30096. private static _baseCache;
  30097. /**
  30098. * Instantiates an effect.
  30099. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30100. * @param baseName Name of the effect.
  30101. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30102. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30103. * @param samplers List of sampler variables that will be passed to the shader.
  30104. * @param engine Engine to be used to render the effect
  30105. * @param defines Define statements to be added to the shader.
  30106. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30107. * @param onCompiled Callback that will be called when the shader is compiled.
  30108. * @param onError Callback that will be called if an error occurs during shader compilation.
  30109. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30110. */
  30111. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30112. private _useFinalCode;
  30113. /**
  30114. * Unique key for this effect
  30115. */
  30116. get key(): string;
  30117. /**
  30118. * If the effect has been compiled and prepared.
  30119. * @returns if the effect is compiled and prepared.
  30120. */
  30121. isReady(): boolean;
  30122. private _isReadyInternal;
  30123. /**
  30124. * The engine the effect was initialized with.
  30125. * @returns the engine.
  30126. */
  30127. getEngine(): Engine;
  30128. /**
  30129. * The pipeline context for this effect
  30130. * @returns the associated pipeline context
  30131. */
  30132. getPipelineContext(): Nullable<IPipelineContext>;
  30133. /**
  30134. * The set of names of attribute variables for the shader.
  30135. * @returns An array of attribute names.
  30136. */
  30137. getAttributesNames(): string[];
  30138. /**
  30139. * Returns the attribute at the given index.
  30140. * @param index The index of the attribute.
  30141. * @returns The location of the attribute.
  30142. */
  30143. getAttributeLocation(index: number): number;
  30144. /**
  30145. * Returns the attribute based on the name of the variable.
  30146. * @param name of the attribute to look up.
  30147. * @returns the attribute location.
  30148. */
  30149. getAttributeLocationByName(name: string): number;
  30150. /**
  30151. * The number of attributes.
  30152. * @returns the numnber of attributes.
  30153. */
  30154. getAttributesCount(): number;
  30155. /**
  30156. * Gets the index of a uniform variable.
  30157. * @param uniformName of the uniform to look up.
  30158. * @returns the index.
  30159. */
  30160. getUniformIndex(uniformName: string): number;
  30161. /**
  30162. * Returns the attribute based on the name of the variable.
  30163. * @param uniformName of the uniform to look up.
  30164. * @returns the location of the uniform.
  30165. */
  30166. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30167. /**
  30168. * Returns an array of sampler variable names
  30169. * @returns The array of sampler variable neames.
  30170. */
  30171. getSamplers(): string[];
  30172. /**
  30173. * The error from the last compilation.
  30174. * @returns the error string.
  30175. */
  30176. getCompilationError(): string;
  30177. /**
  30178. * Gets a boolean indicating that all fallbacks were used during compilation
  30179. * @returns true if all fallbacks were used
  30180. */
  30181. allFallbacksProcessed(): boolean;
  30182. /**
  30183. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30184. * @param func The callback to be used.
  30185. */
  30186. executeWhenCompiled(func: (effect: Effect) => void): void;
  30187. private _checkIsReady;
  30188. private _loadShader;
  30189. /**
  30190. * Recompiles the webGL program
  30191. * @param vertexSourceCode The source code for the vertex shader.
  30192. * @param fragmentSourceCode The source code for the fragment shader.
  30193. * @param onCompiled Callback called when completed.
  30194. * @param onError Callback called on error.
  30195. * @hidden
  30196. */
  30197. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30198. /**
  30199. * Prepares the effect
  30200. * @hidden
  30201. */
  30202. _prepareEffect(): void;
  30203. private _getShaderCodeAndErrorLine;
  30204. private _processCompilationErrors;
  30205. /**
  30206. * Checks if the effect is supported. (Must be called after compilation)
  30207. */
  30208. get isSupported(): boolean;
  30209. /**
  30210. * Binds a texture to the engine to be used as output of the shader.
  30211. * @param channel Name of the output variable.
  30212. * @param texture Texture to bind.
  30213. * @hidden
  30214. */
  30215. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30216. /**
  30217. * Sets a texture on the engine to be used in the shader.
  30218. * @param channel Name of the sampler variable.
  30219. * @param texture Texture to set.
  30220. */
  30221. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30222. /**
  30223. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30224. * @param channel Name of the sampler variable.
  30225. * @param texture Texture to set.
  30226. */
  30227. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30228. /**
  30229. * Sets an array of textures on the engine to be used in the shader.
  30230. * @param channel Name of the variable.
  30231. * @param textures Textures to set.
  30232. */
  30233. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30234. /**
  30235. * 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)
  30236. * @param channel Name of the sampler variable.
  30237. * @param postProcess Post process to get the input texture from.
  30238. */
  30239. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30240. /**
  30241. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30242. * 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)
  30243. * @param channel Name of the sampler variable.
  30244. * @param postProcess Post process to get the output texture from.
  30245. */
  30246. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30247. /** @hidden */
  30248. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30249. /** @hidden */
  30250. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30251. /** @hidden */
  30252. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30253. /** @hidden */
  30254. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30255. /**
  30256. * Binds a buffer to a uniform.
  30257. * @param buffer Buffer to bind.
  30258. * @param name Name of the uniform variable to bind to.
  30259. */
  30260. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30261. /**
  30262. * Binds block to a uniform.
  30263. * @param blockName Name of the block to bind.
  30264. * @param index Index to bind.
  30265. */
  30266. bindUniformBlock(blockName: string, index: number): void;
  30267. /**
  30268. * Sets an interger value on a uniform variable.
  30269. * @param uniformName Name of the variable.
  30270. * @param value Value to be set.
  30271. * @returns this effect.
  30272. */
  30273. setInt(uniformName: string, value: number): Effect;
  30274. /**
  30275. * Sets an int array on a uniform variable.
  30276. * @param uniformName Name of the variable.
  30277. * @param array array to be set.
  30278. * @returns this effect.
  30279. */
  30280. setIntArray(uniformName: string, array: Int32Array): Effect;
  30281. /**
  30282. * 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)
  30283. * @param uniformName Name of the variable.
  30284. * @param array array to be set.
  30285. * @returns this effect.
  30286. */
  30287. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30288. /**
  30289. * 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)
  30290. * @param uniformName Name of the variable.
  30291. * @param array array to be set.
  30292. * @returns this effect.
  30293. */
  30294. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30295. /**
  30296. * 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)
  30297. * @param uniformName Name of the variable.
  30298. * @param array array to be set.
  30299. * @returns this effect.
  30300. */
  30301. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30302. /**
  30303. * Sets an float array on a uniform variable.
  30304. * @param uniformName Name of the variable.
  30305. * @param array array to be set.
  30306. * @returns this effect.
  30307. */
  30308. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30309. /**
  30310. * 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)
  30311. * @param uniformName Name of the variable.
  30312. * @param array array to be set.
  30313. * @returns this effect.
  30314. */
  30315. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30316. /**
  30317. * 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)
  30318. * @param uniformName Name of the variable.
  30319. * @param array array to be set.
  30320. * @returns this effect.
  30321. */
  30322. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30323. /**
  30324. * 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)
  30325. * @param uniformName Name of the variable.
  30326. * @param array array to be set.
  30327. * @returns this effect.
  30328. */
  30329. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30330. /**
  30331. * Sets an array on a uniform variable.
  30332. * @param uniformName Name of the variable.
  30333. * @param array array to be set.
  30334. * @returns this effect.
  30335. */
  30336. setArray(uniformName: string, array: number[]): Effect;
  30337. /**
  30338. * 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)
  30339. * @param uniformName Name of the variable.
  30340. * @param array array to be set.
  30341. * @returns this effect.
  30342. */
  30343. setArray2(uniformName: string, array: number[]): Effect;
  30344. /**
  30345. * 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)
  30346. * @param uniformName Name of the variable.
  30347. * @param array array to be set.
  30348. * @returns this effect.
  30349. */
  30350. setArray3(uniformName: string, array: number[]): Effect;
  30351. /**
  30352. * 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)
  30353. * @param uniformName Name of the variable.
  30354. * @param array array to be set.
  30355. * @returns this effect.
  30356. */
  30357. setArray4(uniformName: string, array: number[]): Effect;
  30358. /**
  30359. * Sets matrices on a uniform variable.
  30360. * @param uniformName Name of the variable.
  30361. * @param matrices matrices to be set.
  30362. * @returns this effect.
  30363. */
  30364. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30365. /**
  30366. * Sets matrix on a uniform variable.
  30367. * @param uniformName Name of the variable.
  30368. * @param matrix matrix to be set.
  30369. * @returns this effect.
  30370. */
  30371. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30372. /**
  30373. * 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)
  30374. * @param uniformName Name of the variable.
  30375. * @param matrix matrix to be set.
  30376. * @returns this effect.
  30377. */
  30378. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30379. /**
  30380. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30381. * @param uniformName Name of the variable.
  30382. * @param matrix matrix to be set.
  30383. * @returns this effect.
  30384. */
  30385. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30386. /**
  30387. * Sets a float on a uniform variable.
  30388. * @param uniformName Name of the variable.
  30389. * @param value value to be set.
  30390. * @returns this effect.
  30391. */
  30392. setFloat(uniformName: string, value: number): Effect;
  30393. /**
  30394. * Sets a boolean on a uniform variable.
  30395. * @param uniformName Name of the variable.
  30396. * @param bool value to be set.
  30397. * @returns this effect.
  30398. */
  30399. setBool(uniformName: string, bool: boolean): Effect;
  30400. /**
  30401. * Sets a Vector2 on a uniform variable.
  30402. * @param uniformName Name of the variable.
  30403. * @param vector2 vector2 to be set.
  30404. * @returns this effect.
  30405. */
  30406. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30407. /**
  30408. * Sets a float2 on a uniform variable.
  30409. * @param uniformName Name of the variable.
  30410. * @param x First float in float2.
  30411. * @param y Second float in float2.
  30412. * @returns this effect.
  30413. */
  30414. setFloat2(uniformName: string, x: number, y: number): Effect;
  30415. /**
  30416. * Sets a Vector3 on a uniform variable.
  30417. * @param uniformName Name of the variable.
  30418. * @param vector3 Value to be set.
  30419. * @returns this effect.
  30420. */
  30421. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30422. /**
  30423. * Sets a float3 on a uniform variable.
  30424. * @param uniformName Name of the variable.
  30425. * @param x First float in float3.
  30426. * @param y Second float in float3.
  30427. * @param z Third float in float3.
  30428. * @returns this effect.
  30429. */
  30430. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30431. /**
  30432. * Sets a Vector4 on a uniform variable.
  30433. * @param uniformName Name of the variable.
  30434. * @param vector4 Value to be set.
  30435. * @returns this effect.
  30436. */
  30437. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30438. /**
  30439. * Sets a float4 on a uniform variable.
  30440. * @param uniformName Name of the variable.
  30441. * @param x First float in float4.
  30442. * @param y Second float in float4.
  30443. * @param z Third float in float4.
  30444. * @param w Fourth float in float4.
  30445. * @returns this effect.
  30446. */
  30447. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30448. /**
  30449. * Sets a Color3 on a uniform variable.
  30450. * @param uniformName Name of the variable.
  30451. * @param color3 Value to be set.
  30452. * @returns this effect.
  30453. */
  30454. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30455. /**
  30456. * Sets a Color4 on a uniform variable.
  30457. * @param uniformName Name of the variable.
  30458. * @param color3 Value to be set.
  30459. * @param alpha Alpha value to be set.
  30460. * @returns this effect.
  30461. */
  30462. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30463. /**
  30464. * Sets a Color4 on a uniform variable
  30465. * @param uniformName defines the name of the variable
  30466. * @param color4 defines the value to be set
  30467. * @returns this effect.
  30468. */
  30469. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30470. /** Release all associated resources */
  30471. dispose(): void;
  30472. /**
  30473. * This function will add a new shader to the shader store
  30474. * @param name the name of the shader
  30475. * @param pixelShader optional pixel shader content
  30476. * @param vertexShader optional vertex shader content
  30477. */
  30478. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30479. /**
  30480. * Store of each shader (The can be looked up using effect.key)
  30481. */
  30482. static ShadersStore: {
  30483. [key: string]: string;
  30484. };
  30485. /**
  30486. * Store of each included file for a shader (The can be looked up using effect.key)
  30487. */
  30488. static IncludesShadersStore: {
  30489. [key: string]: string;
  30490. };
  30491. /**
  30492. * Resets the cache of effects.
  30493. */
  30494. static ResetCache(): void;
  30495. }
  30496. }
  30497. declare module BABYLON {
  30498. /**
  30499. * Interface used to describe the capabilities of the engine relatively to the current browser
  30500. */
  30501. export interface EngineCapabilities {
  30502. /** Maximum textures units per fragment shader */
  30503. maxTexturesImageUnits: number;
  30504. /** Maximum texture units per vertex shader */
  30505. maxVertexTextureImageUnits: number;
  30506. /** Maximum textures units in the entire pipeline */
  30507. maxCombinedTexturesImageUnits: number;
  30508. /** Maximum texture size */
  30509. maxTextureSize: number;
  30510. /** Maximum texture samples */
  30511. maxSamples?: number;
  30512. /** Maximum cube texture size */
  30513. maxCubemapTextureSize: number;
  30514. /** Maximum render texture size */
  30515. maxRenderTextureSize: number;
  30516. /** Maximum number of vertex attributes */
  30517. maxVertexAttribs: number;
  30518. /** Maximum number of varyings */
  30519. maxVaryingVectors: number;
  30520. /** Maximum number of uniforms per vertex shader */
  30521. maxVertexUniformVectors: number;
  30522. /** Maximum number of uniforms per fragment shader */
  30523. maxFragmentUniformVectors: number;
  30524. /** Defines if standard derivates (dx/dy) are supported */
  30525. standardDerivatives: boolean;
  30526. /** Defines if s3tc texture compression is supported */
  30527. s3tc?: WEBGL_compressed_texture_s3tc;
  30528. /** Defines if pvrtc texture compression is supported */
  30529. pvrtc: any;
  30530. /** Defines if etc1 texture compression is supported */
  30531. etc1: any;
  30532. /** Defines if etc2 texture compression is supported */
  30533. etc2: any;
  30534. /** Defines if astc texture compression is supported */
  30535. astc: any;
  30536. /** Defines if float textures are supported */
  30537. textureFloat: boolean;
  30538. /** Defines if vertex array objects are supported */
  30539. vertexArrayObject: boolean;
  30540. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30541. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30542. /** Gets the maximum level of anisotropy supported */
  30543. maxAnisotropy: number;
  30544. /** Defines if instancing is supported */
  30545. instancedArrays: boolean;
  30546. /** Defines if 32 bits indices are supported */
  30547. uintIndices: boolean;
  30548. /** Defines if high precision shaders are supported */
  30549. highPrecisionShaderSupported: boolean;
  30550. /** Defines if depth reading in the fragment shader is supported */
  30551. fragmentDepthSupported: boolean;
  30552. /** Defines if float texture linear filtering is supported*/
  30553. textureFloatLinearFiltering: boolean;
  30554. /** Defines if rendering to float textures is supported */
  30555. textureFloatRender: boolean;
  30556. /** Defines if half float textures are supported*/
  30557. textureHalfFloat: boolean;
  30558. /** Defines if half float texture linear filtering is supported*/
  30559. textureHalfFloatLinearFiltering: boolean;
  30560. /** Defines if rendering to half float textures is supported */
  30561. textureHalfFloatRender: boolean;
  30562. /** Defines if textureLOD shader command is supported */
  30563. textureLOD: boolean;
  30564. /** Defines if draw buffers extension is supported */
  30565. drawBuffersExtension: boolean;
  30566. /** Defines if depth textures are supported */
  30567. depthTextureExtension: boolean;
  30568. /** Defines if float color buffer are supported */
  30569. colorBufferFloat: boolean;
  30570. /** Gets disjoint timer query extension (null if not supported) */
  30571. timerQuery?: EXT_disjoint_timer_query;
  30572. /** Defines if timestamp can be used with timer query */
  30573. canUseTimestampForTimerQuery: boolean;
  30574. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30575. multiview?: any;
  30576. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30577. oculusMultiview?: any;
  30578. /** Function used to let the system compiles shaders in background */
  30579. parallelShaderCompile?: {
  30580. COMPLETION_STATUS_KHR: number;
  30581. };
  30582. /** Max number of texture samples for MSAA */
  30583. maxMSAASamples: number;
  30584. /** Defines if the blend min max extension is supported */
  30585. blendMinMax: boolean;
  30586. }
  30587. }
  30588. declare module BABYLON {
  30589. /**
  30590. * @hidden
  30591. **/
  30592. export class DepthCullingState {
  30593. private _isDepthTestDirty;
  30594. private _isDepthMaskDirty;
  30595. private _isDepthFuncDirty;
  30596. private _isCullFaceDirty;
  30597. private _isCullDirty;
  30598. private _isZOffsetDirty;
  30599. private _isFrontFaceDirty;
  30600. private _depthTest;
  30601. private _depthMask;
  30602. private _depthFunc;
  30603. private _cull;
  30604. private _cullFace;
  30605. private _zOffset;
  30606. private _frontFace;
  30607. /**
  30608. * Initializes the state.
  30609. */
  30610. constructor();
  30611. get isDirty(): boolean;
  30612. get zOffset(): number;
  30613. set zOffset(value: number);
  30614. get cullFace(): Nullable<number>;
  30615. set cullFace(value: Nullable<number>);
  30616. get cull(): Nullable<boolean>;
  30617. set cull(value: Nullable<boolean>);
  30618. get depthFunc(): Nullable<number>;
  30619. set depthFunc(value: Nullable<number>);
  30620. get depthMask(): boolean;
  30621. set depthMask(value: boolean);
  30622. get depthTest(): boolean;
  30623. set depthTest(value: boolean);
  30624. get frontFace(): Nullable<number>;
  30625. set frontFace(value: Nullable<number>);
  30626. reset(): void;
  30627. apply(gl: WebGLRenderingContext): void;
  30628. }
  30629. }
  30630. declare module BABYLON {
  30631. /**
  30632. * @hidden
  30633. **/
  30634. export class StencilState {
  30635. /** 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 */
  30636. static readonly ALWAYS: number;
  30637. /** Passed to stencilOperation to specify that stencil value must be kept */
  30638. static readonly KEEP: number;
  30639. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30640. static readonly REPLACE: number;
  30641. private _isStencilTestDirty;
  30642. private _isStencilMaskDirty;
  30643. private _isStencilFuncDirty;
  30644. private _isStencilOpDirty;
  30645. private _stencilTest;
  30646. private _stencilMask;
  30647. private _stencilFunc;
  30648. private _stencilFuncRef;
  30649. private _stencilFuncMask;
  30650. private _stencilOpStencilFail;
  30651. private _stencilOpDepthFail;
  30652. private _stencilOpStencilDepthPass;
  30653. get isDirty(): boolean;
  30654. get stencilFunc(): number;
  30655. set stencilFunc(value: number);
  30656. get stencilFuncRef(): number;
  30657. set stencilFuncRef(value: number);
  30658. get stencilFuncMask(): number;
  30659. set stencilFuncMask(value: number);
  30660. get stencilOpStencilFail(): number;
  30661. set stencilOpStencilFail(value: number);
  30662. get stencilOpDepthFail(): number;
  30663. set stencilOpDepthFail(value: number);
  30664. get stencilOpStencilDepthPass(): number;
  30665. set stencilOpStencilDepthPass(value: number);
  30666. get stencilMask(): number;
  30667. set stencilMask(value: number);
  30668. get stencilTest(): boolean;
  30669. set stencilTest(value: boolean);
  30670. constructor();
  30671. reset(): void;
  30672. apply(gl: WebGLRenderingContext): void;
  30673. }
  30674. }
  30675. declare module BABYLON {
  30676. /**
  30677. * @hidden
  30678. **/
  30679. export class AlphaState {
  30680. private _isAlphaBlendDirty;
  30681. private _isBlendFunctionParametersDirty;
  30682. private _isBlendEquationParametersDirty;
  30683. private _isBlendConstantsDirty;
  30684. private _alphaBlend;
  30685. private _blendFunctionParameters;
  30686. private _blendEquationParameters;
  30687. private _blendConstants;
  30688. /**
  30689. * Initializes the state.
  30690. */
  30691. constructor();
  30692. get isDirty(): boolean;
  30693. get alphaBlend(): boolean;
  30694. set alphaBlend(value: boolean);
  30695. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30696. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30697. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30698. reset(): void;
  30699. apply(gl: WebGLRenderingContext): void;
  30700. }
  30701. }
  30702. declare module BABYLON {
  30703. /** @hidden */
  30704. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30705. attributeProcessor(attribute: string): string;
  30706. varyingProcessor(varying: string, isFragment: boolean): string;
  30707. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30708. }
  30709. }
  30710. declare module BABYLON {
  30711. /**
  30712. * Interface for attribute information associated with buffer instanciation
  30713. */
  30714. export interface InstancingAttributeInfo {
  30715. /**
  30716. * Name of the GLSL attribute
  30717. * if attribute index is not specified, this is used to retrieve the index from the effect
  30718. */
  30719. attributeName: string;
  30720. /**
  30721. * Index/offset of the attribute in the vertex shader
  30722. * if not specified, this will be computes from the name.
  30723. */
  30724. index?: number;
  30725. /**
  30726. * size of the attribute, 1, 2, 3 or 4
  30727. */
  30728. attributeSize: number;
  30729. /**
  30730. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30731. */
  30732. offset: number;
  30733. /**
  30734. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30735. * default to 1
  30736. */
  30737. divisor?: number;
  30738. /**
  30739. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30740. * default is FLOAT
  30741. */
  30742. attributeType?: number;
  30743. /**
  30744. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30745. */
  30746. normalized?: boolean;
  30747. }
  30748. }
  30749. declare module BABYLON {
  30750. interface ThinEngine {
  30751. /**
  30752. * Update a video texture
  30753. * @param texture defines the texture to update
  30754. * @param video defines the video element to use
  30755. * @param invertY defines if data must be stored with Y axis inverted
  30756. */
  30757. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30758. }
  30759. }
  30760. declare module BABYLON {
  30761. /**
  30762. * Settings for finer control over video usage
  30763. */
  30764. export interface VideoTextureSettings {
  30765. /**
  30766. * Applies `autoplay` to video, if specified
  30767. */
  30768. autoPlay?: boolean;
  30769. /**
  30770. * Applies `loop` to video, if specified
  30771. */
  30772. loop?: boolean;
  30773. /**
  30774. * Automatically updates internal texture from video at every frame in the render loop
  30775. */
  30776. autoUpdateTexture: boolean;
  30777. /**
  30778. * Image src displayed during the video loading or until the user interacts with the video.
  30779. */
  30780. poster?: string;
  30781. }
  30782. /**
  30783. * If you want to display a video in your scene, this is the special texture for that.
  30784. * This special texture works similar to other textures, with the exception of a few parameters.
  30785. * @see https://doc.babylonjs.com/how_to/video_texture
  30786. */
  30787. export class VideoTexture extends Texture {
  30788. /**
  30789. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30790. */
  30791. readonly autoUpdateTexture: boolean;
  30792. /**
  30793. * The video instance used by the texture internally
  30794. */
  30795. readonly video: HTMLVideoElement;
  30796. private _onUserActionRequestedObservable;
  30797. /**
  30798. * Event triggerd when a dom action is required by the user to play the video.
  30799. * This happens due to recent changes in browser policies preventing video to auto start.
  30800. */
  30801. get onUserActionRequestedObservable(): Observable<Texture>;
  30802. private _generateMipMaps;
  30803. private _engine;
  30804. private _stillImageCaptured;
  30805. private _displayingPosterTexture;
  30806. private _settings;
  30807. private _createInternalTextureOnEvent;
  30808. private _frameId;
  30809. private _currentSrc;
  30810. /**
  30811. * Creates a video texture.
  30812. * If you want to display a video in your scene, this is the special texture for that.
  30813. * This special texture works similar to other textures, with the exception of a few parameters.
  30814. * @see https://doc.babylonjs.com/how_to/video_texture
  30815. * @param name optional name, will detect from video source, if not defined
  30816. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30817. * @param scene is obviously the current scene.
  30818. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30819. * @param invertY is false by default but can be used to invert video on Y axis
  30820. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30821. * @param settings allows finer control over video usage
  30822. */
  30823. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30824. private _getName;
  30825. private _getVideo;
  30826. private _createInternalTexture;
  30827. private reset;
  30828. /**
  30829. * @hidden Internal method to initiate `update`.
  30830. */
  30831. _rebuild(): void;
  30832. /**
  30833. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30834. */
  30835. update(): void;
  30836. /**
  30837. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30838. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30839. */
  30840. updateTexture(isVisible: boolean): void;
  30841. protected _updateInternalTexture: () => void;
  30842. /**
  30843. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30844. * @param url New url.
  30845. */
  30846. updateURL(url: string): void;
  30847. /**
  30848. * Clones the texture.
  30849. * @returns the cloned texture
  30850. */
  30851. clone(): VideoTexture;
  30852. /**
  30853. * Dispose the texture and release its associated resources.
  30854. */
  30855. dispose(): void;
  30856. /**
  30857. * Creates a video texture straight from a stream.
  30858. * @param scene Define the scene the texture should be created in
  30859. * @param stream Define the stream the texture should be created from
  30860. * @returns The created video texture as a promise
  30861. */
  30862. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30863. /**
  30864. * Creates a video texture straight from your WebCam video feed.
  30865. * @param scene Define the scene the texture should be created in
  30866. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30867. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30868. * @returns The created video texture as a promise
  30869. */
  30870. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30871. minWidth: number;
  30872. maxWidth: number;
  30873. minHeight: number;
  30874. maxHeight: number;
  30875. deviceId: string;
  30876. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30877. /**
  30878. * Creates a video texture straight from your WebCam video feed.
  30879. * @param scene Define the scene the texture should be created in
  30880. * @param onReady Define a callback to triggered once the texture will be ready
  30881. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30882. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30883. */
  30884. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30885. minWidth: number;
  30886. maxWidth: number;
  30887. minHeight: number;
  30888. maxHeight: number;
  30889. deviceId: string;
  30890. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30891. }
  30892. }
  30893. declare module BABYLON {
  30894. /**
  30895. * Defines the interface used by objects working like Scene
  30896. * @hidden
  30897. */
  30898. export interface ISceneLike {
  30899. _addPendingData(data: any): void;
  30900. _removePendingData(data: any): void;
  30901. offlineProvider: IOfflineProvider;
  30902. }
  30903. /** Interface defining initialization parameters for Engine class */
  30904. export interface EngineOptions extends WebGLContextAttributes {
  30905. /**
  30906. * Defines if the engine should no exceed a specified device ratio
  30907. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30908. */
  30909. limitDeviceRatio?: number;
  30910. /**
  30911. * Defines if webvr should be enabled automatically
  30912. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30913. */
  30914. autoEnableWebVR?: boolean;
  30915. /**
  30916. * Defines if webgl2 should be turned off even if supported
  30917. * @see http://doc.babylonjs.com/features/webgl2
  30918. */
  30919. disableWebGL2Support?: boolean;
  30920. /**
  30921. * Defines if webaudio should be initialized as well
  30922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30923. */
  30924. audioEngine?: boolean;
  30925. /**
  30926. * Defines if animations should run using a deterministic lock step
  30927. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30928. */
  30929. deterministicLockstep?: boolean;
  30930. /** Defines the maximum steps to use with deterministic lock step mode */
  30931. lockstepMaxSteps?: number;
  30932. /** Defines the seconds between each deterministic lock step */
  30933. timeStep?: number;
  30934. /**
  30935. * Defines that engine should ignore context lost events
  30936. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30937. */
  30938. doNotHandleContextLost?: boolean;
  30939. /**
  30940. * Defines that engine should ignore modifying touch action attribute and style
  30941. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30942. */
  30943. doNotHandleTouchAction?: boolean;
  30944. /**
  30945. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30946. */
  30947. useHighPrecisionFloats?: boolean;
  30948. }
  30949. /**
  30950. * The base engine class (root of all engines)
  30951. */
  30952. export class ThinEngine {
  30953. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30954. static ExceptionList: ({
  30955. key: string;
  30956. capture: string;
  30957. captureConstraint: number;
  30958. targets: string[];
  30959. } | {
  30960. key: string;
  30961. capture: null;
  30962. captureConstraint: null;
  30963. targets: string[];
  30964. })[];
  30965. /** @hidden */
  30966. static _TextureLoaders: IInternalTextureLoader[];
  30967. /**
  30968. * Returns the current npm package of the sdk
  30969. */
  30970. static get NpmPackage(): string;
  30971. /**
  30972. * Returns the current version of the framework
  30973. */
  30974. static get Version(): string;
  30975. /**
  30976. * Returns a string describing the current engine
  30977. */
  30978. get description(): string;
  30979. /**
  30980. * Gets or sets the epsilon value used by collision engine
  30981. */
  30982. static CollisionsEpsilon: number;
  30983. /**
  30984. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30985. */
  30986. static get ShadersRepository(): string;
  30987. static set ShadersRepository(value: string);
  30988. /** @hidden */
  30989. _shaderProcessor: IShaderProcessor;
  30990. /**
  30991. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30992. */
  30993. forcePOTTextures: boolean;
  30994. /**
  30995. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30996. */
  30997. isFullscreen: boolean;
  30998. /**
  30999. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31000. */
  31001. cullBackFaces: boolean;
  31002. /**
  31003. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31004. */
  31005. renderEvenInBackground: boolean;
  31006. /**
  31007. * Gets or sets a boolean indicating that cache can be kept between frames
  31008. */
  31009. preventCacheWipeBetweenFrames: boolean;
  31010. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31011. validateShaderPrograms: boolean;
  31012. /**
  31013. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31014. * This can provide greater z depth for distant objects.
  31015. */
  31016. useReverseDepthBuffer: boolean;
  31017. /**
  31018. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31019. */
  31020. disableUniformBuffers: boolean;
  31021. /** @hidden */
  31022. _uniformBuffers: UniformBuffer[];
  31023. /**
  31024. * Gets a boolean indicating that the engine supports uniform buffers
  31025. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31026. */
  31027. get supportsUniformBuffers(): boolean;
  31028. /** @hidden */
  31029. _gl: WebGLRenderingContext;
  31030. /** @hidden */
  31031. _webGLVersion: number;
  31032. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31033. protected _windowIsBackground: boolean;
  31034. protected _creationOptions: EngineOptions;
  31035. protected _highPrecisionShadersAllowed: boolean;
  31036. /** @hidden */
  31037. get _shouldUseHighPrecisionShader(): boolean;
  31038. /**
  31039. * Gets a boolean indicating that only power of 2 textures are supported
  31040. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31041. */
  31042. get needPOTTextures(): boolean;
  31043. /** @hidden */
  31044. _badOS: boolean;
  31045. /** @hidden */
  31046. _badDesktopOS: boolean;
  31047. private _hardwareScalingLevel;
  31048. /** @hidden */
  31049. _caps: EngineCapabilities;
  31050. private _isStencilEnable;
  31051. private _glVersion;
  31052. private _glRenderer;
  31053. private _glVendor;
  31054. /** @hidden */
  31055. _videoTextureSupported: boolean;
  31056. protected _renderingQueueLaunched: boolean;
  31057. protected _activeRenderLoops: (() => void)[];
  31058. /**
  31059. * Observable signaled when a context lost event is raised
  31060. */
  31061. onContextLostObservable: Observable<ThinEngine>;
  31062. /**
  31063. * Observable signaled when a context restored event is raised
  31064. */
  31065. onContextRestoredObservable: Observable<ThinEngine>;
  31066. private _onContextLost;
  31067. private _onContextRestored;
  31068. protected _contextWasLost: boolean;
  31069. /** @hidden */
  31070. _doNotHandleContextLost: boolean;
  31071. /**
  31072. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31073. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31074. */
  31075. get doNotHandleContextLost(): boolean;
  31076. set doNotHandleContextLost(value: boolean);
  31077. /**
  31078. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31079. */
  31080. disableVertexArrayObjects: boolean;
  31081. /** @hidden */
  31082. protected _colorWrite: boolean;
  31083. /** @hidden */
  31084. protected _colorWriteChanged: boolean;
  31085. /** @hidden */
  31086. protected _depthCullingState: DepthCullingState;
  31087. /** @hidden */
  31088. protected _stencilState: StencilState;
  31089. /** @hidden */
  31090. _alphaState: AlphaState;
  31091. /** @hidden */
  31092. _alphaMode: number;
  31093. /** @hidden */
  31094. _alphaEquation: number;
  31095. /** @hidden */
  31096. _internalTexturesCache: InternalTexture[];
  31097. /** @hidden */
  31098. protected _activeChannel: number;
  31099. private _currentTextureChannel;
  31100. /** @hidden */
  31101. protected _boundTexturesCache: {
  31102. [key: string]: Nullable<InternalTexture>;
  31103. };
  31104. /** @hidden */
  31105. protected _currentEffect: Nullable<Effect>;
  31106. /** @hidden */
  31107. protected _currentProgram: Nullable<WebGLProgram>;
  31108. private _compiledEffects;
  31109. private _vertexAttribArraysEnabled;
  31110. /** @hidden */
  31111. protected _cachedViewport: Nullable<IViewportLike>;
  31112. private _cachedVertexArrayObject;
  31113. /** @hidden */
  31114. protected _cachedVertexBuffers: any;
  31115. /** @hidden */
  31116. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31117. /** @hidden */
  31118. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31119. /** @hidden */
  31120. _currentRenderTarget: Nullable<InternalTexture>;
  31121. private _uintIndicesCurrentlySet;
  31122. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31123. /** @hidden */
  31124. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31125. private _currentBufferPointers;
  31126. private _currentInstanceLocations;
  31127. private _currentInstanceBuffers;
  31128. private _textureUnits;
  31129. /** @hidden */
  31130. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31131. /** @hidden */
  31132. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31133. /** @hidden */
  31134. _boundRenderFunction: any;
  31135. private _vaoRecordInProgress;
  31136. private _mustWipeVertexAttributes;
  31137. private _emptyTexture;
  31138. private _emptyCubeTexture;
  31139. private _emptyTexture3D;
  31140. private _emptyTexture2DArray;
  31141. /** @hidden */
  31142. _frameHandler: number;
  31143. private _nextFreeTextureSlots;
  31144. private _maxSimultaneousTextures;
  31145. private _activeRequests;
  31146. protected _texturesSupported: string[];
  31147. /** @hidden */
  31148. _textureFormatInUse: Nullable<string>;
  31149. protected get _supportsHardwareTextureRescaling(): boolean;
  31150. private _framebufferDimensionsObject;
  31151. /**
  31152. * sets the object from which width and height will be taken from when getting render width and height
  31153. * Will fallback to the gl object
  31154. * @param dimensions the framebuffer width and height that will be used.
  31155. */
  31156. set framebufferDimensionsObject(dimensions: Nullable<{
  31157. framebufferWidth: number;
  31158. framebufferHeight: number;
  31159. }>);
  31160. /**
  31161. * Gets the list of texture formats supported
  31162. */
  31163. get texturesSupported(): Array<string>;
  31164. /**
  31165. * Gets the list of texture formats in use
  31166. */
  31167. get textureFormatInUse(): Nullable<string>;
  31168. /**
  31169. * Gets the current viewport
  31170. */
  31171. get currentViewport(): Nullable<IViewportLike>;
  31172. /**
  31173. * Gets the default empty texture
  31174. */
  31175. get emptyTexture(): InternalTexture;
  31176. /**
  31177. * Gets the default empty 3D texture
  31178. */
  31179. get emptyTexture3D(): InternalTexture;
  31180. /**
  31181. * Gets the default empty 2D array texture
  31182. */
  31183. get emptyTexture2DArray(): InternalTexture;
  31184. /**
  31185. * Gets the default empty cube texture
  31186. */
  31187. get emptyCubeTexture(): InternalTexture;
  31188. /**
  31189. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31190. */
  31191. readonly premultipliedAlpha: boolean;
  31192. /**
  31193. * Observable event triggered before each texture is initialized
  31194. */
  31195. onBeforeTextureInitObservable: Observable<Texture>;
  31196. /**
  31197. * Creates a new engine
  31198. * @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
  31199. * @param antialias defines enable antialiasing (default: false)
  31200. * @param options defines further options to be sent to the getContext() function
  31201. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31202. */
  31203. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31204. private _rebuildInternalTextures;
  31205. private _rebuildEffects;
  31206. /**
  31207. * Gets a boolean indicating if all created effects are ready
  31208. * @returns true if all effects are ready
  31209. */
  31210. areAllEffectsReady(): boolean;
  31211. protected _rebuildBuffers(): void;
  31212. private _initGLContext;
  31213. /**
  31214. * Gets version of the current webGL context
  31215. */
  31216. get webGLVersion(): number;
  31217. /**
  31218. * Gets a string idenfifying the name of the class
  31219. * @returns "Engine" string
  31220. */
  31221. getClassName(): string;
  31222. /**
  31223. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31224. */
  31225. get isStencilEnable(): boolean;
  31226. /** @hidden */
  31227. _prepareWorkingCanvas(): void;
  31228. /**
  31229. * Reset the texture cache to empty state
  31230. */
  31231. resetTextureCache(): void;
  31232. /**
  31233. * Gets an object containing information about the current webGL context
  31234. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31235. */
  31236. getGlInfo(): {
  31237. vendor: string;
  31238. renderer: string;
  31239. version: string;
  31240. };
  31241. /**
  31242. * Defines the hardware scaling level.
  31243. * By default the hardware scaling level is computed from the window device ratio.
  31244. * 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.
  31245. * @param level defines the level to use
  31246. */
  31247. setHardwareScalingLevel(level: number): void;
  31248. /**
  31249. * Gets the current hardware scaling level.
  31250. * By default the hardware scaling level is computed from the window device ratio.
  31251. * 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.
  31252. * @returns a number indicating the current hardware scaling level
  31253. */
  31254. getHardwareScalingLevel(): number;
  31255. /**
  31256. * Gets the list of loaded textures
  31257. * @returns an array containing all loaded textures
  31258. */
  31259. getLoadedTexturesCache(): InternalTexture[];
  31260. /**
  31261. * Gets the object containing all engine capabilities
  31262. * @returns the EngineCapabilities object
  31263. */
  31264. getCaps(): EngineCapabilities;
  31265. /**
  31266. * stop executing a render loop function and remove it from the execution array
  31267. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31268. */
  31269. stopRenderLoop(renderFunction?: () => void): void;
  31270. /** @hidden */
  31271. _renderLoop(): void;
  31272. /**
  31273. * Gets the HTML canvas attached with the current webGL context
  31274. * @returns a HTML canvas
  31275. */
  31276. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31277. /**
  31278. * Gets host window
  31279. * @returns the host window object
  31280. */
  31281. getHostWindow(): Nullable<Window>;
  31282. /**
  31283. * Gets the current render width
  31284. * @param useScreen defines if screen size must be used (or the current render target if any)
  31285. * @returns a number defining the current render width
  31286. */
  31287. getRenderWidth(useScreen?: boolean): number;
  31288. /**
  31289. * Gets the current render height
  31290. * @param useScreen defines if screen size must be used (or the current render target if any)
  31291. * @returns a number defining the current render height
  31292. */
  31293. getRenderHeight(useScreen?: boolean): number;
  31294. /**
  31295. * Can be used to override the current requestAnimationFrame requester.
  31296. * @hidden
  31297. */
  31298. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31299. /**
  31300. * Register and execute a render loop. The engine can have more than one render function
  31301. * @param renderFunction defines the function to continuously execute
  31302. */
  31303. runRenderLoop(renderFunction: () => void): void;
  31304. /**
  31305. * Clear the current render buffer or the current render target (if any is set up)
  31306. * @param color defines the color to use
  31307. * @param backBuffer defines if the back buffer must be cleared
  31308. * @param depth defines if the depth buffer must be cleared
  31309. * @param stencil defines if the stencil buffer must be cleared
  31310. */
  31311. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31312. private _viewportCached;
  31313. /** @hidden */
  31314. _viewport(x: number, y: number, width: number, height: number): void;
  31315. /**
  31316. * Set the WebGL's viewport
  31317. * @param viewport defines the viewport element to be used
  31318. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31319. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31320. */
  31321. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31322. /**
  31323. * Begin a new frame
  31324. */
  31325. beginFrame(): void;
  31326. /**
  31327. * Enf the current frame
  31328. */
  31329. endFrame(): void;
  31330. /**
  31331. * Resize the view according to the canvas' size
  31332. */
  31333. resize(): void;
  31334. /**
  31335. * Force a specific size of the canvas
  31336. * @param width defines the new canvas' width
  31337. * @param height defines the new canvas' height
  31338. */
  31339. setSize(width: number, height: number): void;
  31340. /**
  31341. * Binds the frame buffer to the specified texture.
  31342. * @param texture The texture to render to or null for the default canvas
  31343. * @param faceIndex The face of the texture to render to in case of cube texture
  31344. * @param requiredWidth The width of the target to render to
  31345. * @param requiredHeight The height of the target to render to
  31346. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31347. * @param lodLevel defines the lod level to bind to the frame buffer
  31348. * @param layer defines the 2d array index to bind to frame buffer to
  31349. */
  31350. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31351. /** @hidden */
  31352. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31353. /**
  31354. * Unbind the current render target texture from the webGL context
  31355. * @param texture defines the render target texture to unbind
  31356. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31357. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31358. */
  31359. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31360. /**
  31361. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31362. */
  31363. flushFramebuffer(): void;
  31364. /**
  31365. * Unbind the current render target and bind the default framebuffer
  31366. */
  31367. restoreDefaultFramebuffer(): void;
  31368. /** @hidden */
  31369. protected _resetVertexBufferBinding(): void;
  31370. /**
  31371. * Creates a vertex buffer
  31372. * @param data the data for the vertex buffer
  31373. * @returns the new WebGL static buffer
  31374. */
  31375. createVertexBuffer(data: DataArray): DataBuffer;
  31376. private _createVertexBuffer;
  31377. /**
  31378. * Creates a dynamic vertex buffer
  31379. * @param data the data for the dynamic vertex buffer
  31380. * @returns the new WebGL dynamic buffer
  31381. */
  31382. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31383. protected _resetIndexBufferBinding(): void;
  31384. /**
  31385. * Creates a new index buffer
  31386. * @param indices defines the content of the index buffer
  31387. * @param updatable defines if the index buffer must be updatable
  31388. * @returns a new webGL buffer
  31389. */
  31390. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31391. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31392. /**
  31393. * Bind a webGL buffer to the webGL context
  31394. * @param buffer defines the buffer to bind
  31395. */
  31396. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31397. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31398. private bindBuffer;
  31399. /**
  31400. * update the bound buffer with the given data
  31401. * @param data defines the data to update
  31402. */
  31403. updateArrayBuffer(data: Float32Array): void;
  31404. private _vertexAttribPointer;
  31405. /** @hidden */
  31406. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31407. private _bindVertexBuffersAttributes;
  31408. /**
  31409. * Records a vertex array object
  31410. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31411. * @param vertexBuffers defines the list of vertex buffers to store
  31412. * @param indexBuffer defines the index buffer to store
  31413. * @param effect defines the effect to store
  31414. * @returns the new vertex array object
  31415. */
  31416. recordVertexArrayObject(vertexBuffers: {
  31417. [key: string]: VertexBuffer;
  31418. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31419. /**
  31420. * Bind a specific vertex array object
  31421. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31422. * @param vertexArrayObject defines the vertex array object to bind
  31423. * @param indexBuffer defines the index buffer to bind
  31424. */
  31425. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31426. /**
  31427. * Bind webGl buffers directly to the webGL context
  31428. * @param vertexBuffer defines the vertex buffer to bind
  31429. * @param indexBuffer defines the index buffer to bind
  31430. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31431. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31432. * @param effect defines the effect associated with the vertex buffer
  31433. */
  31434. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31435. private _unbindVertexArrayObject;
  31436. /**
  31437. * Bind a list of vertex buffers to the webGL context
  31438. * @param vertexBuffers defines the list of vertex buffers to bind
  31439. * @param indexBuffer defines the index buffer to bind
  31440. * @param effect defines the effect associated with the vertex buffers
  31441. */
  31442. bindBuffers(vertexBuffers: {
  31443. [key: string]: Nullable<VertexBuffer>;
  31444. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31445. /**
  31446. * Unbind all instance attributes
  31447. */
  31448. unbindInstanceAttributes(): void;
  31449. /**
  31450. * Release and free the memory of a vertex array object
  31451. * @param vao defines the vertex array object to delete
  31452. */
  31453. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31454. /** @hidden */
  31455. _releaseBuffer(buffer: DataBuffer): boolean;
  31456. protected _deleteBuffer(buffer: DataBuffer): void;
  31457. /**
  31458. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31459. * @param instancesBuffer defines the webGL buffer to update and bind
  31460. * @param data defines the data to store in the buffer
  31461. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31462. */
  31463. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31464. /**
  31465. * Bind the content of a webGL buffer used with instantiation
  31466. * @param instancesBuffer defines the webGL buffer to bind
  31467. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31468. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31469. */
  31470. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31471. /**
  31472. * Disable the instance attribute corresponding to the name in parameter
  31473. * @param name defines the name of the attribute to disable
  31474. */
  31475. disableInstanceAttributeByName(name: string): void;
  31476. /**
  31477. * Disable the instance attribute corresponding to the location in parameter
  31478. * @param attributeLocation defines the attribute location of the attribute to disable
  31479. */
  31480. disableInstanceAttribute(attributeLocation: number): void;
  31481. /**
  31482. * Disable the attribute corresponding to the location in parameter
  31483. * @param attributeLocation defines the attribute location of the attribute to disable
  31484. */
  31485. disableAttributeByIndex(attributeLocation: number): void;
  31486. /**
  31487. * Send a draw order
  31488. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31489. * @param indexStart defines the starting index
  31490. * @param indexCount defines the number of index to draw
  31491. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31492. */
  31493. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31494. /**
  31495. * Draw a list of points
  31496. * @param verticesStart defines the index of first vertex to draw
  31497. * @param verticesCount defines the count of vertices to draw
  31498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31499. */
  31500. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31501. /**
  31502. * Draw a list of unindexed primitives
  31503. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31504. * @param verticesStart defines the index of first vertex to draw
  31505. * @param verticesCount defines the count of vertices to draw
  31506. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31507. */
  31508. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31509. /**
  31510. * Draw a list of indexed primitives
  31511. * @param fillMode defines the primitive to use
  31512. * @param indexStart defines the starting index
  31513. * @param indexCount defines the number of index to draw
  31514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31515. */
  31516. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31517. /**
  31518. * Draw a list of unindexed primitives
  31519. * @param fillMode defines the primitive to use
  31520. * @param verticesStart defines the index of first vertex to draw
  31521. * @param verticesCount defines the count of vertices to draw
  31522. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31523. */
  31524. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31525. private _drawMode;
  31526. /** @hidden */
  31527. protected _reportDrawCall(): void;
  31528. /** @hidden */
  31529. _releaseEffect(effect: Effect): void;
  31530. /** @hidden */
  31531. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31532. /**
  31533. * Create a new effect (used to store vertex/fragment shaders)
  31534. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31535. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31536. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31537. * @param samplers defines an array of string used to represent textures
  31538. * @param defines defines the string containing the defines to use to compile the shaders
  31539. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31540. * @param onCompiled defines a function to call when the effect creation is successful
  31541. * @param onError defines a function to call when the effect creation has failed
  31542. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31543. * @returns the new Effect
  31544. */
  31545. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31546. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31547. private _compileShader;
  31548. private _compileRawShader;
  31549. /** @hidden */
  31550. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31551. /**
  31552. * Directly creates a webGL program
  31553. * @param pipelineContext defines the pipeline context to attach to
  31554. * @param vertexCode defines the vertex shader code to use
  31555. * @param fragmentCode defines the fragment shader code to use
  31556. * @param context defines the webGL context to use (if not set, the current one will be used)
  31557. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31558. * @returns the new webGL program
  31559. */
  31560. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31561. /**
  31562. * Creates a webGL program
  31563. * @param pipelineContext defines the pipeline context to attach to
  31564. * @param vertexCode defines the vertex shader code to use
  31565. * @param fragmentCode defines the fragment shader code to use
  31566. * @param defines defines the string containing the defines to use to compile the shaders
  31567. * @param context defines the webGL context to use (if not set, the current one will be used)
  31568. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31569. * @returns the new webGL program
  31570. */
  31571. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31572. /**
  31573. * Creates a new pipeline context
  31574. * @returns the new pipeline
  31575. */
  31576. createPipelineContext(): IPipelineContext;
  31577. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31578. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31579. /** @hidden */
  31580. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31581. /** @hidden */
  31582. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31583. /** @hidden */
  31584. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31585. /**
  31586. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31587. * @param pipelineContext defines the pipeline context to use
  31588. * @param uniformsNames defines the list of uniform names
  31589. * @returns an array of webGL uniform locations
  31590. */
  31591. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31592. /**
  31593. * Gets the lsit of active attributes for a given webGL program
  31594. * @param pipelineContext defines the pipeline context to use
  31595. * @param attributesNames defines the list of attribute names to get
  31596. * @returns an array of indices indicating the offset of each attribute
  31597. */
  31598. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31599. /**
  31600. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31601. * @param effect defines the effect to activate
  31602. */
  31603. enableEffect(effect: Nullable<Effect>): void;
  31604. /**
  31605. * Set the value of an uniform to a number (int)
  31606. * @param uniform defines the webGL uniform location where to store the value
  31607. * @param value defines the int number to store
  31608. */
  31609. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31610. /**
  31611. * Set the value of an uniform to an array of int32
  31612. * @param uniform defines the webGL uniform location where to store the value
  31613. * @param array defines the array of int32 to store
  31614. */
  31615. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31616. /**
  31617. * Set the value of an uniform to an array of int32 (stored as vec2)
  31618. * @param uniform defines the webGL uniform location where to store the value
  31619. * @param array defines the array of int32 to store
  31620. */
  31621. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31622. /**
  31623. * Set the value of an uniform to an array of int32 (stored as vec3)
  31624. * @param uniform defines the webGL uniform location where to store the value
  31625. * @param array defines the array of int32 to store
  31626. */
  31627. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31628. /**
  31629. * Set the value of an uniform to an array of int32 (stored as vec4)
  31630. * @param uniform defines the webGL uniform location where to store the value
  31631. * @param array defines the array of int32 to store
  31632. */
  31633. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31634. /**
  31635. * Set the value of an uniform to an array of number
  31636. * @param uniform defines the webGL uniform location where to store the value
  31637. * @param array defines the array of number to store
  31638. */
  31639. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31640. /**
  31641. * Set the value of an uniform to an array of number (stored as vec2)
  31642. * @param uniform defines the webGL uniform location where to store the value
  31643. * @param array defines the array of number to store
  31644. */
  31645. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31646. /**
  31647. * Set the value of an uniform to an array of number (stored as vec3)
  31648. * @param uniform defines the webGL uniform location where to store the value
  31649. * @param array defines the array of number to store
  31650. */
  31651. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31652. /**
  31653. * Set the value of an uniform to an array of number (stored as vec4)
  31654. * @param uniform defines the webGL uniform location where to store the value
  31655. * @param array defines the array of number to store
  31656. */
  31657. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31658. /**
  31659. * Set the value of an uniform to an array of float32 (stored as matrices)
  31660. * @param uniform defines the webGL uniform location where to store the value
  31661. * @param matrices defines the array of float32 to store
  31662. */
  31663. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31664. /**
  31665. * Set the value of an uniform to a matrix (3x3)
  31666. * @param uniform defines the webGL uniform location where to store the value
  31667. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31668. */
  31669. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31670. /**
  31671. * Set the value of an uniform to a matrix (2x2)
  31672. * @param uniform defines the webGL uniform location where to store the value
  31673. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31674. */
  31675. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31676. /**
  31677. * Set the value of an uniform to a number (float)
  31678. * @param uniform defines the webGL uniform location where to store the value
  31679. * @param value defines the float number to store
  31680. */
  31681. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31682. /**
  31683. * Set the value of an uniform to a vec2
  31684. * @param uniform defines the webGL uniform location where to store the value
  31685. * @param x defines the 1st component of the value
  31686. * @param y defines the 2nd component of the value
  31687. */
  31688. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31689. /**
  31690. * Set the value of an uniform to a vec3
  31691. * @param uniform defines the webGL uniform location where to store the value
  31692. * @param x defines the 1st component of the value
  31693. * @param y defines the 2nd component of the value
  31694. * @param z defines the 3rd component of the value
  31695. */
  31696. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31697. /**
  31698. * Set the value of an uniform to a vec4
  31699. * @param uniform defines the webGL uniform location where to store the value
  31700. * @param x defines the 1st component of the value
  31701. * @param y defines the 2nd component of the value
  31702. * @param z defines the 3rd component of the value
  31703. * @param w defines the 4th component of the value
  31704. */
  31705. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31706. /**
  31707. * Apply all cached states (depth, culling, stencil and alpha)
  31708. */
  31709. applyStates(): void;
  31710. /**
  31711. * Enable or disable color writing
  31712. * @param enable defines the state to set
  31713. */
  31714. setColorWrite(enable: boolean): void;
  31715. /**
  31716. * Gets a boolean indicating if color writing is enabled
  31717. * @returns the current color writing state
  31718. */
  31719. getColorWrite(): boolean;
  31720. /**
  31721. * Gets the depth culling state manager
  31722. */
  31723. get depthCullingState(): DepthCullingState;
  31724. /**
  31725. * Gets the alpha state manager
  31726. */
  31727. get alphaState(): AlphaState;
  31728. /**
  31729. * Gets the stencil state manager
  31730. */
  31731. get stencilState(): StencilState;
  31732. /**
  31733. * Clears the list of texture accessible through engine.
  31734. * This can help preventing texture load conflict due to name collision.
  31735. */
  31736. clearInternalTexturesCache(): void;
  31737. /**
  31738. * Force the entire cache to be cleared
  31739. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31740. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31741. */
  31742. wipeCaches(bruteForce?: boolean): void;
  31743. /** @hidden */
  31744. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31745. min: number;
  31746. mag: number;
  31747. };
  31748. /** @hidden */
  31749. _createTexture(): WebGLTexture;
  31750. /**
  31751. * Usually called from Texture.ts.
  31752. * Passed information to create a WebGLTexture
  31753. * @param urlArg defines a value which contains one of the following:
  31754. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31755. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31756. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31758. * @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)
  31759. * @param scene needed for loading to the correct scene
  31760. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31761. * @param onLoad optional callback to be called upon successful completion
  31762. * @param onError optional callback to be called upon failure
  31763. * @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
  31764. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31765. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31766. * @param forcedExtension defines the extension to use to pick the right loader
  31767. * @param mimeType defines an optional mime type
  31768. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31769. */
  31770. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  31771. /**
  31772. * Loads an image as an HTMLImageElement.
  31773. * @param input url string, ArrayBuffer, or Blob to load
  31774. * @param onLoad callback called when the image successfully loads
  31775. * @param onError callback called when the image fails to load
  31776. * @param offlineProvider offline provider for caching
  31777. * @param mimeType optional mime type
  31778. * @returns the HTMLImageElement of the loaded image
  31779. * @hidden
  31780. */
  31781. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31782. /**
  31783. * @hidden
  31784. */
  31785. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31786. /**
  31787. * Creates a raw texture
  31788. * @param data defines the data to store in the texture
  31789. * @param width defines the width of the texture
  31790. * @param height defines the height of the texture
  31791. * @param format defines the format of the data
  31792. * @param generateMipMaps defines if the engine should generate the mip levels
  31793. * @param invertY defines if data must be stored with Y axis inverted
  31794. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31795. * @param compression defines the compression used (null by default)
  31796. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31797. * @returns the raw texture inside an InternalTexture
  31798. */
  31799. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31800. /**
  31801. * Creates a new raw cube texture
  31802. * @param data defines the array of data to use to create each face
  31803. * @param size defines the size of the textures
  31804. * @param format defines the format of the data
  31805. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31806. * @param generateMipMaps defines if the engine should generate the mip levels
  31807. * @param invertY defines if data must be stored with Y axis inverted
  31808. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31809. * @param compression defines the compression used (null by default)
  31810. * @returns the cube texture as an InternalTexture
  31811. */
  31812. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31813. /**
  31814. * Creates a new raw 3D texture
  31815. * @param data defines the data used to create the texture
  31816. * @param width defines the width of the texture
  31817. * @param height defines the height of the texture
  31818. * @param depth defines the depth of the texture
  31819. * @param format defines the format of the texture
  31820. * @param generateMipMaps defines if the engine must generate mip levels
  31821. * @param invertY defines if data must be stored with Y axis inverted
  31822. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31823. * @param compression defines the compressed used (can be null)
  31824. * @param textureType defines the compressed used (can be null)
  31825. * @returns a new raw 3D texture (stored in an InternalTexture)
  31826. */
  31827. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31828. /**
  31829. * Creates a new raw 2D array texture
  31830. * @param data defines the data used to create the texture
  31831. * @param width defines the width of the texture
  31832. * @param height defines the height of the texture
  31833. * @param depth defines the number of layers of the texture
  31834. * @param format defines the format of the texture
  31835. * @param generateMipMaps defines if the engine must generate mip levels
  31836. * @param invertY defines if data must be stored with Y axis inverted
  31837. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31838. * @param compression defines the compressed used (can be null)
  31839. * @param textureType defines the compressed used (can be null)
  31840. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31841. */
  31842. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31843. private _unpackFlipYCached;
  31844. /**
  31845. * In case you are sharing the context with other applications, it might
  31846. * be interested to not cache the unpack flip y state to ensure a consistent
  31847. * value would be set.
  31848. */
  31849. enableUnpackFlipYCached: boolean;
  31850. /** @hidden */
  31851. _unpackFlipY(value: boolean): void;
  31852. /** @hidden */
  31853. _getUnpackAlignement(): number;
  31854. private _getTextureTarget;
  31855. /**
  31856. * Update the sampling mode of a given texture
  31857. * @param samplingMode defines the required sampling mode
  31858. * @param texture defines the texture to update
  31859. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31860. */
  31861. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31862. /**
  31863. * Update the sampling mode of a given texture
  31864. * @param texture defines the texture to update
  31865. * @param wrapU defines the texture wrap mode of the u coordinates
  31866. * @param wrapV defines the texture wrap mode of the v coordinates
  31867. * @param wrapR defines the texture wrap mode of the r coordinates
  31868. */
  31869. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31870. /** @hidden */
  31871. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31872. width: number;
  31873. height: number;
  31874. layers?: number;
  31875. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31876. /** @hidden */
  31877. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31878. /** @hidden */
  31879. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31880. /**
  31881. * Update a portion of an internal texture
  31882. * @param texture defines the texture to update
  31883. * @param imageData defines the data to store into the texture
  31884. * @param xOffset defines the x coordinates of the update rectangle
  31885. * @param yOffset defines the y coordinates of the update rectangle
  31886. * @param width defines the width of the update rectangle
  31887. * @param height defines the height of the update rectangle
  31888. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31889. * @param lod defines the lod level to update (0 by default)
  31890. */
  31891. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31892. /** @hidden */
  31893. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31894. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31895. private _prepareWebGLTexture;
  31896. /** @hidden */
  31897. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31898. private _getDepthStencilBuffer;
  31899. /** @hidden */
  31900. _releaseFramebufferObjects(texture: InternalTexture): void;
  31901. /** @hidden */
  31902. _releaseTexture(texture: InternalTexture): void;
  31903. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31904. protected _setProgram(program: WebGLProgram): void;
  31905. protected _boundUniforms: {
  31906. [key: number]: WebGLUniformLocation;
  31907. };
  31908. /**
  31909. * Binds an effect to the webGL context
  31910. * @param effect defines the effect to bind
  31911. */
  31912. bindSamplers(effect: Effect): void;
  31913. private _activateCurrentTexture;
  31914. /** @hidden */
  31915. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31916. /** @hidden */
  31917. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31918. /**
  31919. * Unbind all textures from the webGL context
  31920. */
  31921. unbindAllTextures(): void;
  31922. /**
  31923. * Sets a texture to the according uniform.
  31924. * @param channel The texture channel
  31925. * @param uniform The uniform to set
  31926. * @param texture The texture to apply
  31927. */
  31928. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31929. private _bindSamplerUniformToChannel;
  31930. private _getTextureWrapMode;
  31931. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31932. /**
  31933. * Sets an array of texture to the webGL context
  31934. * @param channel defines the channel where the texture array must be set
  31935. * @param uniform defines the associated uniform location
  31936. * @param textures defines the array of textures to bind
  31937. */
  31938. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31939. /** @hidden */
  31940. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31941. private _setTextureParameterFloat;
  31942. private _setTextureParameterInteger;
  31943. /**
  31944. * Unbind all vertex attributes from the webGL context
  31945. */
  31946. unbindAllAttributes(): void;
  31947. /**
  31948. * 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
  31949. */
  31950. releaseEffects(): void;
  31951. /**
  31952. * Dispose and release all associated resources
  31953. */
  31954. dispose(): void;
  31955. /**
  31956. * Attach a new callback raised when context lost event is fired
  31957. * @param callback defines the callback to call
  31958. */
  31959. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31960. /**
  31961. * Attach a new callback raised when context restored event is fired
  31962. * @param callback defines the callback to call
  31963. */
  31964. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31965. /**
  31966. * Get the current error code of the webGL context
  31967. * @returns the error code
  31968. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31969. */
  31970. getError(): number;
  31971. private _canRenderToFloatFramebuffer;
  31972. private _canRenderToHalfFloatFramebuffer;
  31973. private _canRenderToFramebuffer;
  31974. /** @hidden */
  31975. _getWebGLTextureType(type: number): number;
  31976. /** @hidden */
  31977. _getInternalFormat(format: number): number;
  31978. /** @hidden */
  31979. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31980. /** @hidden */
  31981. _getRGBAMultiSampleBufferFormat(type: number): number;
  31982. /** @hidden */
  31983. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  31984. /**
  31985. * Loads a file from a url
  31986. * @param url url to load
  31987. * @param onSuccess callback called when the file successfully loads
  31988. * @param onProgress callback called while file is loading (if the server supports this mode)
  31989. * @param offlineProvider defines the offline provider for caching
  31990. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31991. * @param onError callback called when the file fails to load
  31992. * @returns a file request object
  31993. * @hidden
  31994. */
  31995. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  31996. /**
  31997. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31998. * @param x defines the x coordinate of the rectangle where pixels must be read
  31999. * @param y defines the y coordinate of the rectangle where pixels must be read
  32000. * @param width defines the width of the rectangle where pixels must be read
  32001. * @param height defines the height of the rectangle where pixels must be read
  32002. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32003. * @returns a Uint8Array containing RGBA colors
  32004. */
  32005. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32006. private static _isSupported;
  32007. /**
  32008. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32009. * @returns true if the engine can be created
  32010. * @ignorenaming
  32011. */
  32012. static isSupported(): boolean;
  32013. /**
  32014. * Find the next highest power of two.
  32015. * @param x Number to start search from.
  32016. * @return Next highest power of two.
  32017. */
  32018. static CeilingPOT(x: number): number;
  32019. /**
  32020. * Find the next lowest power of two.
  32021. * @param x Number to start search from.
  32022. * @return Next lowest power of two.
  32023. */
  32024. static FloorPOT(x: number): number;
  32025. /**
  32026. * Find the nearest power of two.
  32027. * @param x Number to start search from.
  32028. * @return Next nearest power of two.
  32029. */
  32030. static NearestPOT(x: number): number;
  32031. /**
  32032. * Get the closest exponent of two
  32033. * @param value defines the value to approximate
  32034. * @param max defines the maximum value to return
  32035. * @param mode defines how to define the closest value
  32036. * @returns closest exponent of two of the given value
  32037. */
  32038. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32039. /**
  32040. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32041. * @param func - the function to be called
  32042. * @param requester - the object that will request the next frame. Falls back to window.
  32043. * @returns frame number
  32044. */
  32045. static QueueNewFrame(func: () => void, requester?: any): number;
  32046. /**
  32047. * Gets host document
  32048. * @returns the host document object
  32049. */
  32050. getHostDocument(): Nullable<Document>;
  32051. }
  32052. }
  32053. declare module BABYLON {
  32054. /**
  32055. * Class representing spherical harmonics coefficients to the 3rd degree
  32056. */
  32057. export class SphericalHarmonics {
  32058. /**
  32059. * Defines whether or not the harmonics have been prescaled for rendering.
  32060. */
  32061. preScaled: boolean;
  32062. /**
  32063. * The l0,0 coefficients of the spherical harmonics
  32064. */
  32065. l00: Vector3;
  32066. /**
  32067. * The l1,-1 coefficients of the spherical harmonics
  32068. */
  32069. l1_1: Vector3;
  32070. /**
  32071. * The l1,0 coefficients of the spherical harmonics
  32072. */
  32073. l10: Vector3;
  32074. /**
  32075. * The l1,1 coefficients of the spherical harmonics
  32076. */
  32077. l11: Vector3;
  32078. /**
  32079. * The l2,-2 coefficients of the spherical harmonics
  32080. */
  32081. l2_2: Vector3;
  32082. /**
  32083. * The l2,-1 coefficients of the spherical harmonics
  32084. */
  32085. l2_1: Vector3;
  32086. /**
  32087. * The l2,0 coefficients of the spherical harmonics
  32088. */
  32089. l20: Vector3;
  32090. /**
  32091. * The l2,1 coefficients of the spherical harmonics
  32092. */
  32093. l21: Vector3;
  32094. /**
  32095. * The l2,2 coefficients of the spherical harmonics
  32096. */
  32097. l22: Vector3;
  32098. /**
  32099. * Adds a light to the spherical harmonics
  32100. * @param direction the direction of the light
  32101. * @param color the color of the light
  32102. * @param deltaSolidAngle the delta solid angle of the light
  32103. */
  32104. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32105. /**
  32106. * Scales the spherical harmonics by the given amount
  32107. * @param scale the amount to scale
  32108. */
  32109. scaleInPlace(scale: number): void;
  32110. /**
  32111. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32112. *
  32113. * ```
  32114. * E_lm = A_l * L_lm
  32115. * ```
  32116. *
  32117. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32118. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32119. * the scaling factors are given in equation 9.
  32120. */
  32121. convertIncidentRadianceToIrradiance(): void;
  32122. /**
  32123. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32124. *
  32125. * ```
  32126. * L = (1/pi) * E * rho
  32127. * ```
  32128. *
  32129. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32130. */
  32131. convertIrradianceToLambertianRadiance(): void;
  32132. /**
  32133. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32134. * required operations at run time.
  32135. *
  32136. * This is simply done by scaling back the SH with Ylm constants parameter.
  32137. * The trigonometric part being applied by the shader at run time.
  32138. */
  32139. preScaleForRendering(): void;
  32140. /**
  32141. * Constructs a spherical harmonics from an array.
  32142. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32143. * @returns the spherical harmonics
  32144. */
  32145. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32146. /**
  32147. * Gets the spherical harmonics from polynomial
  32148. * @param polynomial the spherical polynomial
  32149. * @returns the spherical harmonics
  32150. */
  32151. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32152. }
  32153. /**
  32154. * Class representing spherical polynomial coefficients to the 3rd degree
  32155. */
  32156. export class SphericalPolynomial {
  32157. private _harmonics;
  32158. /**
  32159. * The spherical harmonics used to create the polynomials.
  32160. */
  32161. get preScaledHarmonics(): SphericalHarmonics;
  32162. /**
  32163. * The x coefficients of the spherical polynomial
  32164. */
  32165. x: Vector3;
  32166. /**
  32167. * The y coefficients of the spherical polynomial
  32168. */
  32169. y: Vector3;
  32170. /**
  32171. * The z coefficients of the spherical polynomial
  32172. */
  32173. z: Vector3;
  32174. /**
  32175. * The xx coefficients of the spherical polynomial
  32176. */
  32177. xx: Vector3;
  32178. /**
  32179. * The yy coefficients of the spherical polynomial
  32180. */
  32181. yy: Vector3;
  32182. /**
  32183. * The zz coefficients of the spherical polynomial
  32184. */
  32185. zz: Vector3;
  32186. /**
  32187. * The xy coefficients of the spherical polynomial
  32188. */
  32189. xy: Vector3;
  32190. /**
  32191. * The yz coefficients of the spherical polynomial
  32192. */
  32193. yz: Vector3;
  32194. /**
  32195. * The zx coefficients of the spherical polynomial
  32196. */
  32197. zx: Vector3;
  32198. /**
  32199. * Adds an ambient color to the spherical polynomial
  32200. * @param color the color to add
  32201. */
  32202. addAmbient(color: Color3): void;
  32203. /**
  32204. * Scales the spherical polynomial by the given amount
  32205. * @param scale the amount to scale
  32206. */
  32207. scaleInPlace(scale: number): void;
  32208. /**
  32209. * Gets the spherical polynomial from harmonics
  32210. * @param harmonics the spherical harmonics
  32211. * @returns the spherical polynomial
  32212. */
  32213. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32214. /**
  32215. * Constructs a spherical polynomial from an array.
  32216. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32217. * @returns the spherical polynomial
  32218. */
  32219. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32220. }
  32221. }
  32222. declare module BABYLON {
  32223. /**
  32224. * Defines the source of the internal texture
  32225. */
  32226. export enum InternalTextureSource {
  32227. /**
  32228. * The source of the texture data is unknown
  32229. */
  32230. Unknown = 0,
  32231. /**
  32232. * Texture data comes from an URL
  32233. */
  32234. Url = 1,
  32235. /**
  32236. * Texture data is only used for temporary storage
  32237. */
  32238. Temp = 2,
  32239. /**
  32240. * Texture data comes from raw data (ArrayBuffer)
  32241. */
  32242. Raw = 3,
  32243. /**
  32244. * Texture content is dynamic (video or dynamic texture)
  32245. */
  32246. Dynamic = 4,
  32247. /**
  32248. * Texture content is generated by rendering to it
  32249. */
  32250. RenderTarget = 5,
  32251. /**
  32252. * Texture content is part of a multi render target process
  32253. */
  32254. MultiRenderTarget = 6,
  32255. /**
  32256. * Texture data comes from a cube data file
  32257. */
  32258. Cube = 7,
  32259. /**
  32260. * Texture data comes from a raw cube data
  32261. */
  32262. CubeRaw = 8,
  32263. /**
  32264. * Texture data come from a prefiltered cube data file
  32265. */
  32266. CubePrefiltered = 9,
  32267. /**
  32268. * Texture content is raw 3D data
  32269. */
  32270. Raw3D = 10,
  32271. /**
  32272. * Texture content is raw 2D array data
  32273. */
  32274. Raw2DArray = 11,
  32275. /**
  32276. * Texture content is a depth texture
  32277. */
  32278. Depth = 12,
  32279. /**
  32280. * Texture data comes from a raw cube data encoded with RGBD
  32281. */
  32282. CubeRawRGBD = 13
  32283. }
  32284. /**
  32285. * Class used to store data associated with WebGL texture data for the engine
  32286. * This class should not be used directly
  32287. */
  32288. export class InternalTexture {
  32289. /** @hidden */
  32290. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32291. /**
  32292. * Defines if the texture is ready
  32293. */
  32294. isReady: boolean;
  32295. /**
  32296. * Defines if the texture is a cube texture
  32297. */
  32298. isCube: boolean;
  32299. /**
  32300. * Defines if the texture contains 3D data
  32301. */
  32302. is3D: boolean;
  32303. /**
  32304. * Defines if the texture contains 2D array data
  32305. */
  32306. is2DArray: boolean;
  32307. /**
  32308. * Defines if the texture contains multiview data
  32309. */
  32310. isMultiview: boolean;
  32311. /**
  32312. * Gets the URL used to load this texture
  32313. */
  32314. url: string;
  32315. /**
  32316. * Gets the sampling mode of the texture
  32317. */
  32318. samplingMode: number;
  32319. /**
  32320. * Gets a boolean indicating if the texture needs mipmaps generation
  32321. */
  32322. generateMipMaps: boolean;
  32323. /**
  32324. * Gets the number of samples used by the texture (WebGL2+ only)
  32325. */
  32326. samples: number;
  32327. /**
  32328. * Gets the type of the texture (int, float...)
  32329. */
  32330. type: number;
  32331. /**
  32332. * Gets the format of the texture (RGB, RGBA...)
  32333. */
  32334. format: number;
  32335. /**
  32336. * Observable called when the texture is loaded
  32337. */
  32338. onLoadedObservable: Observable<InternalTexture>;
  32339. /**
  32340. * Gets the width of the texture
  32341. */
  32342. width: number;
  32343. /**
  32344. * Gets the height of the texture
  32345. */
  32346. height: number;
  32347. /**
  32348. * Gets the depth of the texture
  32349. */
  32350. depth: number;
  32351. /**
  32352. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32353. */
  32354. baseWidth: number;
  32355. /**
  32356. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32357. */
  32358. baseHeight: number;
  32359. /**
  32360. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32361. */
  32362. baseDepth: number;
  32363. /**
  32364. * Gets a boolean indicating if the texture is inverted on Y axis
  32365. */
  32366. invertY: boolean;
  32367. /** @hidden */
  32368. _invertVScale: boolean;
  32369. /** @hidden */
  32370. _associatedChannel: number;
  32371. /** @hidden */
  32372. _source: InternalTextureSource;
  32373. /** @hidden */
  32374. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32375. /** @hidden */
  32376. _bufferView: Nullable<ArrayBufferView>;
  32377. /** @hidden */
  32378. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32379. /** @hidden */
  32380. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32381. /** @hidden */
  32382. _size: number;
  32383. /** @hidden */
  32384. _extension: string;
  32385. /** @hidden */
  32386. _files: Nullable<string[]>;
  32387. /** @hidden */
  32388. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32389. /** @hidden */
  32390. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32391. /** @hidden */
  32392. _framebuffer: Nullable<WebGLFramebuffer>;
  32393. /** @hidden */
  32394. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32395. /** @hidden */
  32396. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32397. /** @hidden */
  32398. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32399. /** @hidden */
  32400. _attachments: Nullable<number[]>;
  32401. /** @hidden */
  32402. _cachedCoordinatesMode: Nullable<number>;
  32403. /** @hidden */
  32404. _cachedWrapU: Nullable<number>;
  32405. /** @hidden */
  32406. _cachedWrapV: Nullable<number>;
  32407. /** @hidden */
  32408. _cachedWrapR: Nullable<number>;
  32409. /** @hidden */
  32410. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32411. /** @hidden */
  32412. _isDisabled: boolean;
  32413. /** @hidden */
  32414. _compression: Nullable<string>;
  32415. /** @hidden */
  32416. _generateStencilBuffer: boolean;
  32417. /** @hidden */
  32418. _generateDepthBuffer: boolean;
  32419. /** @hidden */
  32420. _comparisonFunction: number;
  32421. /** @hidden */
  32422. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32423. /** @hidden */
  32424. _lodGenerationScale: number;
  32425. /** @hidden */
  32426. _lodGenerationOffset: number;
  32427. /** @hidden */
  32428. _depthStencilTexture: Nullable<InternalTexture>;
  32429. /** @hidden */
  32430. _colorTextureArray: Nullable<WebGLTexture>;
  32431. /** @hidden */
  32432. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32433. /** @hidden */
  32434. _lodTextureHigh: Nullable<BaseTexture>;
  32435. /** @hidden */
  32436. _lodTextureMid: Nullable<BaseTexture>;
  32437. /** @hidden */
  32438. _lodTextureLow: Nullable<BaseTexture>;
  32439. /** @hidden */
  32440. _isRGBD: boolean;
  32441. /** @hidden */
  32442. _linearSpecularLOD: boolean;
  32443. /** @hidden */
  32444. _irradianceTexture: Nullable<BaseTexture>;
  32445. /** @hidden */
  32446. _webGLTexture: Nullable<WebGLTexture>;
  32447. /** @hidden */
  32448. _references: number;
  32449. private _engine;
  32450. /**
  32451. * Gets the Engine the texture belongs to.
  32452. * @returns The babylon engine
  32453. */
  32454. getEngine(): ThinEngine;
  32455. /**
  32456. * Gets the data source type of the texture
  32457. */
  32458. get source(): InternalTextureSource;
  32459. /**
  32460. * Creates a new InternalTexture
  32461. * @param engine defines the engine to use
  32462. * @param source defines the type of data that will be used
  32463. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32464. */
  32465. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32466. /**
  32467. * Increments the number of references (ie. the number of Texture that point to it)
  32468. */
  32469. incrementReferences(): void;
  32470. /**
  32471. * Change the size of the texture (not the size of the content)
  32472. * @param width defines the new width
  32473. * @param height defines the new height
  32474. * @param depth defines the new depth (1 by default)
  32475. */
  32476. updateSize(width: int, height: int, depth?: int): void;
  32477. /** @hidden */
  32478. _rebuild(): void;
  32479. /** @hidden */
  32480. _swapAndDie(target: InternalTexture): void;
  32481. /**
  32482. * Dispose the current allocated resources
  32483. */
  32484. dispose(): void;
  32485. }
  32486. }
  32487. declare module BABYLON {
  32488. /**
  32489. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32491. */
  32492. export class Analyser {
  32493. /**
  32494. * Gets or sets the smoothing
  32495. * @ignorenaming
  32496. */
  32497. SMOOTHING: number;
  32498. /**
  32499. * Gets or sets the FFT table size
  32500. * @ignorenaming
  32501. */
  32502. FFT_SIZE: number;
  32503. /**
  32504. * Gets or sets the bar graph amplitude
  32505. * @ignorenaming
  32506. */
  32507. BARGRAPHAMPLITUDE: number;
  32508. /**
  32509. * Gets or sets the position of the debug canvas
  32510. * @ignorenaming
  32511. */
  32512. DEBUGCANVASPOS: {
  32513. x: number;
  32514. y: number;
  32515. };
  32516. /**
  32517. * Gets or sets the debug canvas size
  32518. * @ignorenaming
  32519. */
  32520. DEBUGCANVASSIZE: {
  32521. width: number;
  32522. height: number;
  32523. };
  32524. private _byteFreqs;
  32525. private _byteTime;
  32526. private _floatFreqs;
  32527. private _webAudioAnalyser;
  32528. private _debugCanvas;
  32529. private _debugCanvasContext;
  32530. private _scene;
  32531. private _registerFunc;
  32532. private _audioEngine;
  32533. /**
  32534. * Creates a new analyser
  32535. * @param scene defines hosting scene
  32536. */
  32537. constructor(scene: Scene);
  32538. /**
  32539. * Get the number of data values you will have to play with for the visualization
  32540. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32541. * @returns a number
  32542. */
  32543. getFrequencyBinCount(): number;
  32544. /**
  32545. * Gets the current frequency data as a byte array
  32546. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32547. * @returns a Uint8Array
  32548. */
  32549. getByteFrequencyData(): Uint8Array;
  32550. /**
  32551. * Gets the current waveform as a byte array
  32552. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32553. * @returns a Uint8Array
  32554. */
  32555. getByteTimeDomainData(): Uint8Array;
  32556. /**
  32557. * Gets the current frequency data as a float array
  32558. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32559. * @returns a Float32Array
  32560. */
  32561. getFloatFrequencyData(): Float32Array;
  32562. /**
  32563. * Renders the debug canvas
  32564. */
  32565. drawDebugCanvas(): void;
  32566. /**
  32567. * Stops rendering the debug canvas and removes it
  32568. */
  32569. stopDebugCanvas(): void;
  32570. /**
  32571. * Connects two audio nodes
  32572. * @param inputAudioNode defines first node to connect
  32573. * @param outputAudioNode defines second node to connect
  32574. */
  32575. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32576. /**
  32577. * Releases all associated resources
  32578. */
  32579. dispose(): void;
  32580. }
  32581. }
  32582. declare module BABYLON {
  32583. /**
  32584. * This represents an audio engine and it is responsible
  32585. * to play, synchronize and analyse sounds throughout the application.
  32586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32587. */
  32588. export interface IAudioEngine extends IDisposable {
  32589. /**
  32590. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32591. */
  32592. readonly canUseWebAudio: boolean;
  32593. /**
  32594. * Gets the current AudioContext if available.
  32595. */
  32596. readonly audioContext: Nullable<AudioContext>;
  32597. /**
  32598. * The master gain node defines the global audio volume of your audio engine.
  32599. */
  32600. readonly masterGain: GainNode;
  32601. /**
  32602. * Gets whether or not mp3 are supported by your browser.
  32603. */
  32604. readonly isMP3supported: boolean;
  32605. /**
  32606. * Gets whether or not ogg are supported by your browser.
  32607. */
  32608. readonly isOGGsupported: boolean;
  32609. /**
  32610. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32611. * @ignoreNaming
  32612. */
  32613. WarnedWebAudioUnsupported: boolean;
  32614. /**
  32615. * Defines if the audio engine relies on a custom unlocked button.
  32616. * In this case, the embedded button will not be displayed.
  32617. */
  32618. useCustomUnlockedButton: boolean;
  32619. /**
  32620. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32621. */
  32622. readonly unlocked: boolean;
  32623. /**
  32624. * Event raised when audio has been unlocked on the browser.
  32625. */
  32626. onAudioUnlockedObservable: Observable<AudioEngine>;
  32627. /**
  32628. * Event raised when audio has been locked on the browser.
  32629. */
  32630. onAudioLockedObservable: Observable<AudioEngine>;
  32631. /**
  32632. * Flags the audio engine in Locked state.
  32633. * This happens due to new browser policies preventing audio to autoplay.
  32634. */
  32635. lock(): void;
  32636. /**
  32637. * Unlocks the audio engine once a user action has been done on the dom.
  32638. * This is helpful to resume play once browser policies have been satisfied.
  32639. */
  32640. unlock(): void;
  32641. /**
  32642. * Gets the global volume sets on the master gain.
  32643. * @returns the global volume if set or -1 otherwise
  32644. */
  32645. getGlobalVolume(): number;
  32646. /**
  32647. * Sets the global volume of your experience (sets on the master gain).
  32648. * @param newVolume Defines the new global volume of the application
  32649. */
  32650. setGlobalVolume(newVolume: number): void;
  32651. /**
  32652. * Connect the audio engine to an audio analyser allowing some amazing
  32653. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32655. * @param analyser The analyser to connect to the engine
  32656. */
  32657. connectToAnalyser(analyser: Analyser): void;
  32658. }
  32659. /**
  32660. * This represents the default audio engine used in babylon.
  32661. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32663. */
  32664. export class AudioEngine implements IAudioEngine {
  32665. private _audioContext;
  32666. private _audioContextInitialized;
  32667. private _muteButton;
  32668. private _hostElement;
  32669. /**
  32670. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32671. */
  32672. canUseWebAudio: boolean;
  32673. /**
  32674. * The master gain node defines the global audio volume of your audio engine.
  32675. */
  32676. masterGain: GainNode;
  32677. /**
  32678. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32679. * @ignoreNaming
  32680. */
  32681. WarnedWebAudioUnsupported: boolean;
  32682. /**
  32683. * Gets whether or not mp3 are supported by your browser.
  32684. */
  32685. isMP3supported: boolean;
  32686. /**
  32687. * Gets whether or not ogg are supported by your browser.
  32688. */
  32689. isOGGsupported: boolean;
  32690. /**
  32691. * Gets whether audio has been unlocked on the device.
  32692. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32693. * a user interaction has happened.
  32694. */
  32695. unlocked: boolean;
  32696. /**
  32697. * Defines if the audio engine relies on a custom unlocked button.
  32698. * In this case, the embedded button will not be displayed.
  32699. */
  32700. useCustomUnlockedButton: boolean;
  32701. /**
  32702. * Event raised when audio has been unlocked on the browser.
  32703. */
  32704. onAudioUnlockedObservable: Observable<AudioEngine>;
  32705. /**
  32706. * Event raised when audio has been locked on the browser.
  32707. */
  32708. onAudioLockedObservable: Observable<AudioEngine>;
  32709. /**
  32710. * Gets the current AudioContext if available.
  32711. */
  32712. get audioContext(): Nullable<AudioContext>;
  32713. private _connectedAnalyser;
  32714. /**
  32715. * Instantiates a new audio engine.
  32716. *
  32717. * There should be only one per page as some browsers restrict the number
  32718. * of audio contexts you can create.
  32719. * @param hostElement defines the host element where to display the mute icon if necessary
  32720. */
  32721. constructor(hostElement?: Nullable<HTMLElement>);
  32722. /**
  32723. * Flags the audio engine in Locked state.
  32724. * This happens due to new browser policies preventing audio to autoplay.
  32725. */
  32726. lock(): void;
  32727. /**
  32728. * Unlocks the audio engine once a user action has been done on the dom.
  32729. * This is helpful to resume play once browser policies have been satisfied.
  32730. */
  32731. unlock(): void;
  32732. private _resumeAudioContext;
  32733. private _initializeAudioContext;
  32734. private _tryToRun;
  32735. private _triggerRunningState;
  32736. private _triggerSuspendedState;
  32737. private _displayMuteButton;
  32738. private _moveButtonToTopLeft;
  32739. private _onResize;
  32740. private _hideMuteButton;
  32741. /**
  32742. * Destroy and release the resources associated with the audio ccontext.
  32743. */
  32744. dispose(): void;
  32745. /**
  32746. * Gets the global volume sets on the master gain.
  32747. * @returns the global volume if set or -1 otherwise
  32748. */
  32749. getGlobalVolume(): number;
  32750. /**
  32751. * Sets the global volume of your experience (sets on the master gain).
  32752. * @param newVolume Defines the new global volume of the application
  32753. */
  32754. setGlobalVolume(newVolume: number): void;
  32755. /**
  32756. * Connect the audio engine to an audio analyser allowing some amazing
  32757. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32759. * @param analyser The analyser to connect to the engine
  32760. */
  32761. connectToAnalyser(analyser: Analyser): void;
  32762. }
  32763. }
  32764. declare module BABYLON {
  32765. /**
  32766. * Interface used to present a loading screen while loading a scene
  32767. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32768. */
  32769. export interface ILoadingScreen {
  32770. /**
  32771. * Function called to display the loading screen
  32772. */
  32773. displayLoadingUI: () => void;
  32774. /**
  32775. * Function called to hide the loading screen
  32776. */
  32777. hideLoadingUI: () => void;
  32778. /**
  32779. * Gets or sets the color to use for the background
  32780. */
  32781. loadingUIBackgroundColor: string;
  32782. /**
  32783. * Gets or sets the text to display while loading
  32784. */
  32785. loadingUIText: string;
  32786. }
  32787. /**
  32788. * Class used for the default loading screen
  32789. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32790. */
  32791. export class DefaultLoadingScreen implements ILoadingScreen {
  32792. private _renderingCanvas;
  32793. private _loadingText;
  32794. private _loadingDivBackgroundColor;
  32795. private _loadingDiv;
  32796. private _loadingTextDiv;
  32797. /** Gets or sets the logo url to use for the default loading screen */
  32798. static DefaultLogoUrl: string;
  32799. /** Gets or sets the spinner url to use for the default loading screen */
  32800. static DefaultSpinnerUrl: string;
  32801. /**
  32802. * Creates a new default loading screen
  32803. * @param _renderingCanvas defines the canvas used to render the scene
  32804. * @param _loadingText defines the default text to display
  32805. * @param _loadingDivBackgroundColor defines the default background color
  32806. */
  32807. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32808. /**
  32809. * Function called to display the loading screen
  32810. */
  32811. displayLoadingUI(): void;
  32812. /**
  32813. * Function called to hide the loading screen
  32814. */
  32815. hideLoadingUI(): void;
  32816. /**
  32817. * Gets or sets the text to display while loading
  32818. */
  32819. set loadingUIText(text: string);
  32820. get loadingUIText(): string;
  32821. /**
  32822. * Gets or sets the color to use for the background
  32823. */
  32824. get loadingUIBackgroundColor(): string;
  32825. set loadingUIBackgroundColor(color: string);
  32826. private _resizeLoadingUI;
  32827. }
  32828. }
  32829. declare module BABYLON {
  32830. /**
  32831. * Interface for any object that can request an animation frame
  32832. */
  32833. export interface ICustomAnimationFrameRequester {
  32834. /**
  32835. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32836. */
  32837. renderFunction?: Function;
  32838. /**
  32839. * Called to request the next frame to render to
  32840. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32841. */
  32842. requestAnimationFrame: Function;
  32843. /**
  32844. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32845. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32846. */
  32847. requestID?: number;
  32848. }
  32849. }
  32850. declare module BABYLON {
  32851. /**
  32852. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32853. */
  32854. export class PerformanceMonitor {
  32855. private _enabled;
  32856. private _rollingFrameTime;
  32857. private _lastFrameTimeMs;
  32858. /**
  32859. * constructor
  32860. * @param frameSampleSize The number of samples required to saturate the sliding window
  32861. */
  32862. constructor(frameSampleSize?: number);
  32863. /**
  32864. * Samples current frame
  32865. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32866. */
  32867. sampleFrame(timeMs?: number): void;
  32868. /**
  32869. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32870. */
  32871. get averageFrameTime(): number;
  32872. /**
  32873. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32874. */
  32875. get averageFrameTimeVariance(): number;
  32876. /**
  32877. * Returns the frame time of the most recent frame
  32878. */
  32879. get instantaneousFrameTime(): number;
  32880. /**
  32881. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32882. */
  32883. get averageFPS(): number;
  32884. /**
  32885. * Returns the average framerate in frames per second using the most recent frame time
  32886. */
  32887. get instantaneousFPS(): number;
  32888. /**
  32889. * Returns true if enough samples have been taken to completely fill the sliding window
  32890. */
  32891. get isSaturated(): boolean;
  32892. /**
  32893. * Enables contributions to the sliding window sample set
  32894. */
  32895. enable(): void;
  32896. /**
  32897. * Disables contributions to the sliding window sample set
  32898. * Samples will not be interpolated over the disabled period
  32899. */
  32900. disable(): void;
  32901. /**
  32902. * Returns true if sampling is enabled
  32903. */
  32904. get isEnabled(): boolean;
  32905. /**
  32906. * Resets performance monitor
  32907. */
  32908. reset(): void;
  32909. }
  32910. /**
  32911. * RollingAverage
  32912. *
  32913. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32914. */
  32915. export class RollingAverage {
  32916. /**
  32917. * Current average
  32918. */
  32919. average: number;
  32920. /**
  32921. * Current variance
  32922. */
  32923. variance: number;
  32924. protected _samples: Array<number>;
  32925. protected _sampleCount: number;
  32926. protected _pos: number;
  32927. protected _m2: number;
  32928. /**
  32929. * constructor
  32930. * @param length The number of samples required to saturate the sliding window
  32931. */
  32932. constructor(length: number);
  32933. /**
  32934. * Adds a sample to the sample set
  32935. * @param v The sample value
  32936. */
  32937. add(v: number): void;
  32938. /**
  32939. * Returns previously added values or null if outside of history or outside the sliding window domain
  32940. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32941. * @return Value previously recorded with add() or null if outside of range
  32942. */
  32943. history(i: number): number;
  32944. /**
  32945. * Returns true if enough samples have been taken to completely fill the sliding window
  32946. * @return true if sample-set saturated
  32947. */
  32948. isSaturated(): boolean;
  32949. /**
  32950. * Resets the rolling average (equivalent to 0 samples taken so far)
  32951. */
  32952. reset(): void;
  32953. /**
  32954. * Wraps a value around the sample range boundaries
  32955. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32956. * @return Wrapped position in sample range
  32957. */
  32958. protected _wrapPosition(i: number): number;
  32959. }
  32960. }
  32961. declare module BABYLON {
  32962. /**
  32963. * This class is used to track a performance counter which is number based.
  32964. * The user has access to many properties which give statistics of different nature.
  32965. *
  32966. * The implementer can track two kinds of Performance Counter: time and count.
  32967. * 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.
  32968. * 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.
  32969. */
  32970. export class PerfCounter {
  32971. /**
  32972. * Gets or sets a global boolean to turn on and off all the counters
  32973. */
  32974. static Enabled: boolean;
  32975. /**
  32976. * Returns the smallest value ever
  32977. */
  32978. get min(): number;
  32979. /**
  32980. * Returns the biggest value ever
  32981. */
  32982. get max(): number;
  32983. /**
  32984. * Returns the average value since the performance counter is running
  32985. */
  32986. get average(): number;
  32987. /**
  32988. * Returns the average value of the last second the counter was monitored
  32989. */
  32990. get lastSecAverage(): number;
  32991. /**
  32992. * Returns the current value
  32993. */
  32994. get current(): number;
  32995. /**
  32996. * Gets the accumulated total
  32997. */
  32998. get total(): number;
  32999. /**
  33000. * Gets the total value count
  33001. */
  33002. get count(): number;
  33003. /**
  33004. * Creates a new counter
  33005. */
  33006. constructor();
  33007. /**
  33008. * Call this method to start monitoring a new frame.
  33009. * 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.
  33010. */
  33011. fetchNewFrame(): void;
  33012. /**
  33013. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33014. * @param newCount the count value to add to the monitored count
  33015. * @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.
  33016. */
  33017. addCount(newCount: number, fetchResult: boolean): void;
  33018. /**
  33019. * Start monitoring this performance counter
  33020. */
  33021. beginMonitoring(): void;
  33022. /**
  33023. * Compute the time lapsed since the previous beginMonitoring() call.
  33024. * @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
  33025. */
  33026. endMonitoring(newFrame?: boolean): void;
  33027. private _fetchResult;
  33028. private _startMonitoringTime;
  33029. private _min;
  33030. private _max;
  33031. private _average;
  33032. private _current;
  33033. private _totalValueCount;
  33034. private _totalAccumulated;
  33035. private _lastSecAverage;
  33036. private _lastSecAccumulated;
  33037. private _lastSecTime;
  33038. private _lastSecValueCount;
  33039. }
  33040. }
  33041. declare module BABYLON {
  33042. interface ThinEngine {
  33043. /**
  33044. * Sets alpha constants used by some alpha blending modes
  33045. * @param r defines the red component
  33046. * @param g defines the green component
  33047. * @param b defines the blue component
  33048. * @param a defines the alpha component
  33049. */
  33050. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33051. /**
  33052. * Sets the current alpha mode
  33053. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33054. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33055. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33056. */
  33057. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33058. /**
  33059. * Gets the current alpha mode
  33060. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33061. * @returns the current alpha mode
  33062. */
  33063. getAlphaMode(): number;
  33064. /**
  33065. * Sets the current alpha equation
  33066. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33067. */
  33068. setAlphaEquation(equation: number): void;
  33069. /**
  33070. * Gets the current alpha equation.
  33071. * @returns the current alpha equation
  33072. */
  33073. getAlphaEquation(): number;
  33074. }
  33075. }
  33076. declare module BABYLON {
  33077. /**
  33078. * Defines the interface used by display changed events
  33079. */
  33080. export interface IDisplayChangedEventArgs {
  33081. /** Gets the vrDisplay object (if any) */
  33082. vrDisplay: Nullable<any>;
  33083. /** Gets a boolean indicating if webVR is supported */
  33084. vrSupported: boolean;
  33085. }
  33086. /**
  33087. * Defines the interface used by objects containing a viewport (like a camera)
  33088. */
  33089. interface IViewportOwnerLike {
  33090. /**
  33091. * Gets or sets the viewport
  33092. */
  33093. viewport: IViewportLike;
  33094. }
  33095. /**
  33096. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33097. */
  33098. export class Engine extends ThinEngine {
  33099. /** Defines that alpha blending is disabled */
  33100. static readonly ALPHA_DISABLE: number;
  33101. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33102. static readonly ALPHA_ADD: number;
  33103. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33104. static readonly ALPHA_COMBINE: number;
  33105. /** Defines that alpha blending to DEST - SRC * DEST */
  33106. static readonly ALPHA_SUBTRACT: number;
  33107. /** Defines that alpha blending to SRC * DEST */
  33108. static readonly ALPHA_MULTIPLY: number;
  33109. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33110. static readonly ALPHA_MAXIMIZED: number;
  33111. /** Defines that alpha blending to SRC + DEST */
  33112. static readonly ALPHA_ONEONE: number;
  33113. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33114. static readonly ALPHA_PREMULTIPLIED: number;
  33115. /**
  33116. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33117. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33118. */
  33119. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33120. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33121. static readonly ALPHA_INTERPOLATE: number;
  33122. /**
  33123. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33124. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33125. */
  33126. static readonly ALPHA_SCREENMODE: number;
  33127. /** Defines that the ressource is not delayed*/
  33128. static readonly DELAYLOADSTATE_NONE: number;
  33129. /** Defines that the ressource was successfully delay loaded */
  33130. static readonly DELAYLOADSTATE_LOADED: number;
  33131. /** Defines that the ressource is currently delay loading */
  33132. static readonly DELAYLOADSTATE_LOADING: number;
  33133. /** Defines that the ressource is delayed and has not started loading */
  33134. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33135. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33136. static readonly NEVER: number;
  33137. /** 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 */
  33138. static readonly ALWAYS: number;
  33139. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33140. static readonly LESS: number;
  33141. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33142. static readonly EQUAL: number;
  33143. /** 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 */
  33144. static readonly LEQUAL: number;
  33145. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33146. static readonly GREATER: number;
  33147. /** 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 */
  33148. static readonly GEQUAL: number;
  33149. /** 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 */
  33150. static readonly NOTEQUAL: number;
  33151. /** Passed to stencilOperation to specify that stencil value must be kept */
  33152. static readonly KEEP: number;
  33153. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33154. static readonly REPLACE: number;
  33155. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33156. static readonly INCR: number;
  33157. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33158. static readonly DECR: number;
  33159. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33160. static readonly INVERT: number;
  33161. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33162. static readonly INCR_WRAP: number;
  33163. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33164. static readonly DECR_WRAP: number;
  33165. /** Texture is not repeating outside of 0..1 UVs */
  33166. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33167. /** Texture is repeating outside of 0..1 UVs */
  33168. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33169. /** Texture is repeating and mirrored */
  33170. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33171. /** ALPHA */
  33172. static readonly TEXTUREFORMAT_ALPHA: number;
  33173. /** LUMINANCE */
  33174. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33175. /** LUMINANCE_ALPHA */
  33176. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33177. /** RGB */
  33178. static readonly TEXTUREFORMAT_RGB: number;
  33179. /** RGBA */
  33180. static readonly TEXTUREFORMAT_RGBA: number;
  33181. /** RED */
  33182. static readonly TEXTUREFORMAT_RED: number;
  33183. /** RED (2nd reference) */
  33184. static readonly TEXTUREFORMAT_R: number;
  33185. /** RG */
  33186. static readonly TEXTUREFORMAT_RG: number;
  33187. /** RED_INTEGER */
  33188. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33189. /** RED_INTEGER (2nd reference) */
  33190. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33191. /** RG_INTEGER */
  33192. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33193. /** RGB_INTEGER */
  33194. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33195. /** RGBA_INTEGER */
  33196. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33197. /** UNSIGNED_BYTE */
  33198. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33199. /** UNSIGNED_BYTE (2nd reference) */
  33200. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33201. /** FLOAT */
  33202. static readonly TEXTURETYPE_FLOAT: number;
  33203. /** HALF_FLOAT */
  33204. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33205. /** BYTE */
  33206. static readonly TEXTURETYPE_BYTE: number;
  33207. /** SHORT */
  33208. static readonly TEXTURETYPE_SHORT: number;
  33209. /** UNSIGNED_SHORT */
  33210. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33211. /** INT */
  33212. static readonly TEXTURETYPE_INT: number;
  33213. /** UNSIGNED_INT */
  33214. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33215. /** UNSIGNED_SHORT_4_4_4_4 */
  33216. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33217. /** UNSIGNED_SHORT_5_5_5_1 */
  33218. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33219. /** UNSIGNED_SHORT_5_6_5 */
  33220. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33221. /** UNSIGNED_INT_2_10_10_10_REV */
  33222. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33223. /** UNSIGNED_INT_24_8 */
  33224. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33225. /** UNSIGNED_INT_10F_11F_11F_REV */
  33226. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33227. /** UNSIGNED_INT_5_9_9_9_REV */
  33228. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33229. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33230. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33231. /** nearest is mag = nearest and min = nearest and mip = linear */
  33232. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33233. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33234. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33235. /** Trilinear is mag = linear and min = linear and mip = linear */
  33236. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33237. /** nearest is mag = nearest and min = nearest and mip = linear */
  33238. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33239. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33240. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33241. /** Trilinear is mag = linear and min = linear and mip = linear */
  33242. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33243. /** mag = nearest and min = nearest and mip = nearest */
  33244. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33245. /** mag = nearest and min = linear and mip = nearest */
  33246. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33247. /** mag = nearest and min = linear and mip = linear */
  33248. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33249. /** mag = nearest and min = linear and mip = none */
  33250. static readonly TEXTURE_NEAREST_LINEAR: number;
  33251. /** mag = nearest and min = nearest and mip = none */
  33252. static readonly TEXTURE_NEAREST_NEAREST: number;
  33253. /** mag = linear and min = nearest and mip = nearest */
  33254. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33255. /** mag = linear and min = nearest and mip = linear */
  33256. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33257. /** mag = linear and min = linear and mip = none */
  33258. static readonly TEXTURE_LINEAR_LINEAR: number;
  33259. /** mag = linear and min = nearest and mip = none */
  33260. static readonly TEXTURE_LINEAR_NEAREST: number;
  33261. /** Explicit coordinates mode */
  33262. static readonly TEXTURE_EXPLICIT_MODE: number;
  33263. /** Spherical coordinates mode */
  33264. static readonly TEXTURE_SPHERICAL_MODE: number;
  33265. /** Planar coordinates mode */
  33266. static readonly TEXTURE_PLANAR_MODE: number;
  33267. /** Cubic coordinates mode */
  33268. static readonly TEXTURE_CUBIC_MODE: number;
  33269. /** Projection coordinates mode */
  33270. static readonly TEXTURE_PROJECTION_MODE: number;
  33271. /** Skybox coordinates mode */
  33272. static readonly TEXTURE_SKYBOX_MODE: number;
  33273. /** Inverse Cubic coordinates mode */
  33274. static readonly TEXTURE_INVCUBIC_MODE: number;
  33275. /** Equirectangular coordinates mode */
  33276. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33277. /** Equirectangular Fixed coordinates mode */
  33278. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33279. /** Equirectangular Fixed Mirrored coordinates mode */
  33280. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33281. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33282. static readonly SCALEMODE_FLOOR: number;
  33283. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33284. static readonly SCALEMODE_NEAREST: number;
  33285. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33286. static readonly SCALEMODE_CEILING: number;
  33287. /**
  33288. * Returns the current npm package of the sdk
  33289. */
  33290. static get NpmPackage(): string;
  33291. /**
  33292. * Returns the current version of the framework
  33293. */
  33294. static get Version(): string;
  33295. /** Gets the list of created engines */
  33296. static get Instances(): Engine[];
  33297. /**
  33298. * Gets the latest created engine
  33299. */
  33300. static get LastCreatedEngine(): Nullable<Engine>;
  33301. /**
  33302. * Gets the latest created scene
  33303. */
  33304. static get LastCreatedScene(): Nullable<Scene>;
  33305. /**
  33306. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33307. * @param flag defines which part of the materials must be marked as dirty
  33308. * @param predicate defines a predicate used to filter which materials should be affected
  33309. */
  33310. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33311. /**
  33312. * Method called to create the default loading screen.
  33313. * This can be overriden in your own app.
  33314. * @param canvas The rendering canvas element
  33315. * @returns The loading screen
  33316. */
  33317. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33318. /**
  33319. * Method called to create the default rescale post process on each engine.
  33320. */
  33321. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33322. /**
  33323. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33324. **/
  33325. enableOfflineSupport: boolean;
  33326. /**
  33327. * 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)
  33328. **/
  33329. disableManifestCheck: boolean;
  33330. /**
  33331. * Gets the list of created scenes
  33332. */
  33333. scenes: Scene[];
  33334. /**
  33335. * Event raised when a new scene is created
  33336. */
  33337. onNewSceneAddedObservable: Observable<Scene>;
  33338. /**
  33339. * Gets the list of created postprocesses
  33340. */
  33341. postProcesses: PostProcess[];
  33342. /**
  33343. * Gets a boolean indicating if the pointer is currently locked
  33344. */
  33345. isPointerLock: boolean;
  33346. /**
  33347. * Observable event triggered each time the rendering canvas is resized
  33348. */
  33349. onResizeObservable: Observable<Engine>;
  33350. /**
  33351. * Observable event triggered each time the canvas loses focus
  33352. */
  33353. onCanvasBlurObservable: Observable<Engine>;
  33354. /**
  33355. * Observable event triggered each time the canvas gains focus
  33356. */
  33357. onCanvasFocusObservable: Observable<Engine>;
  33358. /**
  33359. * Observable event triggered each time the canvas receives pointerout event
  33360. */
  33361. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33362. /**
  33363. * Observable raised when the engine begins a new frame
  33364. */
  33365. onBeginFrameObservable: Observable<Engine>;
  33366. /**
  33367. * If set, will be used to request the next animation frame for the render loop
  33368. */
  33369. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33370. /**
  33371. * Observable raised when the engine ends the current frame
  33372. */
  33373. onEndFrameObservable: Observable<Engine>;
  33374. /**
  33375. * Observable raised when the engine is about to compile a shader
  33376. */
  33377. onBeforeShaderCompilationObservable: Observable<Engine>;
  33378. /**
  33379. * Observable raised when the engine has jsut compiled a shader
  33380. */
  33381. onAfterShaderCompilationObservable: Observable<Engine>;
  33382. /**
  33383. * Gets the audio engine
  33384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33385. * @ignorenaming
  33386. */
  33387. static audioEngine: IAudioEngine;
  33388. /**
  33389. * Default AudioEngine factory responsible of creating the Audio Engine.
  33390. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33391. */
  33392. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33393. /**
  33394. * Default offline support factory responsible of creating a tool used to store data locally.
  33395. * By default, this will create a Database object if the workload has been embedded.
  33396. */
  33397. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33398. private _loadingScreen;
  33399. private _pointerLockRequested;
  33400. private _dummyFramebuffer;
  33401. private _rescalePostProcess;
  33402. private _deterministicLockstep;
  33403. private _lockstepMaxSteps;
  33404. private _timeStep;
  33405. protected get _supportsHardwareTextureRescaling(): boolean;
  33406. private _fps;
  33407. private _deltaTime;
  33408. /** @hidden */
  33409. _drawCalls: PerfCounter;
  33410. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33411. canvasTabIndex: number;
  33412. /**
  33413. * Turn this value on if you want to pause FPS computation when in background
  33414. */
  33415. disablePerformanceMonitorInBackground: boolean;
  33416. private _performanceMonitor;
  33417. /**
  33418. * Gets the performance monitor attached to this engine
  33419. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33420. */
  33421. get performanceMonitor(): PerformanceMonitor;
  33422. private _onFocus;
  33423. private _onBlur;
  33424. private _onCanvasPointerOut;
  33425. private _onCanvasBlur;
  33426. private _onCanvasFocus;
  33427. private _onFullscreenChange;
  33428. private _onPointerLockChange;
  33429. /**
  33430. * Gets the HTML element used to attach event listeners
  33431. * @returns a HTML element
  33432. */
  33433. getInputElement(): Nullable<HTMLElement>;
  33434. /**
  33435. * Creates a new engine
  33436. * @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
  33437. * @param antialias defines enable antialiasing (default: false)
  33438. * @param options defines further options to be sent to the getContext() function
  33439. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33440. */
  33441. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33442. /**
  33443. * Gets current aspect ratio
  33444. * @param viewportOwner defines the camera to use to get the aspect ratio
  33445. * @param useScreen defines if screen size must be used (or the current render target if any)
  33446. * @returns a number defining the aspect ratio
  33447. */
  33448. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33449. /**
  33450. * Gets current screen aspect ratio
  33451. * @returns a number defining the aspect ratio
  33452. */
  33453. getScreenAspectRatio(): number;
  33454. /**
  33455. * Gets the client rect of the HTML canvas attached with the current webGL context
  33456. * @returns a client rectanglee
  33457. */
  33458. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33459. /**
  33460. * Gets the client rect of the HTML element used for events
  33461. * @returns a client rectanglee
  33462. */
  33463. getInputElementClientRect(): Nullable<ClientRect>;
  33464. /**
  33465. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33467. * @returns true if engine is in deterministic lock step mode
  33468. */
  33469. isDeterministicLockStep(): boolean;
  33470. /**
  33471. * Gets the max steps when engine is running in deterministic lock step
  33472. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33473. * @returns the max steps
  33474. */
  33475. getLockstepMaxSteps(): number;
  33476. /**
  33477. * Returns the time in ms between steps when using deterministic lock step.
  33478. * @returns time step in (ms)
  33479. */
  33480. getTimeStep(): number;
  33481. /**
  33482. * Force the mipmap generation for the given render target texture
  33483. * @param texture defines the render target texture to use
  33484. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33485. */
  33486. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33487. /** States */
  33488. /**
  33489. * Set various states to the webGL context
  33490. * @param culling defines backface culling state
  33491. * @param zOffset defines the value to apply to zOffset (0 by default)
  33492. * @param force defines if states must be applied even if cache is up to date
  33493. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33494. */
  33495. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33496. /**
  33497. * Set the z offset to apply to current rendering
  33498. * @param value defines the offset to apply
  33499. */
  33500. setZOffset(value: number): void;
  33501. /**
  33502. * Gets the current value of the zOffset
  33503. * @returns the current zOffset state
  33504. */
  33505. getZOffset(): number;
  33506. /**
  33507. * Enable or disable depth buffering
  33508. * @param enable defines the state to set
  33509. */
  33510. setDepthBuffer(enable: boolean): void;
  33511. /**
  33512. * Gets a boolean indicating if depth writing is enabled
  33513. * @returns the current depth writing state
  33514. */
  33515. getDepthWrite(): boolean;
  33516. /**
  33517. * Enable or disable depth writing
  33518. * @param enable defines the state to set
  33519. */
  33520. setDepthWrite(enable: boolean): void;
  33521. /**
  33522. * Gets a boolean indicating if stencil buffer is enabled
  33523. * @returns the current stencil buffer state
  33524. */
  33525. getStencilBuffer(): boolean;
  33526. /**
  33527. * Enable or disable the stencil buffer
  33528. * @param enable defines if the stencil buffer must be enabled or disabled
  33529. */
  33530. setStencilBuffer(enable: boolean): void;
  33531. /**
  33532. * Gets the current stencil mask
  33533. * @returns a number defining the new stencil mask to use
  33534. */
  33535. getStencilMask(): number;
  33536. /**
  33537. * Sets the current stencil mask
  33538. * @param mask defines the new stencil mask to use
  33539. */
  33540. setStencilMask(mask: number): void;
  33541. /**
  33542. * Gets the current stencil function
  33543. * @returns a number defining the stencil function to use
  33544. */
  33545. getStencilFunction(): number;
  33546. /**
  33547. * Gets the current stencil reference value
  33548. * @returns a number defining the stencil reference value to use
  33549. */
  33550. getStencilFunctionReference(): number;
  33551. /**
  33552. * Gets the current stencil mask
  33553. * @returns a number defining the stencil mask to use
  33554. */
  33555. getStencilFunctionMask(): number;
  33556. /**
  33557. * Sets the current stencil function
  33558. * @param stencilFunc defines the new stencil function to use
  33559. */
  33560. setStencilFunction(stencilFunc: number): void;
  33561. /**
  33562. * Sets the current stencil reference
  33563. * @param reference defines the new stencil reference to use
  33564. */
  33565. setStencilFunctionReference(reference: number): void;
  33566. /**
  33567. * Sets the current stencil mask
  33568. * @param mask defines the new stencil mask to use
  33569. */
  33570. setStencilFunctionMask(mask: number): void;
  33571. /**
  33572. * Gets the current stencil operation when stencil fails
  33573. * @returns a number defining stencil operation to use when stencil fails
  33574. */
  33575. getStencilOperationFail(): number;
  33576. /**
  33577. * Gets the current stencil operation when depth fails
  33578. * @returns a number defining stencil operation to use when depth fails
  33579. */
  33580. getStencilOperationDepthFail(): number;
  33581. /**
  33582. * Gets the current stencil operation when stencil passes
  33583. * @returns a number defining stencil operation to use when stencil passes
  33584. */
  33585. getStencilOperationPass(): number;
  33586. /**
  33587. * Sets the stencil operation to use when stencil fails
  33588. * @param operation defines the stencil operation to use when stencil fails
  33589. */
  33590. setStencilOperationFail(operation: number): void;
  33591. /**
  33592. * Sets the stencil operation to use when depth fails
  33593. * @param operation defines the stencil operation to use when depth fails
  33594. */
  33595. setStencilOperationDepthFail(operation: number): void;
  33596. /**
  33597. * Sets the stencil operation to use when stencil passes
  33598. * @param operation defines the stencil operation to use when stencil passes
  33599. */
  33600. setStencilOperationPass(operation: number): void;
  33601. /**
  33602. * Sets a boolean indicating if the dithering state is enabled or disabled
  33603. * @param value defines the dithering state
  33604. */
  33605. setDitheringState(value: boolean): void;
  33606. /**
  33607. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33608. * @param value defines the rasterizer state
  33609. */
  33610. setRasterizerState(value: boolean): void;
  33611. /**
  33612. * Gets the current depth function
  33613. * @returns a number defining the depth function
  33614. */
  33615. getDepthFunction(): Nullable<number>;
  33616. /**
  33617. * Sets the current depth function
  33618. * @param depthFunc defines the function to use
  33619. */
  33620. setDepthFunction(depthFunc: number): void;
  33621. /**
  33622. * Sets the current depth function to GREATER
  33623. */
  33624. setDepthFunctionToGreater(): void;
  33625. /**
  33626. * Sets the current depth function to GEQUAL
  33627. */
  33628. setDepthFunctionToGreaterOrEqual(): void;
  33629. /**
  33630. * Sets the current depth function to LESS
  33631. */
  33632. setDepthFunctionToLess(): void;
  33633. /**
  33634. * Sets the current depth function to LEQUAL
  33635. */
  33636. setDepthFunctionToLessOrEqual(): void;
  33637. private _cachedStencilBuffer;
  33638. private _cachedStencilFunction;
  33639. private _cachedStencilMask;
  33640. private _cachedStencilOperationPass;
  33641. private _cachedStencilOperationFail;
  33642. private _cachedStencilOperationDepthFail;
  33643. private _cachedStencilReference;
  33644. /**
  33645. * Caches the the state of the stencil buffer
  33646. */
  33647. cacheStencilState(): void;
  33648. /**
  33649. * Restores the state of the stencil buffer
  33650. */
  33651. restoreStencilState(): void;
  33652. /**
  33653. * Directly set the WebGL Viewport
  33654. * @param x defines the x coordinate of the viewport (in screen space)
  33655. * @param y defines the y coordinate of the viewport (in screen space)
  33656. * @param width defines the width of the viewport (in screen space)
  33657. * @param height defines the height of the viewport (in screen space)
  33658. * @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
  33659. */
  33660. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33661. /**
  33662. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33663. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33664. * @param y defines the y-coordinate of the corner of the clear rectangle
  33665. * @param width defines the width of the clear rectangle
  33666. * @param height defines the height of the clear rectangle
  33667. * @param clearColor defines the clear color
  33668. */
  33669. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33670. /**
  33671. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33672. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33673. * @param y defines the y-coordinate of the corner of the clear rectangle
  33674. * @param width defines the width of the clear rectangle
  33675. * @param height defines the height of the clear rectangle
  33676. */
  33677. enableScissor(x: number, y: number, width: number, height: number): void;
  33678. /**
  33679. * Disable previously set scissor test rectangle
  33680. */
  33681. disableScissor(): void;
  33682. protected _reportDrawCall(): void;
  33683. /**
  33684. * Initializes a webVR display and starts listening to display change events
  33685. * The onVRDisplayChangedObservable will be notified upon these changes
  33686. * @returns The onVRDisplayChangedObservable
  33687. */
  33688. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33689. /** @hidden */
  33690. _prepareVRComponent(): void;
  33691. /** @hidden */
  33692. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33693. /** @hidden */
  33694. _submitVRFrame(): void;
  33695. /**
  33696. * Call this function to leave webVR mode
  33697. * Will do nothing if webVR is not supported or if there is no webVR device
  33698. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33699. */
  33700. disableVR(): void;
  33701. /**
  33702. * Gets a boolean indicating that the system is in VR mode and is presenting
  33703. * @returns true if VR mode is engaged
  33704. */
  33705. isVRPresenting(): boolean;
  33706. /** @hidden */
  33707. _requestVRFrame(): void;
  33708. /** @hidden */
  33709. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33710. /**
  33711. * Gets the source code of the vertex shader associated with a specific webGL program
  33712. * @param program defines the program to use
  33713. * @returns a string containing the source code of the vertex shader associated with the program
  33714. */
  33715. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33716. /**
  33717. * Gets the source code of the fragment shader associated with a specific webGL program
  33718. * @param program defines the program to use
  33719. * @returns a string containing the source code of the fragment shader associated with the program
  33720. */
  33721. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33722. /**
  33723. * Sets a depth stencil texture from a render target to the according uniform.
  33724. * @param channel The texture channel
  33725. * @param uniform The uniform to set
  33726. * @param texture The render target texture containing the depth stencil texture to apply
  33727. */
  33728. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33729. /**
  33730. * Sets a texture to the webGL context from a postprocess
  33731. * @param channel defines the channel to use
  33732. * @param postProcess defines the source postprocess
  33733. */
  33734. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33735. /**
  33736. * Binds the output of the passed in post process to the texture channel specified
  33737. * @param channel The channel the texture should be bound to
  33738. * @param postProcess The post process which's output should be bound
  33739. */
  33740. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33741. /** @hidden */
  33742. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33743. protected _rebuildBuffers(): void;
  33744. /** @hidden */
  33745. _renderFrame(): void;
  33746. _renderLoop(): void;
  33747. /** @hidden */
  33748. _renderViews(): boolean;
  33749. /**
  33750. * Toggle full screen mode
  33751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33752. */
  33753. switchFullscreen(requestPointerLock: boolean): void;
  33754. /**
  33755. * Enters full screen mode
  33756. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33757. */
  33758. enterFullscreen(requestPointerLock: boolean): void;
  33759. /**
  33760. * Exits full screen mode
  33761. */
  33762. exitFullscreen(): void;
  33763. /**
  33764. * Enters Pointerlock mode
  33765. */
  33766. enterPointerlock(): void;
  33767. /**
  33768. * Exits Pointerlock mode
  33769. */
  33770. exitPointerlock(): void;
  33771. /**
  33772. * Begin a new frame
  33773. */
  33774. beginFrame(): void;
  33775. /**
  33776. * Enf the current frame
  33777. */
  33778. endFrame(): void;
  33779. resize(): void;
  33780. /**
  33781. * Force a specific size of the canvas
  33782. * @param width defines the new canvas' width
  33783. * @param height defines the new canvas' height
  33784. */
  33785. setSize(width: number, height: number): void;
  33786. /**
  33787. * Updates a dynamic vertex buffer.
  33788. * @param vertexBuffer the vertex buffer to update
  33789. * @param data the data used to update the vertex buffer
  33790. * @param byteOffset the byte offset of the data
  33791. * @param byteLength the byte length of the data
  33792. */
  33793. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33794. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33795. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33796. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33797. _releaseTexture(texture: InternalTexture): void;
  33798. /**
  33799. * @hidden
  33800. * Rescales a texture
  33801. * @param source input texutre
  33802. * @param destination destination texture
  33803. * @param scene scene to use to render the resize
  33804. * @param internalFormat format to use when resizing
  33805. * @param onComplete callback to be called when resize has completed
  33806. */
  33807. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33808. /**
  33809. * Gets the current framerate
  33810. * @returns a number representing the framerate
  33811. */
  33812. getFps(): number;
  33813. /**
  33814. * Gets the time spent between current and previous frame
  33815. * @returns a number representing the delta time in ms
  33816. */
  33817. getDeltaTime(): number;
  33818. private _measureFps;
  33819. /** @hidden */
  33820. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33821. /**
  33822. * Update a dynamic index buffer
  33823. * @param indexBuffer defines the target index buffer
  33824. * @param indices defines the data to update
  33825. * @param offset defines the offset in the target index buffer where update should start
  33826. */
  33827. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33828. /**
  33829. * Updates the sample count of a render target texture
  33830. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33831. * @param texture defines the texture to update
  33832. * @param samples defines the sample count to set
  33833. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33834. */
  33835. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33836. /**
  33837. * Updates a depth texture Comparison Mode and Function.
  33838. * If the comparison Function is equal to 0, the mode will be set to none.
  33839. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33840. * @param texture The texture to set the comparison function for
  33841. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33842. */
  33843. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33844. /**
  33845. * Creates a webGL buffer to use with instanciation
  33846. * @param capacity defines the size of the buffer
  33847. * @returns the webGL buffer
  33848. */
  33849. createInstancesBuffer(capacity: number): DataBuffer;
  33850. /**
  33851. * Delete a webGL buffer used with instanciation
  33852. * @param buffer defines the webGL buffer to delete
  33853. */
  33854. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33855. private _clientWaitAsync;
  33856. /** @hidden */
  33857. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33858. /** @hidden */
  33859. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33860. dispose(): void;
  33861. private _disableTouchAction;
  33862. /**
  33863. * Display the loading screen
  33864. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33865. */
  33866. displayLoadingUI(): void;
  33867. /**
  33868. * Hide the loading screen
  33869. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33870. */
  33871. hideLoadingUI(): void;
  33872. /**
  33873. * Gets the current loading screen object
  33874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33875. */
  33876. get loadingScreen(): ILoadingScreen;
  33877. /**
  33878. * Sets the current loading screen object
  33879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33880. */
  33881. set loadingScreen(loadingScreen: ILoadingScreen);
  33882. /**
  33883. * Sets the current loading screen text
  33884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33885. */
  33886. set loadingUIText(text: string);
  33887. /**
  33888. * Sets the current loading screen background color
  33889. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33890. */
  33891. set loadingUIBackgroundColor(color: string);
  33892. /** Pointerlock and fullscreen */
  33893. /**
  33894. * Ask the browser to promote the current element to pointerlock mode
  33895. * @param element defines the DOM element to promote
  33896. */
  33897. static _RequestPointerlock(element: HTMLElement): void;
  33898. /**
  33899. * Asks the browser to exit pointerlock mode
  33900. */
  33901. static _ExitPointerlock(): void;
  33902. /**
  33903. * Ask the browser to promote the current element to fullscreen rendering mode
  33904. * @param element defines the DOM element to promote
  33905. */
  33906. static _RequestFullscreen(element: HTMLElement): void;
  33907. /**
  33908. * Asks the browser to exit fullscreen mode
  33909. */
  33910. static _ExitFullscreen(): void;
  33911. }
  33912. }
  33913. declare module BABYLON {
  33914. /**
  33915. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33916. * during the life time of the application.
  33917. */
  33918. export class EngineStore {
  33919. /** Gets the list of created engines */
  33920. static Instances: Engine[];
  33921. /** @hidden */
  33922. static _LastCreatedScene: Nullable<Scene>;
  33923. /**
  33924. * Gets the latest created engine
  33925. */
  33926. static get LastCreatedEngine(): Nullable<Engine>;
  33927. /**
  33928. * Gets the latest created scene
  33929. */
  33930. static get LastCreatedScene(): Nullable<Scene>;
  33931. /**
  33932. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33933. * @ignorenaming
  33934. */
  33935. static UseFallbackTexture: boolean;
  33936. /**
  33937. * Texture content used if a texture cannot loaded
  33938. * @ignorenaming
  33939. */
  33940. static FallbackTexture: string;
  33941. }
  33942. }
  33943. declare module BABYLON {
  33944. /**
  33945. * Helper class that provides a small promise polyfill
  33946. */
  33947. export class PromisePolyfill {
  33948. /**
  33949. * Static function used to check if the polyfill is required
  33950. * If this is the case then the function will inject the polyfill to window.Promise
  33951. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33952. */
  33953. static Apply(force?: boolean): void;
  33954. }
  33955. }
  33956. declare module BABYLON {
  33957. /**
  33958. * Interface for screenshot methods with describe argument called `size` as object with options
  33959. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33960. */
  33961. export interface IScreenshotSize {
  33962. /**
  33963. * number in pixels for canvas height
  33964. */
  33965. height?: number;
  33966. /**
  33967. * multiplier allowing render at a higher or lower resolution
  33968. * If value is defined then height and width will be ignored and taken from camera
  33969. */
  33970. precision?: number;
  33971. /**
  33972. * number in pixels for canvas width
  33973. */
  33974. width?: number;
  33975. }
  33976. }
  33977. declare module BABYLON {
  33978. interface IColor4Like {
  33979. r: float;
  33980. g: float;
  33981. b: float;
  33982. a: float;
  33983. }
  33984. /**
  33985. * Class containing a set of static utilities functions
  33986. */
  33987. export class Tools {
  33988. /**
  33989. * Gets or sets the base URL to use to load assets
  33990. */
  33991. static get BaseUrl(): string;
  33992. static set BaseUrl(value: string);
  33993. /**
  33994. * Enable/Disable Custom HTTP Request Headers globally.
  33995. * default = false
  33996. * @see CustomRequestHeaders
  33997. */
  33998. static UseCustomRequestHeaders: boolean;
  33999. /**
  34000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34001. * i.e. when loading files, where the server/service expects an Authorization header
  34002. */
  34003. static CustomRequestHeaders: {
  34004. [key: string]: string;
  34005. };
  34006. /**
  34007. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34008. */
  34009. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34010. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34011. /**
  34012. * Default behaviour for cors in the application.
  34013. * It can be a string if the expected behavior is identical in the entire app.
  34014. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34015. */
  34016. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34017. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34018. /**
  34019. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34020. * @ignorenaming
  34021. */
  34022. static get UseFallbackTexture(): boolean;
  34023. static set UseFallbackTexture(value: boolean);
  34024. /**
  34025. * Use this object to register external classes like custom textures or material
  34026. * to allow the laoders to instantiate them
  34027. */
  34028. static get RegisteredExternalClasses(): {
  34029. [key: string]: Object;
  34030. };
  34031. static set RegisteredExternalClasses(classes: {
  34032. [key: string]: Object;
  34033. });
  34034. /**
  34035. * Texture content used if a texture cannot loaded
  34036. * @ignorenaming
  34037. */
  34038. static get fallbackTexture(): string;
  34039. static set fallbackTexture(value: string);
  34040. /**
  34041. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34042. * @param u defines the coordinate on X axis
  34043. * @param v defines the coordinate on Y axis
  34044. * @param width defines the width of the source data
  34045. * @param height defines the height of the source data
  34046. * @param pixels defines the source byte array
  34047. * @param color defines the output color
  34048. */
  34049. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34050. /**
  34051. * Interpolates between a and b via alpha
  34052. * @param a The lower value (returned when alpha = 0)
  34053. * @param b The upper value (returned when alpha = 1)
  34054. * @param alpha The interpolation-factor
  34055. * @return The mixed value
  34056. */
  34057. static Mix(a: number, b: number, alpha: number): number;
  34058. /**
  34059. * Tries to instantiate a new object from a given class name
  34060. * @param className defines the class name to instantiate
  34061. * @returns the new object or null if the system was not able to do the instantiation
  34062. */
  34063. static Instantiate(className: string): any;
  34064. /**
  34065. * Provides a slice function that will work even on IE
  34066. * @param data defines the array to slice
  34067. * @param start defines the start of the data (optional)
  34068. * @param end defines the end of the data (optional)
  34069. * @returns the new sliced array
  34070. */
  34071. static Slice<T>(data: T, start?: number, end?: number): T;
  34072. /**
  34073. * Polyfill for setImmediate
  34074. * @param action defines the action to execute after the current execution block
  34075. */
  34076. static SetImmediate(action: () => void): void;
  34077. /**
  34078. * Function indicating if a number is an exponent of 2
  34079. * @param value defines the value to test
  34080. * @returns true if the value is an exponent of 2
  34081. */
  34082. static IsExponentOfTwo(value: number): boolean;
  34083. private static _tmpFloatArray;
  34084. /**
  34085. * Returns the nearest 32-bit single precision float representation of a Number
  34086. * @param value A Number. If the parameter is of a different type, it will get converted
  34087. * to a number or to NaN if it cannot be converted
  34088. * @returns number
  34089. */
  34090. static FloatRound(value: number): number;
  34091. /**
  34092. * Extracts the filename from a path
  34093. * @param path defines the path to use
  34094. * @returns the filename
  34095. */
  34096. static GetFilename(path: string): string;
  34097. /**
  34098. * Extracts the "folder" part of a path (everything before the filename).
  34099. * @param uri The URI to extract the info from
  34100. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34101. * @returns The "folder" part of the path
  34102. */
  34103. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34104. /**
  34105. * Extracts text content from a DOM element hierarchy
  34106. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34107. */
  34108. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34109. /**
  34110. * Convert an angle in radians to degrees
  34111. * @param angle defines the angle to convert
  34112. * @returns the angle in degrees
  34113. */
  34114. static ToDegrees(angle: number): number;
  34115. /**
  34116. * Convert an angle in degrees to radians
  34117. * @param angle defines the angle to convert
  34118. * @returns the angle in radians
  34119. */
  34120. static ToRadians(angle: number): number;
  34121. /**
  34122. * Returns an array if obj is not an array
  34123. * @param obj defines the object to evaluate as an array
  34124. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34125. * @returns either obj directly if obj is an array or a new array containing obj
  34126. */
  34127. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34128. /**
  34129. * Gets the pointer prefix to use
  34130. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34131. */
  34132. static GetPointerPrefix(): string;
  34133. /**
  34134. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34135. * @param url define the url we are trying
  34136. * @param element define the dom element where to configure the cors policy
  34137. */
  34138. static SetCorsBehavior(url: string | string[], element: {
  34139. crossOrigin: string | null;
  34140. }): void;
  34141. /**
  34142. * Removes unwanted characters from an url
  34143. * @param url defines the url to clean
  34144. * @returns the cleaned url
  34145. */
  34146. static CleanUrl(url: string): string;
  34147. /**
  34148. * Gets or sets a function used to pre-process url before using them to load assets
  34149. */
  34150. static get PreprocessUrl(): (url: string) => string;
  34151. static set PreprocessUrl(processor: (url: string) => string);
  34152. /**
  34153. * Loads an image as an HTMLImageElement.
  34154. * @param input url string, ArrayBuffer, or Blob to load
  34155. * @param onLoad callback called when the image successfully loads
  34156. * @param onError callback called when the image fails to load
  34157. * @param offlineProvider offline provider for caching
  34158. * @param mimeType optional mime type
  34159. * @returns the HTMLImageElement of the loaded image
  34160. */
  34161. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34162. /**
  34163. * Loads a file from a url
  34164. * @param url url string, ArrayBuffer, or Blob to load
  34165. * @param onSuccess callback called when the file successfully loads
  34166. * @param onProgress callback called while file is loading (if the server supports this mode)
  34167. * @param offlineProvider defines the offline provider for caching
  34168. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34169. * @param onError callback called when the file fails to load
  34170. * @returns a file request object
  34171. */
  34172. 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;
  34173. /**
  34174. * Loads a file from a url
  34175. * @param url the file url to load
  34176. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34177. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34178. */
  34179. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34180. /**
  34181. * Load a script (identified by an url). When the url returns, the
  34182. * content of this file is added into a new script element, attached to the DOM (body element)
  34183. * @param scriptUrl defines the url of the script to laod
  34184. * @param onSuccess defines the callback called when the script is loaded
  34185. * @param onError defines the callback to call if an error occurs
  34186. * @param scriptId defines the id of the script element
  34187. */
  34188. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34189. /**
  34190. * Load an asynchronous script (identified by an url). When the url returns, the
  34191. * content of this file is added into a new script element, attached to the DOM (body element)
  34192. * @param scriptUrl defines the url of the script to laod
  34193. * @param scriptId defines the id of the script element
  34194. * @returns a promise request object
  34195. */
  34196. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34197. /**
  34198. * Loads a file from a blob
  34199. * @param fileToLoad defines the blob to use
  34200. * @param callback defines the callback to call when data is loaded
  34201. * @param progressCallback defines the callback to call during loading process
  34202. * @returns a file request object
  34203. */
  34204. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34205. /**
  34206. * Reads a file from a File object
  34207. * @param file defines the file to load
  34208. * @param onSuccess defines the callback to call when data is loaded
  34209. * @param onProgress defines the callback to call during loading process
  34210. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34211. * @param onError defines the callback to call when an error occurs
  34212. * @returns a file request object
  34213. */
  34214. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34215. /**
  34216. * Creates a data url from a given string content
  34217. * @param content defines the content to convert
  34218. * @returns the new data url link
  34219. */
  34220. static FileAsURL(content: string): string;
  34221. /**
  34222. * Format the given number to a specific decimal format
  34223. * @param value defines the number to format
  34224. * @param decimals defines the number of decimals to use
  34225. * @returns the formatted string
  34226. */
  34227. static Format(value: number, decimals?: number): string;
  34228. /**
  34229. * Tries to copy an object by duplicating every property
  34230. * @param source defines the source object
  34231. * @param destination defines the target object
  34232. * @param doNotCopyList defines a list of properties to avoid
  34233. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34234. */
  34235. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34236. /**
  34237. * Gets a boolean indicating if the given object has no own property
  34238. * @param obj defines the object to test
  34239. * @returns true if object has no own property
  34240. */
  34241. static IsEmpty(obj: any): boolean;
  34242. /**
  34243. * Function used to register events at window level
  34244. * @param windowElement defines the Window object to use
  34245. * @param events defines the events to register
  34246. */
  34247. static RegisterTopRootEvents(windowElement: Window, events: {
  34248. name: string;
  34249. handler: Nullable<(e: FocusEvent) => any>;
  34250. }[]): void;
  34251. /**
  34252. * Function used to unregister events from window level
  34253. * @param windowElement defines the Window object to use
  34254. * @param events defines the events to unregister
  34255. */
  34256. static UnregisterTopRootEvents(windowElement: Window, events: {
  34257. name: string;
  34258. handler: Nullable<(e: FocusEvent) => any>;
  34259. }[]): void;
  34260. /**
  34261. * @ignore
  34262. */
  34263. static _ScreenshotCanvas: HTMLCanvasElement;
  34264. /**
  34265. * Dumps the current bound framebuffer
  34266. * @param width defines the rendering width
  34267. * @param height defines the rendering height
  34268. * @param engine defines the hosting engine
  34269. * @param successCallback defines the callback triggered once the data are available
  34270. * @param mimeType defines the mime type of the result
  34271. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34272. */
  34273. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34274. /**
  34275. * Converts the canvas data to blob.
  34276. * This acts as a polyfill for browsers not supporting the to blob function.
  34277. * @param canvas Defines the canvas to extract the data from
  34278. * @param successCallback Defines the callback triggered once the data are available
  34279. * @param mimeType Defines the mime type of the result
  34280. */
  34281. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34282. /**
  34283. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34284. * @param successCallback defines the callback triggered once the data are available
  34285. * @param mimeType defines the mime type of the result
  34286. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34287. */
  34288. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34289. /**
  34290. * Downloads a blob in the browser
  34291. * @param blob defines the blob to download
  34292. * @param fileName defines the name of the downloaded file
  34293. */
  34294. static Download(blob: Blob, fileName: string): void;
  34295. /**
  34296. * Captures a screenshot of the current rendering
  34297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34298. * @param engine defines the rendering engine
  34299. * @param camera defines the source camera
  34300. * @param size This parameter can be set to a single number or to an object with the
  34301. * following (optional) properties: precision, width, height. If a single number is passed,
  34302. * it will be used for both width and height. If an object is passed, the screenshot size
  34303. * will be derived from the parameters. The precision property is a multiplier allowing
  34304. * rendering at a higher or lower resolution
  34305. * @param successCallback defines the callback receives a single parameter which contains the
  34306. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34307. * src parameter of an <img> to display it
  34308. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34309. * Check your browser for supported MIME types
  34310. */
  34311. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34312. /**
  34313. * Captures a screenshot of the current rendering
  34314. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34315. * @param engine defines the rendering engine
  34316. * @param camera defines the source camera
  34317. * @param size This parameter can be set to a single number or to an object with the
  34318. * following (optional) properties: precision, width, height. If a single number is passed,
  34319. * it will be used for both width and height. If an object is passed, the screenshot size
  34320. * will be derived from the parameters. The precision property is a multiplier allowing
  34321. * rendering at a higher or lower resolution
  34322. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34323. * Check your browser for supported MIME types
  34324. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34325. * to the src parameter of an <img> to display it
  34326. */
  34327. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34328. /**
  34329. * Generates an image screenshot from the specified camera.
  34330. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34331. * @param engine The engine to use for rendering
  34332. * @param camera The camera to use for rendering
  34333. * @param size This parameter can be set to a single number or to an object with the
  34334. * following (optional) properties: precision, width, height. If a single number is passed,
  34335. * it will be used for both width and height. If an object is passed, the screenshot size
  34336. * will be derived from the parameters. The precision property is a multiplier allowing
  34337. * rendering at a higher or lower resolution
  34338. * @param successCallback The callback receives a single parameter which contains the
  34339. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34340. * src parameter of an <img> to display it
  34341. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34342. * Check your browser for supported MIME types
  34343. * @param samples Texture samples (default: 1)
  34344. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34345. * @param fileName A name for for the downloaded file.
  34346. */
  34347. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34348. /**
  34349. * Generates an image screenshot from the specified camera.
  34350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34351. * @param engine The engine to use for rendering
  34352. * @param camera The camera to use for rendering
  34353. * @param size This parameter can be set to a single number or to an object with the
  34354. * following (optional) properties: precision, width, height. If a single number is passed,
  34355. * it will be used for both width and height. If an object is passed, the screenshot size
  34356. * will be derived from the parameters. The precision property is a multiplier allowing
  34357. * rendering at a higher or lower resolution
  34358. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34359. * Check your browser for supported MIME types
  34360. * @param samples Texture samples (default: 1)
  34361. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34362. * @param fileName A name for for the downloaded file.
  34363. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34364. * to the src parameter of an <img> to display it
  34365. */
  34366. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34367. /**
  34368. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34369. * Be aware Math.random() could cause collisions, but:
  34370. * "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"
  34371. * @returns a pseudo random id
  34372. */
  34373. static RandomId(): string;
  34374. /**
  34375. * Test if the given uri is a base64 string
  34376. * @param uri The uri to test
  34377. * @return True if the uri is a base64 string or false otherwise
  34378. */
  34379. static IsBase64(uri: string): boolean;
  34380. /**
  34381. * Decode the given base64 uri.
  34382. * @param uri The uri to decode
  34383. * @return The decoded base64 data.
  34384. */
  34385. static DecodeBase64(uri: string): ArrayBuffer;
  34386. /**
  34387. * Gets the absolute url.
  34388. * @param url the input url
  34389. * @return the absolute url
  34390. */
  34391. static GetAbsoluteUrl(url: string): string;
  34392. /**
  34393. * No log
  34394. */
  34395. static readonly NoneLogLevel: number;
  34396. /**
  34397. * Only message logs
  34398. */
  34399. static readonly MessageLogLevel: number;
  34400. /**
  34401. * Only warning logs
  34402. */
  34403. static readonly WarningLogLevel: number;
  34404. /**
  34405. * Only error logs
  34406. */
  34407. static readonly ErrorLogLevel: number;
  34408. /**
  34409. * All logs
  34410. */
  34411. static readonly AllLogLevel: number;
  34412. /**
  34413. * Gets a value indicating the number of loading errors
  34414. * @ignorenaming
  34415. */
  34416. static get errorsCount(): number;
  34417. /**
  34418. * Callback called when a new log is added
  34419. */
  34420. static OnNewCacheEntry: (entry: string) => void;
  34421. /**
  34422. * Log a message to the console
  34423. * @param message defines the message to log
  34424. */
  34425. static Log(message: string): void;
  34426. /**
  34427. * Write a warning message to the console
  34428. * @param message defines the message to log
  34429. */
  34430. static Warn(message: string): void;
  34431. /**
  34432. * Write an error message to the console
  34433. * @param message defines the message to log
  34434. */
  34435. static Error(message: string): void;
  34436. /**
  34437. * Gets current log cache (list of logs)
  34438. */
  34439. static get LogCache(): string;
  34440. /**
  34441. * Clears the log cache
  34442. */
  34443. static ClearLogCache(): void;
  34444. /**
  34445. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34446. */
  34447. static set LogLevels(level: number);
  34448. /**
  34449. * Checks if the window object exists
  34450. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34451. */
  34452. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34453. /**
  34454. * No performance log
  34455. */
  34456. static readonly PerformanceNoneLogLevel: number;
  34457. /**
  34458. * Use user marks to log performance
  34459. */
  34460. static readonly PerformanceUserMarkLogLevel: number;
  34461. /**
  34462. * Log performance to the console
  34463. */
  34464. static readonly PerformanceConsoleLogLevel: number;
  34465. private static _performance;
  34466. /**
  34467. * Sets the current performance log level
  34468. */
  34469. static set PerformanceLogLevel(level: number);
  34470. private static _StartPerformanceCounterDisabled;
  34471. private static _EndPerformanceCounterDisabled;
  34472. private static _StartUserMark;
  34473. private static _EndUserMark;
  34474. private static _StartPerformanceConsole;
  34475. private static _EndPerformanceConsole;
  34476. /**
  34477. * Starts a performance counter
  34478. */
  34479. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34480. /**
  34481. * Ends a specific performance coutner
  34482. */
  34483. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34484. /**
  34485. * Gets either window.performance.now() if supported or Date.now() else
  34486. */
  34487. static get Now(): number;
  34488. /**
  34489. * This method will return the name of the class used to create the instance of the given object.
  34490. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34491. * @param object the object to get the class name from
  34492. * @param isType defines if the object is actually a type
  34493. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34494. */
  34495. static GetClassName(object: any, isType?: boolean): string;
  34496. /**
  34497. * Gets the first element of an array satisfying a given predicate
  34498. * @param array defines the array to browse
  34499. * @param predicate defines the predicate to use
  34500. * @returns null if not found or the element
  34501. */
  34502. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34503. /**
  34504. * This method will return the name of the full name of the class, including its owning module (if any).
  34505. * 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).
  34506. * @param object the object to get the class name from
  34507. * @param isType defines if the object is actually a type
  34508. * @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.
  34509. * @ignorenaming
  34510. */
  34511. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34512. /**
  34513. * Returns a promise that resolves after the given amount of time.
  34514. * @param delay Number of milliseconds to delay
  34515. * @returns Promise that resolves after the given amount of time
  34516. */
  34517. static DelayAsync(delay: number): Promise<void>;
  34518. /**
  34519. * Utility function to detect if the current user agent is Safari
  34520. * @returns whether or not the current user agent is safari
  34521. */
  34522. static IsSafari(): boolean;
  34523. }
  34524. /**
  34525. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34526. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34527. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34528. * @param name The name of the class, case should be preserved
  34529. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34530. */
  34531. export function className(name: string, module?: string): (target: Object) => void;
  34532. /**
  34533. * An implementation of a loop for asynchronous functions.
  34534. */
  34535. export class AsyncLoop {
  34536. /**
  34537. * Defines the number of iterations for the loop
  34538. */
  34539. iterations: number;
  34540. /**
  34541. * Defines the current index of the loop.
  34542. */
  34543. index: number;
  34544. private _done;
  34545. private _fn;
  34546. private _successCallback;
  34547. /**
  34548. * Constructor.
  34549. * @param iterations the number of iterations.
  34550. * @param func the function to run each iteration
  34551. * @param successCallback the callback that will be called upon succesful execution
  34552. * @param offset starting offset.
  34553. */
  34554. constructor(
  34555. /**
  34556. * Defines the number of iterations for the loop
  34557. */
  34558. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34559. /**
  34560. * Execute the next iteration. Must be called after the last iteration was finished.
  34561. */
  34562. executeNext(): void;
  34563. /**
  34564. * Break the loop and run the success callback.
  34565. */
  34566. breakLoop(): void;
  34567. /**
  34568. * Create and run an async loop.
  34569. * @param iterations the number of iterations.
  34570. * @param fn the function to run each iteration
  34571. * @param successCallback the callback that will be called upon succesful execution
  34572. * @param offset starting offset.
  34573. * @returns the created async loop object
  34574. */
  34575. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34576. /**
  34577. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34578. * @param iterations total number of iterations
  34579. * @param syncedIterations number of synchronous iterations in each async iteration.
  34580. * @param fn the function to call each iteration.
  34581. * @param callback a success call back that will be called when iterating stops.
  34582. * @param breakFunction a break condition (optional)
  34583. * @param timeout timeout settings for the setTimeout function. default - 0.
  34584. * @returns the created async loop object
  34585. */
  34586. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34587. }
  34588. }
  34589. declare module BABYLON {
  34590. /**
  34591. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34592. * The underlying implementation relies on an associative array to ensure the best performances.
  34593. * The value can be anything including 'null' but except 'undefined'
  34594. */
  34595. export class StringDictionary<T> {
  34596. /**
  34597. * This will clear this dictionary and copy the content from the 'source' one.
  34598. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34599. * @param source the dictionary to take the content from and copy to this dictionary
  34600. */
  34601. copyFrom(source: StringDictionary<T>): void;
  34602. /**
  34603. * Get a value based from its key
  34604. * @param key the given key to get the matching value from
  34605. * @return the value if found, otherwise undefined is returned
  34606. */
  34607. get(key: string): T | undefined;
  34608. /**
  34609. * Get a value from its key or add it if it doesn't exist.
  34610. * This method will ensure you that a given key/data will be present in the dictionary.
  34611. * @param key the given key to get the matching value from
  34612. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34613. * The factory will only be invoked if there's no data for the given key.
  34614. * @return the value corresponding to the key.
  34615. */
  34616. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34617. /**
  34618. * Get a value from its key if present in the dictionary otherwise add it
  34619. * @param key the key to get the value from
  34620. * @param val if there's no such key/value pair in the dictionary add it with this value
  34621. * @return the value corresponding to the key
  34622. */
  34623. getOrAdd(key: string, val: T): T;
  34624. /**
  34625. * Check if there's a given key in the dictionary
  34626. * @param key the key to check for
  34627. * @return true if the key is present, false otherwise
  34628. */
  34629. contains(key: string): boolean;
  34630. /**
  34631. * Add a new key and its corresponding value
  34632. * @param key the key to add
  34633. * @param value the value corresponding to the key
  34634. * @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
  34635. */
  34636. add(key: string, value: T): boolean;
  34637. /**
  34638. * Update a specific value associated to a key
  34639. * @param key defines the key to use
  34640. * @param value defines the value to store
  34641. * @returns true if the value was updated (or false if the key was not found)
  34642. */
  34643. set(key: string, value: T): boolean;
  34644. /**
  34645. * Get the element of the given key and remove it from the dictionary
  34646. * @param key defines the key to search
  34647. * @returns the value associated with the key or null if not found
  34648. */
  34649. getAndRemove(key: string): Nullable<T>;
  34650. /**
  34651. * Remove a key/value from the dictionary.
  34652. * @param key the key to remove
  34653. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34654. */
  34655. remove(key: string): boolean;
  34656. /**
  34657. * Clear the whole content of the dictionary
  34658. */
  34659. clear(): void;
  34660. /**
  34661. * Gets the current count
  34662. */
  34663. get count(): number;
  34664. /**
  34665. * Execute a callback on each key/val of the dictionary.
  34666. * Note that you can remove any element in this dictionary in the callback implementation
  34667. * @param callback the callback to execute on a given key/value pair
  34668. */
  34669. forEach(callback: (key: string, val: T) => void): void;
  34670. /**
  34671. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34672. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34673. * Note that you can remove any element in this dictionary in the callback implementation
  34674. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34675. * @returns the first item
  34676. */
  34677. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34678. private _count;
  34679. private _data;
  34680. }
  34681. }
  34682. declare module BABYLON {
  34683. /** @hidden */
  34684. export interface ICollisionCoordinator {
  34685. createCollider(): Collider;
  34686. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34687. init(scene: Scene): void;
  34688. }
  34689. /** @hidden */
  34690. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34691. private _scene;
  34692. private _scaledPosition;
  34693. private _scaledVelocity;
  34694. private _finalPosition;
  34695. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34696. createCollider(): Collider;
  34697. init(scene: Scene): void;
  34698. private _collideWithWorld;
  34699. }
  34700. }
  34701. declare module BABYLON {
  34702. /**
  34703. * Class used to manage all inputs for the scene.
  34704. */
  34705. export class InputManager {
  34706. /** The distance in pixel that you have to move to prevent some events */
  34707. static DragMovementThreshold: number;
  34708. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34709. static LongPressDelay: number;
  34710. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34711. static DoubleClickDelay: number;
  34712. /** If you need to check double click without raising a single click at first click, enable this flag */
  34713. static ExclusiveDoubleClickMode: boolean;
  34714. private _wheelEventName;
  34715. private _onPointerMove;
  34716. private _onPointerDown;
  34717. private _onPointerUp;
  34718. private _initClickEvent;
  34719. private _initActionManager;
  34720. private _delayedSimpleClick;
  34721. private _delayedSimpleClickTimeout;
  34722. private _previousDelayedSimpleClickTimeout;
  34723. private _meshPickProceed;
  34724. private _previousButtonPressed;
  34725. private _currentPickResult;
  34726. private _previousPickResult;
  34727. private _totalPointersPressed;
  34728. private _doubleClickOccured;
  34729. private _pointerOverMesh;
  34730. private _pickedDownMesh;
  34731. private _pickedUpMesh;
  34732. private _pointerX;
  34733. private _pointerY;
  34734. private _unTranslatedPointerX;
  34735. private _unTranslatedPointerY;
  34736. private _startingPointerPosition;
  34737. private _previousStartingPointerPosition;
  34738. private _startingPointerTime;
  34739. private _previousStartingPointerTime;
  34740. private _pointerCaptures;
  34741. private _onKeyDown;
  34742. private _onKeyUp;
  34743. private _onCanvasFocusObserver;
  34744. private _onCanvasBlurObserver;
  34745. private _scene;
  34746. /**
  34747. * Creates a new InputManager
  34748. * @param scene defines the hosting scene
  34749. */
  34750. constructor(scene: Scene);
  34751. /**
  34752. * Gets the mesh that is currently under the pointer
  34753. */
  34754. get meshUnderPointer(): Nullable<AbstractMesh>;
  34755. /**
  34756. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34757. */
  34758. get unTranslatedPointer(): Vector2;
  34759. /**
  34760. * Gets or sets the current on-screen X position of the pointer
  34761. */
  34762. get pointerX(): number;
  34763. set pointerX(value: number);
  34764. /**
  34765. * Gets or sets the current on-screen Y position of the pointer
  34766. */
  34767. get pointerY(): number;
  34768. set pointerY(value: number);
  34769. private _updatePointerPosition;
  34770. private _processPointerMove;
  34771. private _setRayOnPointerInfo;
  34772. private _checkPrePointerObservable;
  34773. /**
  34774. * Use this method to simulate a pointer move on a mesh
  34775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34778. */
  34779. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34780. /**
  34781. * Use this method to simulate a pointer down on a mesh
  34782. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34783. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34784. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34785. */
  34786. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34787. private _processPointerDown;
  34788. /** @hidden */
  34789. _isPointerSwiping(): boolean;
  34790. /**
  34791. * Use this method to simulate a pointer up on a mesh
  34792. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34793. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34794. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34795. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34796. */
  34797. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34798. private _processPointerUp;
  34799. /**
  34800. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34801. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34802. * @returns true if the pointer was captured
  34803. */
  34804. isPointerCaptured(pointerId?: number): boolean;
  34805. /**
  34806. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34807. * @param attachUp defines if you want to attach events to pointerup
  34808. * @param attachDown defines if you want to attach events to pointerdown
  34809. * @param attachMove defines if you want to attach events to pointermove
  34810. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34811. */
  34812. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34813. /**
  34814. * Detaches all event handlers
  34815. */
  34816. detachControl(): void;
  34817. /**
  34818. * Force the value of meshUnderPointer
  34819. * @param mesh defines the mesh to use
  34820. */
  34821. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34822. /**
  34823. * Gets the mesh under the pointer
  34824. * @returns a Mesh or null if no mesh is under the pointer
  34825. */
  34826. getPointerOverMesh(): Nullable<AbstractMesh>;
  34827. }
  34828. }
  34829. declare module BABYLON {
  34830. /**
  34831. * Helper class used to generate session unique ID
  34832. */
  34833. export class UniqueIdGenerator {
  34834. private static _UniqueIdCounter;
  34835. /**
  34836. * Gets an unique (relatively to the current scene) Id
  34837. */
  34838. static get UniqueId(): number;
  34839. }
  34840. }
  34841. declare module BABYLON {
  34842. /**
  34843. * This class defines the direct association between an animation and a target
  34844. */
  34845. export class TargetedAnimation {
  34846. /**
  34847. * Animation to perform
  34848. */
  34849. animation: Animation;
  34850. /**
  34851. * Target to animate
  34852. */
  34853. target: any;
  34854. /**
  34855. * Serialize the object
  34856. * @returns the JSON object representing the current entity
  34857. */
  34858. serialize(): any;
  34859. }
  34860. /**
  34861. * Use this class to create coordinated animations on multiple targets
  34862. */
  34863. export class AnimationGroup implements IDisposable {
  34864. /** The name of the animation group */
  34865. name: string;
  34866. private _scene;
  34867. private _targetedAnimations;
  34868. private _animatables;
  34869. private _from;
  34870. private _to;
  34871. private _isStarted;
  34872. private _isPaused;
  34873. private _speedRatio;
  34874. private _loopAnimation;
  34875. /**
  34876. * Gets or sets the unique id of the node
  34877. */
  34878. uniqueId: number;
  34879. /**
  34880. * This observable will notify when one animation have ended
  34881. */
  34882. onAnimationEndObservable: Observable<TargetedAnimation>;
  34883. /**
  34884. * Observer raised when one animation loops
  34885. */
  34886. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34887. /**
  34888. * Observer raised when all animations have looped
  34889. */
  34890. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34891. /**
  34892. * This observable will notify when all animations have ended.
  34893. */
  34894. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34895. /**
  34896. * This observable will notify when all animations have paused.
  34897. */
  34898. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34899. /**
  34900. * This observable will notify when all animations are playing.
  34901. */
  34902. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34903. /**
  34904. * Gets the first frame
  34905. */
  34906. get from(): number;
  34907. /**
  34908. * Gets the last frame
  34909. */
  34910. get to(): number;
  34911. /**
  34912. * Define if the animations are started
  34913. */
  34914. get isStarted(): boolean;
  34915. /**
  34916. * Gets a value indicating that the current group is playing
  34917. */
  34918. get isPlaying(): boolean;
  34919. /**
  34920. * Gets or sets the speed ratio to use for all animations
  34921. */
  34922. get speedRatio(): number;
  34923. /**
  34924. * Gets or sets the speed ratio to use for all animations
  34925. */
  34926. set speedRatio(value: number);
  34927. /**
  34928. * Gets or sets if all animations should loop or not
  34929. */
  34930. get loopAnimation(): boolean;
  34931. set loopAnimation(value: boolean);
  34932. /**
  34933. * Gets the targeted animations for this animation group
  34934. */
  34935. get targetedAnimations(): Array<TargetedAnimation>;
  34936. /**
  34937. * returning the list of animatables controlled by this animation group.
  34938. */
  34939. get animatables(): Array<Animatable>;
  34940. /**
  34941. * Instantiates a new Animation Group.
  34942. * This helps managing several animations at once.
  34943. * @see http://doc.babylonjs.com/how_to/group
  34944. * @param name Defines the name of the group
  34945. * @param scene Defines the scene the group belongs to
  34946. */
  34947. constructor(
  34948. /** The name of the animation group */
  34949. name: string, scene?: Nullable<Scene>);
  34950. /**
  34951. * Add an animation (with its target) in the group
  34952. * @param animation defines the animation we want to add
  34953. * @param target defines the target of the animation
  34954. * @returns the TargetedAnimation object
  34955. */
  34956. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34957. /**
  34958. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34959. * It can add constant keys at begin or end
  34960. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34961. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34962. * @returns the animation group
  34963. */
  34964. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34965. private _animationLoopCount;
  34966. private _animationLoopFlags;
  34967. private _processLoop;
  34968. /**
  34969. * Start all animations on given targets
  34970. * @param loop defines if animations must loop
  34971. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34972. * @param from defines the from key (optional)
  34973. * @param to defines the to key (optional)
  34974. * @returns the current animation group
  34975. */
  34976. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34977. /**
  34978. * Pause all animations
  34979. * @returns the animation group
  34980. */
  34981. pause(): AnimationGroup;
  34982. /**
  34983. * Play all animations to initial state
  34984. * This function will start() the animations if they were not started or will restart() them if they were paused
  34985. * @param loop defines if animations must loop
  34986. * @returns the animation group
  34987. */
  34988. play(loop?: boolean): AnimationGroup;
  34989. /**
  34990. * Reset all animations to initial state
  34991. * @returns the animation group
  34992. */
  34993. reset(): AnimationGroup;
  34994. /**
  34995. * Restart animations from key 0
  34996. * @returns the animation group
  34997. */
  34998. restart(): AnimationGroup;
  34999. /**
  35000. * Stop all animations
  35001. * @returns the animation group
  35002. */
  35003. stop(): AnimationGroup;
  35004. /**
  35005. * Set animation weight for all animatables
  35006. * @param weight defines the weight to use
  35007. * @return the animationGroup
  35008. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35009. */
  35010. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35011. /**
  35012. * Synchronize and normalize all animatables with a source animatable
  35013. * @param root defines the root animatable to synchronize with
  35014. * @return the animationGroup
  35015. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35016. */
  35017. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35018. /**
  35019. * Goes to a specific frame in this animation group
  35020. * @param frame the frame number to go to
  35021. * @return the animationGroup
  35022. */
  35023. goToFrame(frame: number): AnimationGroup;
  35024. /**
  35025. * Dispose all associated resources
  35026. */
  35027. dispose(): void;
  35028. private _checkAnimationGroupEnded;
  35029. /**
  35030. * Clone the current animation group and returns a copy
  35031. * @param newName defines the name of the new group
  35032. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35033. * @returns the new aniamtion group
  35034. */
  35035. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35036. /**
  35037. * Serializes the animationGroup to an object
  35038. * @returns Serialized object
  35039. */
  35040. serialize(): any;
  35041. /**
  35042. * Returns a new AnimationGroup object parsed from the source provided.
  35043. * @param parsedAnimationGroup defines the source
  35044. * @param scene defines the scene that will receive the animationGroup
  35045. * @returns a new AnimationGroup
  35046. */
  35047. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35048. /**
  35049. * Returns the string "AnimationGroup"
  35050. * @returns "AnimationGroup"
  35051. */
  35052. getClassName(): string;
  35053. /**
  35054. * Creates a detailled string about the object
  35055. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35056. * @returns a string representing the object
  35057. */
  35058. toString(fullDetails?: boolean): string;
  35059. }
  35060. }
  35061. declare module BABYLON {
  35062. /**
  35063. * Define an interface for all classes that will hold resources
  35064. */
  35065. export interface IDisposable {
  35066. /**
  35067. * Releases all held resources
  35068. */
  35069. dispose(): void;
  35070. }
  35071. /** Interface defining initialization parameters for Scene class */
  35072. export interface SceneOptions {
  35073. /**
  35074. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35075. * It will improve performance when the number of geometries becomes important.
  35076. */
  35077. useGeometryUniqueIdsMap?: boolean;
  35078. /**
  35079. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35080. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35081. */
  35082. useMaterialMeshMap?: boolean;
  35083. /**
  35084. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35085. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35086. */
  35087. useClonedMeshMap?: boolean;
  35088. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35089. virtual?: boolean;
  35090. }
  35091. /**
  35092. * Represents a scene to be rendered by the engine.
  35093. * @see http://doc.babylonjs.com/features/scene
  35094. */
  35095. export class Scene extends AbstractScene implements IAnimatable {
  35096. /** The fog is deactivated */
  35097. static readonly FOGMODE_NONE: number;
  35098. /** The fog density is following an exponential function */
  35099. static readonly FOGMODE_EXP: number;
  35100. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35101. static readonly FOGMODE_EXP2: number;
  35102. /** The fog density is following a linear function. */
  35103. static readonly FOGMODE_LINEAR: number;
  35104. /**
  35105. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35106. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35107. */
  35108. static MinDeltaTime: number;
  35109. /**
  35110. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35111. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35112. */
  35113. static MaxDeltaTime: number;
  35114. /**
  35115. * Factory used to create the default material.
  35116. * @param name The name of the material to create
  35117. * @param scene The scene to create the material for
  35118. * @returns The default material
  35119. */
  35120. static DefaultMaterialFactory(scene: Scene): Material;
  35121. /**
  35122. * Factory used to create the a collision coordinator.
  35123. * @returns The collision coordinator
  35124. */
  35125. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35126. /** @hidden */
  35127. _inputManager: InputManager;
  35128. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35129. cameraToUseForPointers: Nullable<Camera>;
  35130. /** @hidden */
  35131. readonly _isScene: boolean;
  35132. /** @hidden */
  35133. _blockEntityCollection: boolean;
  35134. /**
  35135. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35136. */
  35137. autoClear: boolean;
  35138. /**
  35139. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35140. */
  35141. autoClearDepthAndStencil: boolean;
  35142. /**
  35143. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35144. */
  35145. clearColor: Color4;
  35146. /**
  35147. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35148. */
  35149. ambientColor: Color3;
  35150. /**
  35151. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35152. * It should only be one of the following (if not the default embedded one):
  35153. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35154. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35155. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35156. * The material properties need to be setup according to the type of texture in use.
  35157. */
  35158. environmentBRDFTexture: BaseTexture;
  35159. /** @hidden */
  35160. protected _environmentTexture: Nullable<BaseTexture>;
  35161. /**
  35162. * Texture used in all pbr material as the reflection texture.
  35163. * As in the majority of the scene they are the same (exception for multi room and so on),
  35164. * this is easier to reference from here than from all the materials.
  35165. */
  35166. get environmentTexture(): Nullable<BaseTexture>;
  35167. /**
  35168. * Texture used in all pbr material as the reflection texture.
  35169. * As in the majority of the scene they are the same (exception for multi room and so on),
  35170. * this is easier to set here than in all the materials.
  35171. */
  35172. set environmentTexture(value: Nullable<BaseTexture>);
  35173. /** @hidden */
  35174. protected _environmentIntensity: number;
  35175. /**
  35176. * Intensity of the environment in all pbr material.
  35177. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35178. * As in the majority of the scene they are the same (exception for multi room and so on),
  35179. * this is easier to reference from here than from all the materials.
  35180. */
  35181. get environmentIntensity(): number;
  35182. /**
  35183. * Intensity of the environment in all pbr material.
  35184. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35185. * As in the majority of the scene they are the same (exception for multi room and so on),
  35186. * this is easier to set here than in all the materials.
  35187. */
  35188. set environmentIntensity(value: number);
  35189. /** @hidden */
  35190. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35191. /**
  35192. * Default image processing configuration used either in the rendering
  35193. * Forward main pass or through the imageProcessingPostProcess if present.
  35194. * As in the majority of the scene they are the same (exception for multi camera),
  35195. * this is easier to reference from here than from all the materials and post process.
  35196. *
  35197. * No setter as we it is a shared configuration, you can set the values instead.
  35198. */
  35199. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35200. private _forceWireframe;
  35201. /**
  35202. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35203. */
  35204. set forceWireframe(value: boolean);
  35205. get forceWireframe(): boolean;
  35206. private _skipFrustumClipping;
  35207. /**
  35208. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35209. */
  35210. set skipFrustumClipping(value: boolean);
  35211. get skipFrustumClipping(): boolean;
  35212. private _forcePointsCloud;
  35213. /**
  35214. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35215. */
  35216. set forcePointsCloud(value: boolean);
  35217. get forcePointsCloud(): boolean;
  35218. /**
  35219. * Gets or sets the active clipplane 1
  35220. */
  35221. clipPlane: Nullable<Plane>;
  35222. /**
  35223. * Gets or sets the active clipplane 2
  35224. */
  35225. clipPlane2: Nullable<Plane>;
  35226. /**
  35227. * Gets or sets the active clipplane 3
  35228. */
  35229. clipPlane3: Nullable<Plane>;
  35230. /**
  35231. * Gets or sets the active clipplane 4
  35232. */
  35233. clipPlane4: Nullable<Plane>;
  35234. /**
  35235. * Gets or sets the active clipplane 5
  35236. */
  35237. clipPlane5: Nullable<Plane>;
  35238. /**
  35239. * Gets or sets the active clipplane 6
  35240. */
  35241. clipPlane6: Nullable<Plane>;
  35242. /**
  35243. * Gets or sets a boolean indicating if animations are enabled
  35244. */
  35245. animationsEnabled: boolean;
  35246. private _animationPropertiesOverride;
  35247. /**
  35248. * Gets or sets the animation properties override
  35249. */
  35250. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35251. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35252. /**
  35253. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35254. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35255. */
  35256. useConstantAnimationDeltaTime: boolean;
  35257. /**
  35258. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35259. * Please note that it requires to run a ray cast through the scene on every frame
  35260. */
  35261. constantlyUpdateMeshUnderPointer: boolean;
  35262. /**
  35263. * Defines the HTML cursor to use when hovering over interactive elements
  35264. */
  35265. hoverCursor: string;
  35266. /**
  35267. * Defines the HTML default cursor to use (empty by default)
  35268. */
  35269. defaultCursor: string;
  35270. /**
  35271. * Defines whether cursors are handled by the scene.
  35272. */
  35273. doNotHandleCursors: boolean;
  35274. /**
  35275. * This is used to call preventDefault() on pointer down
  35276. * in order to block unwanted artifacts like system double clicks
  35277. */
  35278. preventDefaultOnPointerDown: boolean;
  35279. /**
  35280. * This is used to call preventDefault() on pointer up
  35281. * in order to block unwanted artifacts like system double clicks
  35282. */
  35283. preventDefaultOnPointerUp: boolean;
  35284. /**
  35285. * Gets or sets user defined metadata
  35286. */
  35287. metadata: any;
  35288. /**
  35289. * For internal use only. Please do not use.
  35290. */
  35291. reservedDataStore: any;
  35292. /**
  35293. * Gets the name of the plugin used to load this scene (null by default)
  35294. */
  35295. loadingPluginName: string;
  35296. /**
  35297. * Use this array to add regular expressions used to disable offline support for specific urls
  35298. */
  35299. disableOfflineSupportExceptionRules: RegExp[];
  35300. /**
  35301. * An event triggered when the scene is disposed.
  35302. */
  35303. onDisposeObservable: Observable<Scene>;
  35304. private _onDisposeObserver;
  35305. /** Sets a function to be executed when this scene is disposed. */
  35306. set onDispose(callback: () => void);
  35307. /**
  35308. * An event triggered before rendering the scene (right after animations and physics)
  35309. */
  35310. onBeforeRenderObservable: Observable<Scene>;
  35311. private _onBeforeRenderObserver;
  35312. /** Sets a function to be executed before rendering this scene */
  35313. set beforeRender(callback: Nullable<() => void>);
  35314. /**
  35315. * An event triggered after rendering the scene
  35316. */
  35317. onAfterRenderObservable: Observable<Scene>;
  35318. /**
  35319. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35320. */
  35321. onAfterRenderCameraObservable: Observable<Camera>;
  35322. private _onAfterRenderObserver;
  35323. /** Sets a function to be executed after rendering this scene */
  35324. set afterRender(callback: Nullable<() => void>);
  35325. /**
  35326. * An event triggered before animating the scene
  35327. */
  35328. onBeforeAnimationsObservable: Observable<Scene>;
  35329. /**
  35330. * An event triggered after animations processing
  35331. */
  35332. onAfterAnimationsObservable: Observable<Scene>;
  35333. /**
  35334. * An event triggered before draw calls are ready to be sent
  35335. */
  35336. onBeforeDrawPhaseObservable: Observable<Scene>;
  35337. /**
  35338. * An event triggered after draw calls have been sent
  35339. */
  35340. onAfterDrawPhaseObservable: Observable<Scene>;
  35341. /**
  35342. * An event triggered when the scene is ready
  35343. */
  35344. onReadyObservable: Observable<Scene>;
  35345. /**
  35346. * An event triggered before rendering a camera
  35347. */
  35348. onBeforeCameraRenderObservable: Observable<Camera>;
  35349. private _onBeforeCameraRenderObserver;
  35350. /** Sets a function to be executed before rendering a camera*/
  35351. set beforeCameraRender(callback: () => void);
  35352. /**
  35353. * An event triggered after rendering a camera
  35354. */
  35355. onAfterCameraRenderObservable: Observable<Camera>;
  35356. private _onAfterCameraRenderObserver;
  35357. /** Sets a function to be executed after rendering a camera*/
  35358. set afterCameraRender(callback: () => void);
  35359. /**
  35360. * An event triggered when active meshes evaluation is about to start
  35361. */
  35362. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35363. /**
  35364. * An event triggered when active meshes evaluation is done
  35365. */
  35366. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35367. /**
  35368. * An event triggered when particles rendering is about to start
  35369. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35370. */
  35371. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35372. /**
  35373. * An event triggered when particles rendering is done
  35374. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35375. */
  35376. onAfterParticlesRenderingObservable: Observable<Scene>;
  35377. /**
  35378. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35379. */
  35380. onDataLoadedObservable: Observable<Scene>;
  35381. /**
  35382. * An event triggered when a camera is created
  35383. */
  35384. onNewCameraAddedObservable: Observable<Camera>;
  35385. /**
  35386. * An event triggered when a camera is removed
  35387. */
  35388. onCameraRemovedObservable: Observable<Camera>;
  35389. /**
  35390. * An event triggered when a light is created
  35391. */
  35392. onNewLightAddedObservable: Observable<Light>;
  35393. /**
  35394. * An event triggered when a light is removed
  35395. */
  35396. onLightRemovedObservable: Observable<Light>;
  35397. /**
  35398. * An event triggered when a geometry is created
  35399. */
  35400. onNewGeometryAddedObservable: Observable<Geometry>;
  35401. /**
  35402. * An event triggered when a geometry is removed
  35403. */
  35404. onGeometryRemovedObservable: Observable<Geometry>;
  35405. /**
  35406. * An event triggered when a transform node is created
  35407. */
  35408. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35409. /**
  35410. * An event triggered when a transform node is removed
  35411. */
  35412. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35413. /**
  35414. * An event triggered when a mesh is created
  35415. */
  35416. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35417. /**
  35418. * An event triggered when a mesh is removed
  35419. */
  35420. onMeshRemovedObservable: Observable<AbstractMesh>;
  35421. /**
  35422. * An event triggered when a skeleton is created
  35423. */
  35424. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35425. /**
  35426. * An event triggered when a skeleton is removed
  35427. */
  35428. onSkeletonRemovedObservable: Observable<Skeleton>;
  35429. /**
  35430. * An event triggered when a material is created
  35431. */
  35432. onNewMaterialAddedObservable: Observable<Material>;
  35433. /**
  35434. * An event triggered when a material is removed
  35435. */
  35436. onMaterialRemovedObservable: Observable<Material>;
  35437. /**
  35438. * An event triggered when a texture is created
  35439. */
  35440. onNewTextureAddedObservable: Observable<BaseTexture>;
  35441. /**
  35442. * An event triggered when a texture is removed
  35443. */
  35444. onTextureRemovedObservable: Observable<BaseTexture>;
  35445. /**
  35446. * An event triggered when render targets are about to be rendered
  35447. * Can happen multiple times per frame.
  35448. */
  35449. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35450. /**
  35451. * An event triggered when render targets were rendered.
  35452. * Can happen multiple times per frame.
  35453. */
  35454. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35455. /**
  35456. * An event triggered before calculating deterministic simulation step
  35457. */
  35458. onBeforeStepObservable: Observable<Scene>;
  35459. /**
  35460. * An event triggered after calculating deterministic simulation step
  35461. */
  35462. onAfterStepObservable: Observable<Scene>;
  35463. /**
  35464. * An event triggered when the activeCamera property is updated
  35465. */
  35466. onActiveCameraChanged: Observable<Scene>;
  35467. /**
  35468. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35469. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35470. * 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)
  35471. */
  35472. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35473. /**
  35474. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35475. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35476. * 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)
  35477. */
  35478. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35479. /**
  35480. * This Observable will when a mesh has been imported into the scene.
  35481. */
  35482. onMeshImportedObservable: Observable<AbstractMesh>;
  35483. /**
  35484. * This Observable will when an animation file has been imported into the scene.
  35485. */
  35486. onAnimationFileImportedObservable: Observable<Scene>;
  35487. /**
  35488. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35489. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35490. */
  35491. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35492. /** @hidden */
  35493. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35494. /**
  35495. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35496. */
  35497. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35498. /**
  35499. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35500. */
  35501. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35502. /**
  35503. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35504. */
  35505. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35506. /** Callback called when a pointer move is detected */
  35507. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35508. /** Callback called when a pointer down is detected */
  35509. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35510. /** Callback called when a pointer up is detected */
  35511. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35512. /** Callback called when a pointer pick is detected */
  35513. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35514. /**
  35515. * 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).
  35516. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35517. */
  35518. onPrePointerObservable: Observable<PointerInfoPre>;
  35519. /**
  35520. * Observable event triggered each time an input event is received from the rendering canvas
  35521. */
  35522. onPointerObservable: Observable<PointerInfo>;
  35523. /**
  35524. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35525. */
  35526. get unTranslatedPointer(): Vector2;
  35527. /**
  35528. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35529. */
  35530. static get DragMovementThreshold(): number;
  35531. static set DragMovementThreshold(value: number);
  35532. /**
  35533. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35534. */
  35535. static get LongPressDelay(): number;
  35536. static set LongPressDelay(value: number);
  35537. /**
  35538. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35539. */
  35540. static get DoubleClickDelay(): number;
  35541. static set DoubleClickDelay(value: number);
  35542. /** If you need to check double click without raising a single click at first click, enable this flag */
  35543. static get ExclusiveDoubleClickMode(): boolean;
  35544. static set ExclusiveDoubleClickMode(value: boolean);
  35545. /** @hidden */
  35546. _mirroredCameraPosition: Nullable<Vector3>;
  35547. /**
  35548. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35549. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35550. */
  35551. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35552. /**
  35553. * Observable event triggered each time an keyboard event is received from the hosting window
  35554. */
  35555. onKeyboardObservable: Observable<KeyboardInfo>;
  35556. private _useRightHandedSystem;
  35557. /**
  35558. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35559. */
  35560. set useRightHandedSystem(value: boolean);
  35561. get useRightHandedSystem(): boolean;
  35562. private _timeAccumulator;
  35563. private _currentStepId;
  35564. private _currentInternalStep;
  35565. /**
  35566. * Sets the step Id used by deterministic lock step
  35567. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35568. * @param newStepId defines the step Id
  35569. */
  35570. setStepId(newStepId: number): void;
  35571. /**
  35572. * Gets the step Id used by deterministic lock step
  35573. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35574. * @returns the step Id
  35575. */
  35576. getStepId(): number;
  35577. /**
  35578. * Gets the internal step used by deterministic lock step
  35579. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35580. * @returns the internal step
  35581. */
  35582. getInternalStep(): number;
  35583. private _fogEnabled;
  35584. /**
  35585. * Gets or sets a boolean indicating if fog is enabled on this scene
  35586. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35587. * (Default is true)
  35588. */
  35589. set fogEnabled(value: boolean);
  35590. get fogEnabled(): boolean;
  35591. private _fogMode;
  35592. /**
  35593. * Gets or sets the fog mode to use
  35594. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35595. * | mode | value |
  35596. * | --- | --- |
  35597. * | FOGMODE_NONE | 0 |
  35598. * | FOGMODE_EXP | 1 |
  35599. * | FOGMODE_EXP2 | 2 |
  35600. * | FOGMODE_LINEAR | 3 |
  35601. */
  35602. set fogMode(value: number);
  35603. get fogMode(): number;
  35604. /**
  35605. * Gets or sets the fog color to use
  35606. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35607. * (Default is Color3(0.2, 0.2, 0.3))
  35608. */
  35609. fogColor: Color3;
  35610. /**
  35611. * Gets or sets the fog density to use
  35612. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35613. * (Default is 0.1)
  35614. */
  35615. fogDensity: number;
  35616. /**
  35617. * Gets or sets the fog start distance to use
  35618. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35619. * (Default is 0)
  35620. */
  35621. fogStart: number;
  35622. /**
  35623. * Gets or sets the fog end distance to use
  35624. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35625. * (Default is 1000)
  35626. */
  35627. fogEnd: number;
  35628. private _shadowsEnabled;
  35629. /**
  35630. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35631. */
  35632. set shadowsEnabled(value: boolean);
  35633. get shadowsEnabled(): boolean;
  35634. private _lightsEnabled;
  35635. /**
  35636. * Gets or sets a boolean indicating if lights are enabled on this scene
  35637. */
  35638. set lightsEnabled(value: boolean);
  35639. get lightsEnabled(): boolean;
  35640. /** All of the active cameras added to this scene. */
  35641. activeCameras: Camera[];
  35642. /** @hidden */
  35643. _activeCamera: Nullable<Camera>;
  35644. /** Gets or sets the current active camera */
  35645. get activeCamera(): Nullable<Camera>;
  35646. set activeCamera(value: Nullable<Camera>);
  35647. private _defaultMaterial;
  35648. /** The default material used on meshes when no material is affected */
  35649. get defaultMaterial(): Material;
  35650. /** The default material used on meshes when no material is affected */
  35651. set defaultMaterial(value: Material);
  35652. private _texturesEnabled;
  35653. /**
  35654. * Gets or sets a boolean indicating if textures are enabled on this scene
  35655. */
  35656. set texturesEnabled(value: boolean);
  35657. get texturesEnabled(): boolean;
  35658. /**
  35659. * Gets or sets a boolean indicating if particles are enabled on this scene
  35660. */
  35661. particlesEnabled: boolean;
  35662. /**
  35663. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35664. */
  35665. spritesEnabled: boolean;
  35666. private _skeletonsEnabled;
  35667. /**
  35668. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35669. */
  35670. set skeletonsEnabled(value: boolean);
  35671. get skeletonsEnabled(): boolean;
  35672. /**
  35673. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35674. */
  35675. lensFlaresEnabled: boolean;
  35676. /**
  35677. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35678. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35679. */
  35680. collisionsEnabled: boolean;
  35681. private _collisionCoordinator;
  35682. /** @hidden */
  35683. get collisionCoordinator(): ICollisionCoordinator;
  35684. /**
  35685. * Defines the gravity applied to this scene (used only for collisions)
  35686. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35687. */
  35688. gravity: Vector3;
  35689. /**
  35690. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35691. */
  35692. postProcessesEnabled: boolean;
  35693. /**
  35694. * The list of postprocesses added to the scene
  35695. */
  35696. postProcesses: PostProcess[];
  35697. /**
  35698. * Gets the current postprocess manager
  35699. */
  35700. postProcessManager: PostProcessManager;
  35701. /**
  35702. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35703. */
  35704. renderTargetsEnabled: boolean;
  35705. /**
  35706. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35707. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35708. */
  35709. dumpNextRenderTargets: boolean;
  35710. /**
  35711. * The list of user defined render targets added to the scene
  35712. */
  35713. customRenderTargets: RenderTargetTexture[];
  35714. /**
  35715. * Defines if texture loading must be delayed
  35716. * If true, textures will only be loaded when they need to be rendered
  35717. */
  35718. useDelayedTextureLoading: boolean;
  35719. /**
  35720. * Gets the list of meshes imported to the scene through SceneLoader
  35721. */
  35722. importedMeshesFiles: String[];
  35723. /**
  35724. * Gets or sets a boolean indicating if probes are enabled on this scene
  35725. */
  35726. probesEnabled: boolean;
  35727. /**
  35728. * Gets or sets the current offline provider to use to store scene data
  35729. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35730. */
  35731. offlineProvider: IOfflineProvider;
  35732. /**
  35733. * Gets or sets the action manager associated with the scene
  35734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35735. */
  35736. actionManager: AbstractActionManager;
  35737. private _meshesForIntersections;
  35738. /**
  35739. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35740. */
  35741. proceduralTexturesEnabled: boolean;
  35742. private _engine;
  35743. private _totalVertices;
  35744. /** @hidden */
  35745. _activeIndices: PerfCounter;
  35746. /** @hidden */
  35747. _activeParticles: PerfCounter;
  35748. /** @hidden */
  35749. _activeBones: PerfCounter;
  35750. private _animationRatio;
  35751. /** @hidden */
  35752. _animationTimeLast: number;
  35753. /** @hidden */
  35754. _animationTime: number;
  35755. /**
  35756. * Gets or sets a general scale for animation speed
  35757. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35758. */
  35759. animationTimeScale: number;
  35760. /** @hidden */
  35761. _cachedMaterial: Nullable<Material>;
  35762. /** @hidden */
  35763. _cachedEffect: Nullable<Effect>;
  35764. /** @hidden */
  35765. _cachedVisibility: Nullable<number>;
  35766. private _renderId;
  35767. private _frameId;
  35768. private _executeWhenReadyTimeoutId;
  35769. private _intermediateRendering;
  35770. private _viewUpdateFlag;
  35771. private _projectionUpdateFlag;
  35772. /** @hidden */
  35773. _toBeDisposed: Nullable<IDisposable>[];
  35774. private _activeRequests;
  35775. /** @hidden */
  35776. _pendingData: any[];
  35777. private _isDisposed;
  35778. /**
  35779. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35780. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35781. */
  35782. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35783. private _activeMeshes;
  35784. private _processedMaterials;
  35785. private _renderTargets;
  35786. /** @hidden */
  35787. _activeParticleSystems: SmartArray<IParticleSystem>;
  35788. private _activeSkeletons;
  35789. private _softwareSkinnedMeshes;
  35790. private _renderingManager;
  35791. /** @hidden */
  35792. _activeAnimatables: Animatable[];
  35793. private _transformMatrix;
  35794. private _sceneUbo;
  35795. /** @hidden */
  35796. _viewMatrix: Matrix;
  35797. private _projectionMatrix;
  35798. /** @hidden */
  35799. _forcedViewPosition: Nullable<Vector3>;
  35800. /** @hidden */
  35801. _frustumPlanes: Plane[];
  35802. /**
  35803. * Gets the list of frustum planes (built from the active camera)
  35804. */
  35805. get frustumPlanes(): Plane[];
  35806. /**
  35807. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35808. * This is useful if there are more lights that the maximum simulteanous authorized
  35809. */
  35810. requireLightSorting: boolean;
  35811. /** @hidden */
  35812. readonly useMaterialMeshMap: boolean;
  35813. /** @hidden */
  35814. readonly useClonedMeshMap: boolean;
  35815. private _externalData;
  35816. private _uid;
  35817. /**
  35818. * @hidden
  35819. * Backing store of defined scene components.
  35820. */
  35821. _components: ISceneComponent[];
  35822. /**
  35823. * @hidden
  35824. * Backing store of defined scene components.
  35825. */
  35826. _serializableComponents: ISceneSerializableComponent[];
  35827. /**
  35828. * List of components to register on the next registration step.
  35829. */
  35830. private _transientComponents;
  35831. /**
  35832. * Registers the transient components if needed.
  35833. */
  35834. private _registerTransientComponents;
  35835. /**
  35836. * @hidden
  35837. * Add a component to the scene.
  35838. * Note that the ccomponent could be registered on th next frame if this is called after
  35839. * the register component stage.
  35840. * @param component Defines the component to add to the scene
  35841. */
  35842. _addComponent(component: ISceneComponent): void;
  35843. /**
  35844. * @hidden
  35845. * Gets a component from the scene.
  35846. * @param name defines the name of the component to retrieve
  35847. * @returns the component or null if not present
  35848. */
  35849. _getComponent(name: string): Nullable<ISceneComponent>;
  35850. /**
  35851. * @hidden
  35852. * Defines the actions happening before camera updates.
  35853. */
  35854. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35855. /**
  35856. * @hidden
  35857. * Defines the actions happening before clear the canvas.
  35858. */
  35859. _beforeClearStage: Stage<SimpleStageAction>;
  35860. /**
  35861. * @hidden
  35862. * Defines the actions when collecting render targets for the frame.
  35863. */
  35864. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35865. /**
  35866. * @hidden
  35867. * Defines the actions happening for one camera in the frame.
  35868. */
  35869. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35870. /**
  35871. * @hidden
  35872. * Defines the actions happening during the per mesh ready checks.
  35873. */
  35874. _isReadyForMeshStage: Stage<MeshStageAction>;
  35875. /**
  35876. * @hidden
  35877. * Defines the actions happening before evaluate active mesh checks.
  35878. */
  35879. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35880. /**
  35881. * @hidden
  35882. * Defines the actions happening during the evaluate sub mesh checks.
  35883. */
  35884. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35885. /**
  35886. * @hidden
  35887. * Defines the actions happening during the active mesh stage.
  35888. */
  35889. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35890. /**
  35891. * @hidden
  35892. * Defines the actions happening during the per camera render target step.
  35893. */
  35894. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35895. /**
  35896. * @hidden
  35897. * Defines the actions happening just before the active camera is drawing.
  35898. */
  35899. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35900. /**
  35901. * @hidden
  35902. * Defines the actions happening just before a render target is drawing.
  35903. */
  35904. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35905. /**
  35906. * @hidden
  35907. * Defines the actions happening just before a rendering group is drawing.
  35908. */
  35909. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35910. /**
  35911. * @hidden
  35912. * Defines the actions happening just before a mesh is drawing.
  35913. */
  35914. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35915. /**
  35916. * @hidden
  35917. * Defines the actions happening just after a mesh has been drawn.
  35918. */
  35919. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35920. /**
  35921. * @hidden
  35922. * Defines the actions happening just after a rendering group has been drawn.
  35923. */
  35924. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35925. /**
  35926. * @hidden
  35927. * Defines the actions happening just after the active camera has been drawn.
  35928. */
  35929. _afterCameraDrawStage: Stage<CameraStageAction>;
  35930. /**
  35931. * @hidden
  35932. * Defines the actions happening just after a render target has been drawn.
  35933. */
  35934. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35935. /**
  35936. * @hidden
  35937. * Defines the actions happening just after rendering all cameras and computing intersections.
  35938. */
  35939. _afterRenderStage: Stage<SimpleStageAction>;
  35940. /**
  35941. * @hidden
  35942. * Defines the actions happening when a pointer move event happens.
  35943. */
  35944. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35945. /**
  35946. * @hidden
  35947. * Defines the actions happening when a pointer down event happens.
  35948. */
  35949. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35950. /**
  35951. * @hidden
  35952. * Defines the actions happening when a pointer up event happens.
  35953. */
  35954. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35955. /**
  35956. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35957. */
  35958. private geometriesByUniqueId;
  35959. /**
  35960. * Creates a new Scene
  35961. * @param engine defines the engine to use to render this scene
  35962. * @param options defines the scene options
  35963. */
  35964. constructor(engine: Engine, options?: SceneOptions);
  35965. /**
  35966. * Gets a string idenfifying the name of the class
  35967. * @returns "Scene" string
  35968. */
  35969. getClassName(): string;
  35970. private _defaultMeshCandidates;
  35971. /**
  35972. * @hidden
  35973. */
  35974. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35975. private _defaultSubMeshCandidates;
  35976. /**
  35977. * @hidden
  35978. */
  35979. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35980. /**
  35981. * Sets the default candidate providers for the scene.
  35982. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35983. * and getCollidingSubMeshCandidates to their default function
  35984. */
  35985. setDefaultCandidateProviders(): void;
  35986. /**
  35987. * Gets the mesh that is currently under the pointer
  35988. */
  35989. get meshUnderPointer(): Nullable<AbstractMesh>;
  35990. /**
  35991. * Gets or sets the current on-screen X position of the pointer
  35992. */
  35993. get pointerX(): number;
  35994. set pointerX(value: number);
  35995. /**
  35996. * Gets or sets the current on-screen Y position of the pointer
  35997. */
  35998. get pointerY(): number;
  35999. set pointerY(value: number);
  36000. /**
  36001. * Gets the cached material (ie. the latest rendered one)
  36002. * @returns the cached material
  36003. */
  36004. getCachedMaterial(): Nullable<Material>;
  36005. /**
  36006. * Gets the cached effect (ie. the latest rendered one)
  36007. * @returns the cached effect
  36008. */
  36009. getCachedEffect(): Nullable<Effect>;
  36010. /**
  36011. * Gets the cached visibility state (ie. the latest rendered one)
  36012. * @returns the cached visibility state
  36013. */
  36014. getCachedVisibility(): Nullable<number>;
  36015. /**
  36016. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36017. * @param material defines the current material
  36018. * @param effect defines the current effect
  36019. * @param visibility defines the current visibility state
  36020. * @returns true if one parameter is not cached
  36021. */
  36022. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36023. /**
  36024. * Gets the engine associated with the scene
  36025. * @returns an Engine
  36026. */
  36027. getEngine(): Engine;
  36028. /**
  36029. * Gets the total number of vertices rendered per frame
  36030. * @returns the total number of vertices rendered per frame
  36031. */
  36032. getTotalVertices(): number;
  36033. /**
  36034. * Gets the performance counter for total vertices
  36035. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36036. */
  36037. get totalVerticesPerfCounter(): PerfCounter;
  36038. /**
  36039. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36040. * @returns the total number of active indices rendered per frame
  36041. */
  36042. getActiveIndices(): number;
  36043. /**
  36044. * Gets the performance counter for active indices
  36045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36046. */
  36047. get totalActiveIndicesPerfCounter(): PerfCounter;
  36048. /**
  36049. * Gets the total number of active particles rendered per frame
  36050. * @returns the total number of active particles rendered per frame
  36051. */
  36052. getActiveParticles(): number;
  36053. /**
  36054. * Gets the performance counter for active particles
  36055. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36056. */
  36057. get activeParticlesPerfCounter(): PerfCounter;
  36058. /**
  36059. * Gets the total number of active bones rendered per frame
  36060. * @returns the total number of active bones rendered per frame
  36061. */
  36062. getActiveBones(): number;
  36063. /**
  36064. * Gets the performance counter for active bones
  36065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36066. */
  36067. get activeBonesPerfCounter(): PerfCounter;
  36068. /**
  36069. * Gets the array of active meshes
  36070. * @returns an array of AbstractMesh
  36071. */
  36072. getActiveMeshes(): SmartArray<AbstractMesh>;
  36073. /**
  36074. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36075. * @returns a number
  36076. */
  36077. getAnimationRatio(): number;
  36078. /**
  36079. * Gets an unique Id for the current render phase
  36080. * @returns a number
  36081. */
  36082. getRenderId(): number;
  36083. /**
  36084. * Gets an unique Id for the current frame
  36085. * @returns a number
  36086. */
  36087. getFrameId(): number;
  36088. /** Call this function if you want to manually increment the render Id*/
  36089. incrementRenderId(): void;
  36090. private _createUbo;
  36091. /**
  36092. * Use this method to simulate a pointer move on a mesh
  36093. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36094. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36095. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36096. * @returns the current scene
  36097. */
  36098. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36099. /**
  36100. * Use this method to simulate a pointer down on a mesh
  36101. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36102. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36103. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36104. * @returns the current scene
  36105. */
  36106. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36107. /**
  36108. * Use this method to simulate a pointer up on a mesh
  36109. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36110. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36111. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36112. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36113. * @returns the current scene
  36114. */
  36115. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36116. /**
  36117. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36118. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36119. * @returns true if the pointer was captured
  36120. */
  36121. isPointerCaptured(pointerId?: number): boolean;
  36122. /**
  36123. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36124. * @param attachUp defines if you want to attach events to pointerup
  36125. * @param attachDown defines if you want to attach events to pointerdown
  36126. * @param attachMove defines if you want to attach events to pointermove
  36127. */
  36128. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36129. /** Detaches all event handlers*/
  36130. detachControl(): void;
  36131. /**
  36132. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36133. * Delay loaded resources are not taking in account
  36134. * @return true if all required resources are ready
  36135. */
  36136. isReady(): boolean;
  36137. /** Resets all cached information relative to material (including effect and visibility) */
  36138. resetCachedMaterial(): void;
  36139. /**
  36140. * Registers a function to be called before every frame render
  36141. * @param func defines the function to register
  36142. */
  36143. registerBeforeRender(func: () => void): void;
  36144. /**
  36145. * Unregisters a function called before every frame render
  36146. * @param func defines the function to unregister
  36147. */
  36148. unregisterBeforeRender(func: () => void): void;
  36149. /**
  36150. * Registers a function to be called after every frame render
  36151. * @param func defines the function to register
  36152. */
  36153. registerAfterRender(func: () => void): void;
  36154. /**
  36155. * Unregisters a function called after every frame render
  36156. * @param func defines the function to unregister
  36157. */
  36158. unregisterAfterRender(func: () => void): void;
  36159. private _executeOnceBeforeRender;
  36160. /**
  36161. * The provided function will run before render once and will be disposed afterwards.
  36162. * A timeout delay can be provided so that the function will be executed in N ms.
  36163. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36164. * @param func The function to be executed.
  36165. * @param timeout optional delay in ms
  36166. */
  36167. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36168. /** @hidden */
  36169. _addPendingData(data: any): void;
  36170. /** @hidden */
  36171. _removePendingData(data: any): void;
  36172. /**
  36173. * Returns the number of items waiting to be loaded
  36174. * @returns the number of items waiting to be loaded
  36175. */
  36176. getWaitingItemsCount(): number;
  36177. /**
  36178. * Returns a boolean indicating if the scene is still loading data
  36179. */
  36180. get isLoading(): boolean;
  36181. /**
  36182. * Registers a function to be executed when the scene is ready
  36183. * @param {Function} func - the function to be executed
  36184. */
  36185. executeWhenReady(func: () => void): void;
  36186. /**
  36187. * Returns a promise that resolves when the scene is ready
  36188. * @returns A promise that resolves when the scene is ready
  36189. */
  36190. whenReadyAsync(): Promise<void>;
  36191. /** @hidden */
  36192. _checkIsReady(): void;
  36193. /**
  36194. * Gets all animatable attached to the scene
  36195. */
  36196. get animatables(): Animatable[];
  36197. /**
  36198. * Resets the last animation time frame.
  36199. * Useful to override when animations start running when loading a scene for the first time.
  36200. */
  36201. resetLastAnimationTimeFrame(): void;
  36202. /**
  36203. * Gets the current view matrix
  36204. * @returns a Matrix
  36205. */
  36206. getViewMatrix(): Matrix;
  36207. /**
  36208. * Gets the current projection matrix
  36209. * @returns a Matrix
  36210. */
  36211. getProjectionMatrix(): Matrix;
  36212. /**
  36213. * Gets the current transform matrix
  36214. * @returns a Matrix made of View * Projection
  36215. */
  36216. getTransformMatrix(): Matrix;
  36217. /**
  36218. * Sets the current transform matrix
  36219. * @param viewL defines the View matrix to use
  36220. * @param projectionL defines the Projection matrix to use
  36221. * @param viewR defines the right View matrix to use (if provided)
  36222. * @param projectionR defines the right Projection matrix to use (if provided)
  36223. */
  36224. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36225. /**
  36226. * Gets the uniform buffer used to store scene data
  36227. * @returns a UniformBuffer
  36228. */
  36229. getSceneUniformBuffer(): UniformBuffer;
  36230. /**
  36231. * Gets an unique (relatively to the current scene) Id
  36232. * @returns an unique number for the scene
  36233. */
  36234. getUniqueId(): number;
  36235. /**
  36236. * Add a mesh to the list of scene's meshes
  36237. * @param newMesh defines the mesh to add
  36238. * @param recursive if all child meshes should also be added to the scene
  36239. */
  36240. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36241. /**
  36242. * Remove a mesh for the list of scene's meshes
  36243. * @param toRemove defines the mesh to remove
  36244. * @param recursive if all child meshes should also be removed from the scene
  36245. * @returns the index where the mesh was in the mesh list
  36246. */
  36247. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36248. /**
  36249. * Add a transform node to the list of scene's transform nodes
  36250. * @param newTransformNode defines the transform node to add
  36251. */
  36252. addTransformNode(newTransformNode: TransformNode): void;
  36253. /**
  36254. * Remove a transform node for the list of scene's transform nodes
  36255. * @param toRemove defines the transform node to remove
  36256. * @returns the index where the transform node was in the transform node list
  36257. */
  36258. removeTransformNode(toRemove: TransformNode): number;
  36259. /**
  36260. * Remove a skeleton for the list of scene's skeletons
  36261. * @param toRemove defines the skeleton to remove
  36262. * @returns the index where the skeleton was in the skeleton list
  36263. */
  36264. removeSkeleton(toRemove: Skeleton): number;
  36265. /**
  36266. * Remove a morph target for the list of scene's morph targets
  36267. * @param toRemove defines the morph target to remove
  36268. * @returns the index where the morph target was in the morph target list
  36269. */
  36270. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36271. /**
  36272. * Remove a light for the list of scene's lights
  36273. * @param toRemove defines the light to remove
  36274. * @returns the index where the light was in the light list
  36275. */
  36276. removeLight(toRemove: Light): number;
  36277. /**
  36278. * Remove a camera for the list of scene's cameras
  36279. * @param toRemove defines the camera to remove
  36280. * @returns the index where the camera was in the camera list
  36281. */
  36282. removeCamera(toRemove: Camera): number;
  36283. /**
  36284. * Remove a particle system for the list of scene's particle systems
  36285. * @param toRemove defines the particle system to remove
  36286. * @returns the index where the particle system was in the particle system list
  36287. */
  36288. removeParticleSystem(toRemove: IParticleSystem): number;
  36289. /**
  36290. * Remove a animation for the list of scene's animations
  36291. * @param toRemove defines the animation to remove
  36292. * @returns the index where the animation was in the animation list
  36293. */
  36294. removeAnimation(toRemove: Animation): number;
  36295. /**
  36296. * Will stop the animation of the given target
  36297. * @param target - the target
  36298. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36299. * @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)
  36300. */
  36301. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36302. /**
  36303. * Removes the given animation group from this scene.
  36304. * @param toRemove The animation group to remove
  36305. * @returns The index of the removed animation group
  36306. */
  36307. removeAnimationGroup(toRemove: AnimationGroup): number;
  36308. /**
  36309. * Removes the given multi-material from this scene.
  36310. * @param toRemove The multi-material to remove
  36311. * @returns The index of the removed multi-material
  36312. */
  36313. removeMultiMaterial(toRemove: MultiMaterial): number;
  36314. /**
  36315. * Removes the given material from this scene.
  36316. * @param toRemove The material to remove
  36317. * @returns The index of the removed material
  36318. */
  36319. removeMaterial(toRemove: Material): number;
  36320. /**
  36321. * Removes the given action manager from this scene.
  36322. * @param toRemove The action manager to remove
  36323. * @returns The index of the removed action manager
  36324. */
  36325. removeActionManager(toRemove: AbstractActionManager): number;
  36326. /**
  36327. * Removes the given texture from this scene.
  36328. * @param toRemove The texture to remove
  36329. * @returns The index of the removed texture
  36330. */
  36331. removeTexture(toRemove: BaseTexture): number;
  36332. /**
  36333. * Adds the given light to this scene
  36334. * @param newLight The light to add
  36335. */
  36336. addLight(newLight: Light): void;
  36337. /**
  36338. * Sorts the list list based on light priorities
  36339. */
  36340. sortLightsByPriority(): void;
  36341. /**
  36342. * Adds the given camera to this scene
  36343. * @param newCamera The camera to add
  36344. */
  36345. addCamera(newCamera: Camera): void;
  36346. /**
  36347. * Adds the given skeleton to this scene
  36348. * @param newSkeleton The skeleton to add
  36349. */
  36350. addSkeleton(newSkeleton: Skeleton): void;
  36351. /**
  36352. * Adds the given particle system to this scene
  36353. * @param newParticleSystem The particle system to add
  36354. */
  36355. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36356. /**
  36357. * Adds the given animation to this scene
  36358. * @param newAnimation The animation to add
  36359. */
  36360. addAnimation(newAnimation: Animation): void;
  36361. /**
  36362. * Adds the given animation group to this scene.
  36363. * @param newAnimationGroup The animation group to add
  36364. */
  36365. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36366. /**
  36367. * Adds the given multi-material to this scene
  36368. * @param newMultiMaterial The multi-material to add
  36369. */
  36370. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36371. /**
  36372. * Adds the given material to this scene
  36373. * @param newMaterial The material to add
  36374. */
  36375. addMaterial(newMaterial: Material): void;
  36376. /**
  36377. * Adds the given morph target to this scene
  36378. * @param newMorphTargetManager The morph target to add
  36379. */
  36380. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36381. /**
  36382. * Adds the given geometry to this scene
  36383. * @param newGeometry The geometry to add
  36384. */
  36385. addGeometry(newGeometry: Geometry): void;
  36386. /**
  36387. * Adds the given action manager to this scene
  36388. * @param newActionManager The action manager to add
  36389. */
  36390. addActionManager(newActionManager: AbstractActionManager): void;
  36391. /**
  36392. * Adds the given texture to this scene.
  36393. * @param newTexture The texture to add
  36394. */
  36395. addTexture(newTexture: BaseTexture): void;
  36396. /**
  36397. * Switch active camera
  36398. * @param newCamera defines the new active camera
  36399. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36400. */
  36401. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36402. /**
  36403. * sets the active camera of the scene using its ID
  36404. * @param id defines the camera's ID
  36405. * @return the new active camera or null if none found.
  36406. */
  36407. setActiveCameraByID(id: string): Nullable<Camera>;
  36408. /**
  36409. * sets the active camera of the scene using its name
  36410. * @param name defines the camera's name
  36411. * @returns the new active camera or null if none found.
  36412. */
  36413. setActiveCameraByName(name: string): Nullable<Camera>;
  36414. /**
  36415. * get an animation group using its name
  36416. * @param name defines the material's name
  36417. * @return the animation group or null if none found.
  36418. */
  36419. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36420. /**
  36421. * Get a material using its unique id
  36422. * @param uniqueId defines the material's unique id
  36423. * @return the material or null if none found.
  36424. */
  36425. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36426. /**
  36427. * get a material using its id
  36428. * @param id defines the material's ID
  36429. * @return the material or null if none found.
  36430. */
  36431. getMaterialByID(id: string): Nullable<Material>;
  36432. /**
  36433. * Gets a the last added material using a given id
  36434. * @param id defines the material's ID
  36435. * @return the last material with the given id or null if none found.
  36436. */
  36437. getLastMaterialByID(id: string): Nullable<Material>;
  36438. /**
  36439. * Gets a material using its name
  36440. * @param name defines the material's name
  36441. * @return the material or null if none found.
  36442. */
  36443. getMaterialByName(name: string): Nullable<Material>;
  36444. /**
  36445. * Get a texture using its unique id
  36446. * @param uniqueId defines the texture's unique id
  36447. * @return the texture or null if none found.
  36448. */
  36449. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36450. /**
  36451. * Gets a camera using its id
  36452. * @param id defines the id to look for
  36453. * @returns the camera or null if not found
  36454. */
  36455. getCameraByID(id: string): Nullable<Camera>;
  36456. /**
  36457. * Gets a camera using its unique id
  36458. * @param uniqueId defines the unique id to look for
  36459. * @returns the camera or null if not found
  36460. */
  36461. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36462. /**
  36463. * Gets a camera using its name
  36464. * @param name defines the camera's name
  36465. * @return the camera or null if none found.
  36466. */
  36467. getCameraByName(name: string): Nullable<Camera>;
  36468. /**
  36469. * Gets a bone using its id
  36470. * @param id defines the bone's id
  36471. * @return the bone or null if not found
  36472. */
  36473. getBoneByID(id: string): Nullable<Bone>;
  36474. /**
  36475. * Gets a bone using its id
  36476. * @param name defines the bone's name
  36477. * @return the bone or null if not found
  36478. */
  36479. getBoneByName(name: string): Nullable<Bone>;
  36480. /**
  36481. * Gets a light node using its name
  36482. * @param name defines the the light's name
  36483. * @return the light or null if none found.
  36484. */
  36485. getLightByName(name: string): Nullable<Light>;
  36486. /**
  36487. * Gets a light node using its id
  36488. * @param id defines the light's id
  36489. * @return the light or null if none found.
  36490. */
  36491. getLightByID(id: string): Nullable<Light>;
  36492. /**
  36493. * Gets a light node using its scene-generated unique ID
  36494. * @param uniqueId defines the light's unique id
  36495. * @return the light or null if none found.
  36496. */
  36497. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36498. /**
  36499. * Gets a particle system by id
  36500. * @param id defines the particle system id
  36501. * @return the corresponding system or null if none found
  36502. */
  36503. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36504. /**
  36505. * Gets a geometry using its ID
  36506. * @param id defines the geometry's id
  36507. * @return the geometry or null if none found.
  36508. */
  36509. getGeometryByID(id: string): Nullable<Geometry>;
  36510. private _getGeometryByUniqueID;
  36511. /**
  36512. * Add a new geometry to this scene
  36513. * @param geometry defines the geometry to be added to the scene.
  36514. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36515. * @return a boolean defining if the geometry was added or not
  36516. */
  36517. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36518. /**
  36519. * Removes an existing geometry
  36520. * @param geometry defines the geometry to be removed from the scene
  36521. * @return a boolean defining if the geometry was removed or not
  36522. */
  36523. removeGeometry(geometry: Geometry): boolean;
  36524. /**
  36525. * Gets the list of geometries attached to the scene
  36526. * @returns an array of Geometry
  36527. */
  36528. getGeometries(): Geometry[];
  36529. /**
  36530. * Gets the first added mesh found of a given ID
  36531. * @param id defines the id to search for
  36532. * @return the mesh found or null if not found at all
  36533. */
  36534. getMeshByID(id: string): Nullable<AbstractMesh>;
  36535. /**
  36536. * Gets a list of meshes using their id
  36537. * @param id defines the id to search for
  36538. * @returns a list of meshes
  36539. */
  36540. getMeshesByID(id: string): Array<AbstractMesh>;
  36541. /**
  36542. * Gets the first added transform node found of a given ID
  36543. * @param id defines the id to search for
  36544. * @return the found transform node or null if not found at all.
  36545. */
  36546. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36547. /**
  36548. * Gets a transform node with its auto-generated unique id
  36549. * @param uniqueId efines the unique id to search for
  36550. * @return the found transform node or null if not found at all.
  36551. */
  36552. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36553. /**
  36554. * Gets a list of transform nodes using their id
  36555. * @param id defines the id to search for
  36556. * @returns a list of transform nodes
  36557. */
  36558. getTransformNodesByID(id: string): Array<TransformNode>;
  36559. /**
  36560. * Gets a mesh with its auto-generated unique id
  36561. * @param uniqueId defines the unique id to search for
  36562. * @return the found mesh or null if not found at all.
  36563. */
  36564. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36565. /**
  36566. * Gets a the last added mesh using a given id
  36567. * @param id defines the id to search for
  36568. * @return the found mesh or null if not found at all.
  36569. */
  36570. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36571. /**
  36572. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36573. * @param id defines the id to search for
  36574. * @return the found node or null if not found at all
  36575. */
  36576. getLastEntryByID(id: string): Nullable<Node>;
  36577. /**
  36578. * Gets a node (Mesh, Camera, Light) using a given id
  36579. * @param id defines the id to search for
  36580. * @return the found node or null if not found at all
  36581. */
  36582. getNodeByID(id: string): Nullable<Node>;
  36583. /**
  36584. * Gets a node (Mesh, Camera, Light) using a given name
  36585. * @param name defines the name to search for
  36586. * @return the found node or null if not found at all.
  36587. */
  36588. getNodeByName(name: string): Nullable<Node>;
  36589. /**
  36590. * Gets a mesh using a given name
  36591. * @param name defines the name to search for
  36592. * @return the found mesh or null if not found at all.
  36593. */
  36594. getMeshByName(name: string): Nullable<AbstractMesh>;
  36595. /**
  36596. * Gets a transform node using a given name
  36597. * @param name defines the name to search for
  36598. * @return the found transform node or null if not found at all.
  36599. */
  36600. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36601. /**
  36602. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36603. * @param id defines the id to search for
  36604. * @return the found skeleton or null if not found at all.
  36605. */
  36606. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36607. /**
  36608. * Gets a skeleton using a given auto generated unique id
  36609. * @param uniqueId defines the unique id to search for
  36610. * @return the found skeleton or null if not found at all.
  36611. */
  36612. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36613. /**
  36614. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36615. * @param id defines the id to search for
  36616. * @return the found skeleton or null if not found at all.
  36617. */
  36618. getSkeletonById(id: string): Nullable<Skeleton>;
  36619. /**
  36620. * Gets a skeleton using a given name
  36621. * @param name defines the name to search for
  36622. * @return the found skeleton or null if not found at all.
  36623. */
  36624. getSkeletonByName(name: string): Nullable<Skeleton>;
  36625. /**
  36626. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36627. * @param id defines the id to search for
  36628. * @return the found morph target manager or null if not found at all.
  36629. */
  36630. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36631. /**
  36632. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36633. * @param id defines the id to search for
  36634. * @return the found morph target or null if not found at all.
  36635. */
  36636. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36637. /**
  36638. * Gets a boolean indicating if the given mesh is active
  36639. * @param mesh defines the mesh to look for
  36640. * @returns true if the mesh is in the active list
  36641. */
  36642. isActiveMesh(mesh: AbstractMesh): boolean;
  36643. /**
  36644. * Return a unique id as a string which can serve as an identifier for the scene
  36645. */
  36646. get uid(): string;
  36647. /**
  36648. * Add an externaly attached data from its key.
  36649. * This method call will fail and return false, if such key already exists.
  36650. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36651. * @param key the unique key that identifies the data
  36652. * @param data the data object to associate to the key for this Engine instance
  36653. * @return true if no such key were already present and the data was added successfully, false otherwise
  36654. */
  36655. addExternalData<T>(key: string, data: T): boolean;
  36656. /**
  36657. * Get an externaly attached data from its key
  36658. * @param key the unique key that identifies the data
  36659. * @return the associated data, if present (can be null), or undefined if not present
  36660. */
  36661. getExternalData<T>(key: string): Nullable<T>;
  36662. /**
  36663. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36664. * @param key the unique key that identifies the data
  36665. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36666. * @return the associated data, can be null if the factory returned null.
  36667. */
  36668. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36669. /**
  36670. * Remove an externaly attached data from the Engine instance
  36671. * @param key the unique key that identifies the data
  36672. * @return true if the data was successfully removed, false if it doesn't exist
  36673. */
  36674. removeExternalData(key: string): boolean;
  36675. private _evaluateSubMesh;
  36676. /**
  36677. * Clear the processed materials smart array preventing retention point in material dispose.
  36678. */
  36679. freeProcessedMaterials(): void;
  36680. private _preventFreeActiveMeshesAndRenderingGroups;
  36681. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36682. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36683. * when disposing several meshes in a row or a hierarchy of meshes.
  36684. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36685. */
  36686. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36687. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36688. /**
  36689. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36690. */
  36691. freeActiveMeshes(): void;
  36692. /**
  36693. * Clear the info related to rendering groups preventing retention points during dispose.
  36694. */
  36695. freeRenderingGroups(): void;
  36696. /** @hidden */
  36697. _isInIntermediateRendering(): boolean;
  36698. /**
  36699. * Lambda returning the list of potentially active meshes.
  36700. */
  36701. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36702. /**
  36703. * Lambda returning the list of potentially active sub meshes.
  36704. */
  36705. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36706. /**
  36707. * Lambda returning the list of potentially intersecting sub meshes.
  36708. */
  36709. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36710. /**
  36711. * Lambda returning the list of potentially colliding sub meshes.
  36712. */
  36713. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36714. private _activeMeshesFrozen;
  36715. private _skipEvaluateActiveMeshesCompletely;
  36716. /**
  36717. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36718. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36719. * @returns the current scene
  36720. */
  36721. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36722. /**
  36723. * Use this function to restart evaluating active meshes on every frame
  36724. * @returns the current scene
  36725. */
  36726. unfreezeActiveMeshes(): Scene;
  36727. private _evaluateActiveMeshes;
  36728. private _activeMesh;
  36729. /**
  36730. * Update the transform matrix to update from the current active camera
  36731. * @param force defines a boolean used to force the update even if cache is up to date
  36732. */
  36733. updateTransformMatrix(force?: boolean): void;
  36734. private _bindFrameBuffer;
  36735. /** @hidden */
  36736. _allowPostProcessClearColor: boolean;
  36737. /** @hidden */
  36738. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36739. private _processSubCameras;
  36740. private _checkIntersections;
  36741. /** @hidden */
  36742. _advancePhysicsEngineStep(step: number): void;
  36743. /**
  36744. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36745. */
  36746. getDeterministicFrameTime: () => number;
  36747. /** @hidden */
  36748. _animate(): void;
  36749. /** Execute all animations (for a frame) */
  36750. animate(): void;
  36751. /**
  36752. * Render the scene
  36753. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36754. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36755. */
  36756. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36757. /**
  36758. * Freeze all materials
  36759. * A frozen material will not be updatable but should be faster to render
  36760. */
  36761. freezeMaterials(): void;
  36762. /**
  36763. * Unfreeze all materials
  36764. * A frozen material will not be updatable but should be faster to render
  36765. */
  36766. unfreezeMaterials(): void;
  36767. /**
  36768. * Releases all held ressources
  36769. */
  36770. dispose(): void;
  36771. /**
  36772. * Gets if the scene is already disposed
  36773. */
  36774. get isDisposed(): boolean;
  36775. /**
  36776. * Call this function to reduce memory footprint of the scene.
  36777. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36778. */
  36779. clearCachedVertexData(): void;
  36780. /**
  36781. * This function will remove the local cached buffer data from texture.
  36782. * It will save memory but will prevent the texture from being rebuilt
  36783. */
  36784. cleanCachedTextureBuffer(): void;
  36785. /**
  36786. * Get the world extend vectors with an optional filter
  36787. *
  36788. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36789. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36790. */
  36791. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36792. min: Vector3;
  36793. max: Vector3;
  36794. };
  36795. /**
  36796. * Creates a ray that can be used to pick in the scene
  36797. * @param x defines the x coordinate of the origin (on-screen)
  36798. * @param y defines the y coordinate of the origin (on-screen)
  36799. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36800. * @param camera defines the camera to use for the picking
  36801. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36802. * @returns a Ray
  36803. */
  36804. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36805. /**
  36806. * Creates a ray that can be used to pick in the scene
  36807. * @param x defines the x coordinate of the origin (on-screen)
  36808. * @param y defines the y coordinate of the origin (on-screen)
  36809. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36810. * @param result defines the ray where to store the picking ray
  36811. * @param camera defines the camera to use for the picking
  36812. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36813. * @returns the current scene
  36814. */
  36815. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36816. /**
  36817. * Creates a ray that can be used to pick in the scene
  36818. * @param x defines the x coordinate of the origin (on-screen)
  36819. * @param y defines the y coordinate of the origin (on-screen)
  36820. * @param camera defines the camera to use for the picking
  36821. * @returns a Ray
  36822. */
  36823. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36824. /**
  36825. * Creates a ray that can be used to pick in the scene
  36826. * @param x defines the x coordinate of the origin (on-screen)
  36827. * @param y defines the y coordinate of the origin (on-screen)
  36828. * @param result defines the ray where to store the picking ray
  36829. * @param camera defines the camera to use for the picking
  36830. * @returns the current scene
  36831. */
  36832. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36833. /** Launch a ray to try to pick a mesh in the scene
  36834. * @param x position on screen
  36835. * @param y position on screen
  36836. * @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
  36837. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36838. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36840. * @returns a PickingInfo
  36841. */
  36842. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36843. /** Use the given ray to pick a mesh in the scene
  36844. * @param ray The ray to use to pick meshes
  36845. * @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
  36846. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36847. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36848. * @returns a PickingInfo
  36849. */
  36850. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36851. /**
  36852. * Launch a ray to try to pick a mesh in the scene
  36853. * @param x X position on screen
  36854. * @param y Y position on screen
  36855. * @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
  36856. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36857. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36858. * @returns an array of PickingInfo
  36859. */
  36860. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36861. /**
  36862. * Launch a ray to try to pick a mesh in the scene
  36863. * @param ray Ray to use
  36864. * @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
  36865. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36866. * @returns an array of PickingInfo
  36867. */
  36868. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36869. /**
  36870. * Force the value of meshUnderPointer
  36871. * @param mesh defines the mesh to use
  36872. */
  36873. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36874. /**
  36875. * Gets the mesh under the pointer
  36876. * @returns a Mesh or null if no mesh is under the pointer
  36877. */
  36878. getPointerOverMesh(): Nullable<AbstractMesh>;
  36879. /** @hidden */
  36880. _rebuildGeometries(): void;
  36881. /** @hidden */
  36882. _rebuildTextures(): void;
  36883. private _getByTags;
  36884. /**
  36885. * Get a list of meshes by tags
  36886. * @param tagsQuery defines the tags query to use
  36887. * @param forEach defines a predicate used to filter results
  36888. * @returns an array of Mesh
  36889. */
  36890. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36891. /**
  36892. * Get a list of cameras by tags
  36893. * @param tagsQuery defines the tags query to use
  36894. * @param forEach defines a predicate used to filter results
  36895. * @returns an array of Camera
  36896. */
  36897. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36898. /**
  36899. * Get a list of lights by tags
  36900. * @param tagsQuery defines the tags query to use
  36901. * @param forEach defines a predicate used to filter results
  36902. * @returns an array of Light
  36903. */
  36904. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36905. /**
  36906. * Get a list of materials by tags
  36907. * @param tagsQuery defines the tags query to use
  36908. * @param forEach defines a predicate used to filter results
  36909. * @returns an array of Material
  36910. */
  36911. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36912. /**
  36913. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36914. * This allowed control for front to back rendering or reversly depending of the special needs.
  36915. *
  36916. * @param renderingGroupId The rendering group id corresponding to its index
  36917. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36918. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36919. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36920. */
  36921. 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;
  36922. /**
  36923. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36924. *
  36925. * @param renderingGroupId The rendering group id corresponding to its index
  36926. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36927. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36928. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36929. */
  36930. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36931. /**
  36932. * Gets the current auto clear configuration for one rendering group of the rendering
  36933. * manager.
  36934. * @param index the rendering group index to get the information for
  36935. * @returns The auto clear setup for the requested rendering group
  36936. */
  36937. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36938. private _blockMaterialDirtyMechanism;
  36939. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36940. get blockMaterialDirtyMechanism(): boolean;
  36941. set blockMaterialDirtyMechanism(value: boolean);
  36942. /**
  36943. * Will flag all materials as dirty to trigger new shader compilation
  36944. * @param flag defines the flag used to specify which material part must be marked as dirty
  36945. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36946. */
  36947. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36948. /** @hidden */
  36949. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36950. /** @hidden */
  36951. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36952. /** @hidden */
  36953. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  36954. /** @hidden */
  36955. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36956. /** @hidden */
  36957. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36958. /** @hidden */
  36959. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36960. }
  36961. }
  36962. declare module BABYLON {
  36963. /**
  36964. * Set of assets to keep when moving a scene into an asset container.
  36965. */
  36966. export class KeepAssets extends AbstractScene {
  36967. }
  36968. /**
  36969. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36970. */
  36971. export class InstantiatedEntries {
  36972. /**
  36973. * List of new root nodes (eg. nodes with no parent)
  36974. */
  36975. rootNodes: TransformNode[];
  36976. /**
  36977. * List of new skeletons
  36978. */
  36979. skeletons: Skeleton[];
  36980. /**
  36981. * List of new animation groups
  36982. */
  36983. animationGroups: AnimationGroup[];
  36984. }
  36985. /**
  36986. * Container with a set of assets that can be added or removed from a scene.
  36987. */
  36988. export class AssetContainer extends AbstractScene {
  36989. private _wasAddedToScene;
  36990. /**
  36991. * The scene the AssetContainer belongs to.
  36992. */
  36993. scene: Scene;
  36994. /**
  36995. * Instantiates an AssetContainer.
  36996. * @param scene The scene the AssetContainer belongs to.
  36997. */
  36998. constructor(scene: Scene);
  36999. /**
  37000. * Instantiate or clone all meshes and add the new ones to the scene.
  37001. * Skeletons and animation groups will all be cloned
  37002. * @param nameFunction defines an optional function used to get new names for clones
  37003. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37004. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37005. */
  37006. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37007. /**
  37008. * Adds all the assets from the container to the scene.
  37009. */
  37010. addAllToScene(): void;
  37011. /**
  37012. * Removes all the assets in the container from the scene
  37013. */
  37014. removeAllFromScene(): void;
  37015. /**
  37016. * Disposes all the assets in the container
  37017. */
  37018. dispose(): void;
  37019. private _moveAssets;
  37020. /**
  37021. * Removes all the assets contained in the scene and adds them to the container.
  37022. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37023. */
  37024. moveAllFromScene(keepAssets?: KeepAssets): void;
  37025. /**
  37026. * 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.
  37027. * @returns the root mesh
  37028. */
  37029. createRootMesh(): Mesh;
  37030. /**
  37031. * Merge animations from this asset container into a scene
  37032. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37033. * @param animatables set of animatables to retarget to a node from the scene
  37034. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37035. */
  37036. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37037. }
  37038. }
  37039. declare module BABYLON {
  37040. /**
  37041. * Defines how the parser contract is defined.
  37042. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37043. */
  37044. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37045. /**
  37046. * Defines how the individual parser contract is defined.
  37047. * These parser can parse an individual asset
  37048. */
  37049. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37050. /**
  37051. * Base class of the scene acting as a container for the different elements composing a scene.
  37052. * This class is dynamically extended by the different components of the scene increasing
  37053. * flexibility and reducing coupling
  37054. */
  37055. export abstract class AbstractScene {
  37056. /**
  37057. * Stores the list of available parsers in the application.
  37058. */
  37059. private static _BabylonFileParsers;
  37060. /**
  37061. * Stores the list of available individual parsers in the application.
  37062. */
  37063. private static _IndividualBabylonFileParsers;
  37064. /**
  37065. * Adds a parser in the list of available ones
  37066. * @param name Defines the name of the parser
  37067. * @param parser Defines the parser to add
  37068. */
  37069. static AddParser(name: string, parser: BabylonFileParser): void;
  37070. /**
  37071. * Gets a general parser from the list of avaialble ones
  37072. * @param name Defines the name of the parser
  37073. * @returns the requested parser or null
  37074. */
  37075. static GetParser(name: string): Nullable<BabylonFileParser>;
  37076. /**
  37077. * Adds n individual parser in the list of available ones
  37078. * @param name Defines the name of the parser
  37079. * @param parser Defines the parser to add
  37080. */
  37081. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37082. /**
  37083. * Gets an individual parser from the list of avaialble ones
  37084. * @param name Defines the name of the parser
  37085. * @returns the requested parser or null
  37086. */
  37087. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37088. /**
  37089. * Parser json data and populate both a scene and its associated container object
  37090. * @param jsonData Defines the data to parse
  37091. * @param scene Defines the scene to parse the data for
  37092. * @param container Defines the container attached to the parsing sequence
  37093. * @param rootUrl Defines the root url of the data
  37094. */
  37095. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37096. /**
  37097. * Gets the list of root nodes (ie. nodes with no parent)
  37098. */
  37099. rootNodes: Node[];
  37100. /** All of the cameras added to this scene
  37101. * @see http://doc.babylonjs.com/babylon101/cameras
  37102. */
  37103. cameras: Camera[];
  37104. /**
  37105. * All of the lights added to this scene
  37106. * @see http://doc.babylonjs.com/babylon101/lights
  37107. */
  37108. lights: Light[];
  37109. /**
  37110. * All of the (abstract) meshes added to this scene
  37111. */
  37112. meshes: AbstractMesh[];
  37113. /**
  37114. * The list of skeletons added to the scene
  37115. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37116. */
  37117. skeletons: Skeleton[];
  37118. /**
  37119. * All of the particle systems added to this scene
  37120. * @see http://doc.babylonjs.com/babylon101/particles
  37121. */
  37122. particleSystems: IParticleSystem[];
  37123. /**
  37124. * Gets a list of Animations associated with the scene
  37125. */
  37126. animations: Animation[];
  37127. /**
  37128. * All of the animation groups added to this scene
  37129. * @see http://doc.babylonjs.com/how_to/group
  37130. */
  37131. animationGroups: AnimationGroup[];
  37132. /**
  37133. * All of the multi-materials added to this scene
  37134. * @see http://doc.babylonjs.com/how_to/multi_materials
  37135. */
  37136. multiMaterials: MultiMaterial[];
  37137. /**
  37138. * All of the materials added to this scene
  37139. * In the context of a Scene, it is not supposed to be modified manually.
  37140. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37141. * Note also that the order of the Material within the array is not significant and might change.
  37142. * @see http://doc.babylonjs.com/babylon101/materials
  37143. */
  37144. materials: Material[];
  37145. /**
  37146. * The list of morph target managers added to the scene
  37147. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37148. */
  37149. morphTargetManagers: MorphTargetManager[];
  37150. /**
  37151. * The list of geometries used in the scene.
  37152. */
  37153. geometries: Geometry[];
  37154. /**
  37155. * All of the tranform nodes added to this scene
  37156. * In the context of a Scene, it is not supposed to be modified manually.
  37157. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37158. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37159. * @see http://doc.babylonjs.com/how_to/transformnode
  37160. */
  37161. transformNodes: TransformNode[];
  37162. /**
  37163. * ActionManagers available on the scene.
  37164. */
  37165. actionManagers: AbstractActionManager[];
  37166. /**
  37167. * Textures to keep.
  37168. */
  37169. textures: BaseTexture[];
  37170. /**
  37171. * Environment texture for the scene
  37172. */
  37173. environmentTexture: Nullable<BaseTexture>;
  37174. /**
  37175. * @returns all meshes, lights, cameras, transformNodes and bones
  37176. */
  37177. getNodes(): Array<Node>;
  37178. }
  37179. }
  37180. declare module BABYLON {
  37181. /**
  37182. * Interface used to define options for Sound class
  37183. */
  37184. export interface ISoundOptions {
  37185. /**
  37186. * Does the sound autoplay once loaded.
  37187. */
  37188. autoplay?: boolean;
  37189. /**
  37190. * Does the sound loop after it finishes playing once.
  37191. */
  37192. loop?: boolean;
  37193. /**
  37194. * Sound's volume
  37195. */
  37196. volume?: number;
  37197. /**
  37198. * Is it a spatial sound?
  37199. */
  37200. spatialSound?: boolean;
  37201. /**
  37202. * Maximum distance to hear that sound
  37203. */
  37204. maxDistance?: number;
  37205. /**
  37206. * Uses user defined attenuation function
  37207. */
  37208. useCustomAttenuation?: boolean;
  37209. /**
  37210. * Define the roll off factor of spatial sounds.
  37211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37212. */
  37213. rolloffFactor?: number;
  37214. /**
  37215. * Define the reference distance the sound should be heard perfectly.
  37216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37217. */
  37218. refDistance?: number;
  37219. /**
  37220. * Define the distance attenuation model the sound will follow.
  37221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37222. */
  37223. distanceModel?: string;
  37224. /**
  37225. * Defines the playback speed (1 by default)
  37226. */
  37227. playbackRate?: number;
  37228. /**
  37229. * Defines if the sound is from a streaming source
  37230. */
  37231. streaming?: boolean;
  37232. /**
  37233. * Defines an optional length (in seconds) inside the sound file
  37234. */
  37235. length?: number;
  37236. /**
  37237. * Defines an optional offset (in seconds) inside the sound file
  37238. */
  37239. offset?: number;
  37240. /**
  37241. * If true, URLs will not be required to state the audio file codec to use.
  37242. */
  37243. skipCodecCheck?: boolean;
  37244. }
  37245. /**
  37246. * Defines a sound that can be played in the application.
  37247. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37249. */
  37250. export class Sound {
  37251. /**
  37252. * The name of the sound in the scene.
  37253. */
  37254. name: string;
  37255. /**
  37256. * Does the sound autoplay once loaded.
  37257. */
  37258. autoplay: boolean;
  37259. /**
  37260. * Does the sound loop after it finishes playing once.
  37261. */
  37262. loop: boolean;
  37263. /**
  37264. * Does the sound use a custom attenuation curve to simulate the falloff
  37265. * happening when the source gets further away from the camera.
  37266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37267. */
  37268. useCustomAttenuation: boolean;
  37269. /**
  37270. * The sound track id this sound belongs to.
  37271. */
  37272. soundTrackId: number;
  37273. /**
  37274. * Is this sound currently played.
  37275. */
  37276. isPlaying: boolean;
  37277. /**
  37278. * Is this sound currently paused.
  37279. */
  37280. isPaused: boolean;
  37281. /**
  37282. * Does this sound enables spatial sound.
  37283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37284. */
  37285. spatialSound: boolean;
  37286. /**
  37287. * Define the reference distance the sound should be heard perfectly.
  37288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37289. */
  37290. refDistance: number;
  37291. /**
  37292. * Define the roll off factor of spatial sounds.
  37293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37294. */
  37295. rolloffFactor: number;
  37296. /**
  37297. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37299. */
  37300. maxDistance: number;
  37301. /**
  37302. * Define the distance attenuation model the sound will follow.
  37303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37304. */
  37305. distanceModel: string;
  37306. /**
  37307. * @hidden
  37308. * Back Compat
  37309. **/
  37310. onended: () => any;
  37311. /**
  37312. * Observable event when the current playing sound finishes.
  37313. */
  37314. onEndedObservable: Observable<Sound>;
  37315. private _panningModel;
  37316. private _playbackRate;
  37317. private _streaming;
  37318. private _startTime;
  37319. private _startOffset;
  37320. private _position;
  37321. /** @hidden */
  37322. _positionInEmitterSpace: boolean;
  37323. private _localDirection;
  37324. private _volume;
  37325. private _isReadyToPlay;
  37326. private _isDirectional;
  37327. private _readyToPlayCallback;
  37328. private _audioBuffer;
  37329. private _soundSource;
  37330. private _streamingSource;
  37331. private _soundPanner;
  37332. private _soundGain;
  37333. private _inputAudioNode;
  37334. private _outputAudioNode;
  37335. private _coneInnerAngle;
  37336. private _coneOuterAngle;
  37337. private _coneOuterGain;
  37338. private _scene;
  37339. private _connectedTransformNode;
  37340. private _customAttenuationFunction;
  37341. private _registerFunc;
  37342. private _isOutputConnected;
  37343. private _htmlAudioElement;
  37344. private _urlType;
  37345. private _length?;
  37346. private _offset?;
  37347. /** @hidden */
  37348. static _SceneComponentInitialization: (scene: Scene) => void;
  37349. /**
  37350. * Create a sound and attach it to a scene
  37351. * @param name Name of your sound
  37352. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37353. * @param scene defines the scene the sound belongs to
  37354. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37355. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37356. */
  37357. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37358. /**
  37359. * Release the sound and its associated resources
  37360. */
  37361. dispose(): void;
  37362. /**
  37363. * Gets if the sounds is ready to be played or not.
  37364. * @returns true if ready, otherwise false
  37365. */
  37366. isReady(): boolean;
  37367. private _soundLoaded;
  37368. /**
  37369. * Sets the data of the sound from an audiobuffer
  37370. * @param audioBuffer The audioBuffer containing the data
  37371. */
  37372. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37373. /**
  37374. * Updates the current sounds options such as maxdistance, loop...
  37375. * @param options A JSON object containing values named as the object properties
  37376. */
  37377. updateOptions(options: ISoundOptions): void;
  37378. private _createSpatialParameters;
  37379. private _updateSpatialParameters;
  37380. /**
  37381. * Switch the panning model to HRTF:
  37382. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37384. */
  37385. switchPanningModelToHRTF(): void;
  37386. /**
  37387. * Switch the panning model to Equal Power:
  37388. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37390. */
  37391. switchPanningModelToEqualPower(): void;
  37392. private _switchPanningModel;
  37393. /**
  37394. * Connect this sound to a sound track audio node like gain...
  37395. * @param soundTrackAudioNode the sound track audio node to connect to
  37396. */
  37397. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37398. /**
  37399. * Transform this sound into a directional source
  37400. * @param coneInnerAngle Size of the inner cone in degree
  37401. * @param coneOuterAngle Size of the outer cone in degree
  37402. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37403. */
  37404. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37405. /**
  37406. * Gets or sets the inner angle for the directional cone.
  37407. */
  37408. get directionalConeInnerAngle(): number;
  37409. /**
  37410. * Gets or sets the inner angle for the directional cone.
  37411. */
  37412. set directionalConeInnerAngle(value: number);
  37413. /**
  37414. * Gets or sets the outer angle for the directional cone.
  37415. */
  37416. get directionalConeOuterAngle(): number;
  37417. /**
  37418. * Gets or sets the outer angle for the directional cone.
  37419. */
  37420. set directionalConeOuterAngle(value: number);
  37421. /**
  37422. * Sets the position of the emitter if spatial sound is enabled
  37423. * @param newPosition Defines the new posisiton
  37424. */
  37425. setPosition(newPosition: Vector3): void;
  37426. /**
  37427. * Sets the local direction of the emitter if spatial sound is enabled
  37428. * @param newLocalDirection Defines the new local direction
  37429. */
  37430. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37431. private _updateDirection;
  37432. /** @hidden */
  37433. updateDistanceFromListener(): void;
  37434. /**
  37435. * Sets a new custom attenuation function for the sound.
  37436. * @param callback Defines the function used for the attenuation
  37437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37438. */
  37439. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37440. /**
  37441. * Play the sound
  37442. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37443. * @param offset (optional) Start the sound at a specific time in seconds
  37444. * @param length (optional) Sound duration (in seconds)
  37445. */
  37446. play(time?: number, offset?: number, length?: number): void;
  37447. private _onended;
  37448. /**
  37449. * Stop the sound
  37450. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37451. */
  37452. stop(time?: number): void;
  37453. /**
  37454. * Put the sound in pause
  37455. */
  37456. pause(): void;
  37457. /**
  37458. * Sets a dedicated volume for this sounds
  37459. * @param newVolume Define the new volume of the sound
  37460. * @param time Define time for gradual change to new volume
  37461. */
  37462. setVolume(newVolume: number, time?: number): void;
  37463. /**
  37464. * Set the sound play back rate
  37465. * @param newPlaybackRate Define the playback rate the sound should be played at
  37466. */
  37467. setPlaybackRate(newPlaybackRate: number): void;
  37468. /**
  37469. * Gets the volume of the sound.
  37470. * @returns the volume of the sound
  37471. */
  37472. getVolume(): number;
  37473. /**
  37474. * Attach the sound to a dedicated mesh
  37475. * @param transformNode The transform node to connect the sound with
  37476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37477. */
  37478. attachToMesh(transformNode: TransformNode): void;
  37479. /**
  37480. * Detach the sound from the previously attached mesh
  37481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37482. */
  37483. detachFromMesh(): void;
  37484. private _onRegisterAfterWorldMatrixUpdate;
  37485. /**
  37486. * Clone the current sound in the scene.
  37487. * @returns the new sound clone
  37488. */
  37489. clone(): Nullable<Sound>;
  37490. /**
  37491. * Gets the current underlying audio buffer containing the data
  37492. * @returns the audio buffer
  37493. */
  37494. getAudioBuffer(): Nullable<AudioBuffer>;
  37495. /**
  37496. * Serializes the Sound in a JSON representation
  37497. * @returns the JSON representation of the sound
  37498. */
  37499. serialize(): any;
  37500. /**
  37501. * Parse a JSON representation of a sound to innstantiate in a given scene
  37502. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37503. * @param scene Define the scene the new parsed sound should be created in
  37504. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37505. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37506. * @returns the newly parsed sound
  37507. */
  37508. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37509. }
  37510. }
  37511. declare module BABYLON {
  37512. /**
  37513. * This defines an action helpful to play a defined sound on a triggered action.
  37514. */
  37515. export class PlaySoundAction extends Action {
  37516. private _sound;
  37517. /**
  37518. * Instantiate the action
  37519. * @param triggerOptions defines the trigger options
  37520. * @param sound defines the sound to play
  37521. * @param condition defines the trigger related conditions
  37522. */
  37523. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37524. /** @hidden */
  37525. _prepare(): void;
  37526. /**
  37527. * Execute the action and play the sound.
  37528. */
  37529. execute(): void;
  37530. /**
  37531. * Serializes the actions and its related information.
  37532. * @param parent defines the object to serialize in
  37533. * @returns the serialized object
  37534. */
  37535. serialize(parent: any): any;
  37536. }
  37537. /**
  37538. * This defines an action helpful to stop a defined sound on a triggered action.
  37539. */
  37540. export class StopSoundAction extends Action {
  37541. private _sound;
  37542. /**
  37543. * Instantiate the action
  37544. * @param triggerOptions defines the trigger options
  37545. * @param sound defines the sound to stop
  37546. * @param condition defines the trigger related conditions
  37547. */
  37548. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37549. /** @hidden */
  37550. _prepare(): void;
  37551. /**
  37552. * Execute the action and stop the sound.
  37553. */
  37554. execute(): void;
  37555. /**
  37556. * Serializes the actions and its related information.
  37557. * @param parent defines the object to serialize in
  37558. * @returns the serialized object
  37559. */
  37560. serialize(parent: any): any;
  37561. }
  37562. }
  37563. declare module BABYLON {
  37564. /**
  37565. * This defines an action responsible to change the value of a property
  37566. * by interpolating between its current value and the newly set one once triggered.
  37567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37568. */
  37569. export class InterpolateValueAction extends Action {
  37570. /**
  37571. * Defines the path of the property where the value should be interpolated
  37572. */
  37573. propertyPath: string;
  37574. /**
  37575. * Defines the target value at the end of the interpolation.
  37576. */
  37577. value: any;
  37578. /**
  37579. * Defines the time it will take for the property to interpolate to the value.
  37580. */
  37581. duration: number;
  37582. /**
  37583. * Defines if the other scene animations should be stopped when the action has been triggered
  37584. */
  37585. stopOtherAnimations?: boolean;
  37586. /**
  37587. * Defines a callback raised once the interpolation animation has been done.
  37588. */
  37589. onInterpolationDone?: () => void;
  37590. /**
  37591. * Observable triggered once the interpolation animation has been done.
  37592. */
  37593. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37594. private _target;
  37595. private _effectiveTarget;
  37596. private _property;
  37597. /**
  37598. * Instantiate the action
  37599. * @param triggerOptions defines the trigger options
  37600. * @param target defines the object containing the value to interpolate
  37601. * @param propertyPath defines the path to the property in the target object
  37602. * @param value defines the target value at the end of the interpolation
  37603. * @param duration deines the time it will take for the property to interpolate to the value.
  37604. * @param condition defines the trigger related conditions
  37605. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37606. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37607. */
  37608. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37609. /** @hidden */
  37610. _prepare(): void;
  37611. /**
  37612. * Execute the action starts the value interpolation.
  37613. */
  37614. execute(): void;
  37615. /**
  37616. * Serializes the actions and its related information.
  37617. * @param parent defines the object to serialize in
  37618. * @returns the serialized object
  37619. */
  37620. serialize(parent: any): any;
  37621. }
  37622. }
  37623. declare module BABYLON {
  37624. /**
  37625. * Options allowed during the creation of a sound track.
  37626. */
  37627. export interface ISoundTrackOptions {
  37628. /**
  37629. * The volume the sound track should take during creation
  37630. */
  37631. volume?: number;
  37632. /**
  37633. * Define if the sound track is the main sound track of the scene
  37634. */
  37635. mainTrack?: boolean;
  37636. }
  37637. /**
  37638. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37639. * It will be also used in a future release to apply effects on a specific track.
  37640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37641. */
  37642. export class SoundTrack {
  37643. /**
  37644. * The unique identifier of the sound track in the scene.
  37645. */
  37646. id: number;
  37647. /**
  37648. * The list of sounds included in the sound track.
  37649. */
  37650. soundCollection: Array<Sound>;
  37651. private _outputAudioNode;
  37652. private _scene;
  37653. private _connectedAnalyser;
  37654. private _options;
  37655. private _isInitialized;
  37656. /**
  37657. * Creates a new sound track.
  37658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37659. * @param scene Define the scene the sound track belongs to
  37660. * @param options
  37661. */
  37662. constructor(scene: Scene, options?: ISoundTrackOptions);
  37663. private _initializeSoundTrackAudioGraph;
  37664. /**
  37665. * Release the sound track and its associated resources
  37666. */
  37667. dispose(): void;
  37668. /**
  37669. * Adds a sound to this sound track
  37670. * @param sound define the cound to add
  37671. * @ignoreNaming
  37672. */
  37673. AddSound(sound: Sound): void;
  37674. /**
  37675. * Removes a sound to this sound track
  37676. * @param sound define the cound to remove
  37677. * @ignoreNaming
  37678. */
  37679. RemoveSound(sound: Sound): void;
  37680. /**
  37681. * Set a global volume for the full sound track.
  37682. * @param newVolume Define the new volume of the sound track
  37683. */
  37684. setVolume(newVolume: number): void;
  37685. /**
  37686. * Switch the panning model to HRTF:
  37687. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37689. */
  37690. switchPanningModelToHRTF(): void;
  37691. /**
  37692. * Switch the panning model to Equal Power:
  37693. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37695. */
  37696. switchPanningModelToEqualPower(): void;
  37697. /**
  37698. * Connect the sound track to an audio analyser allowing some amazing
  37699. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37701. * @param analyser The analyser to connect to the engine
  37702. */
  37703. connectToAnalyser(analyser: Analyser): void;
  37704. }
  37705. }
  37706. declare module BABYLON {
  37707. interface AbstractScene {
  37708. /**
  37709. * The list of sounds used in the scene.
  37710. */
  37711. sounds: Nullable<Array<Sound>>;
  37712. }
  37713. interface Scene {
  37714. /**
  37715. * @hidden
  37716. * Backing field
  37717. */
  37718. _mainSoundTrack: SoundTrack;
  37719. /**
  37720. * The main sound track played by the scene.
  37721. * It cotains your primary collection of sounds.
  37722. */
  37723. mainSoundTrack: SoundTrack;
  37724. /**
  37725. * The list of sound tracks added to the scene
  37726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37727. */
  37728. soundTracks: Nullable<Array<SoundTrack>>;
  37729. /**
  37730. * Gets a sound using a given name
  37731. * @param name defines the name to search for
  37732. * @return the found sound or null if not found at all.
  37733. */
  37734. getSoundByName(name: string): Nullable<Sound>;
  37735. /**
  37736. * Gets or sets if audio support is enabled
  37737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37738. */
  37739. audioEnabled: boolean;
  37740. /**
  37741. * Gets or sets if audio will be output to headphones
  37742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37743. */
  37744. headphone: boolean;
  37745. /**
  37746. * Gets or sets custom audio listener position provider
  37747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37748. */
  37749. audioListenerPositionProvider: Nullable<() => Vector3>;
  37750. /**
  37751. * Gets or sets a refresh rate when using 3D audio positioning
  37752. */
  37753. audioPositioningRefreshRate: number;
  37754. }
  37755. /**
  37756. * Defines the sound scene component responsible to manage any sounds
  37757. * in a given scene.
  37758. */
  37759. export class AudioSceneComponent implements ISceneSerializableComponent {
  37760. /**
  37761. * The component name helpfull to identify the component in the list of scene components.
  37762. */
  37763. readonly name: string;
  37764. /**
  37765. * The scene the component belongs to.
  37766. */
  37767. scene: Scene;
  37768. private _audioEnabled;
  37769. /**
  37770. * Gets whether audio is enabled or not.
  37771. * Please use related enable/disable method to switch state.
  37772. */
  37773. get audioEnabled(): boolean;
  37774. private _headphone;
  37775. /**
  37776. * Gets whether audio is outputing to headphone or not.
  37777. * Please use the according Switch methods to change output.
  37778. */
  37779. get headphone(): boolean;
  37780. /**
  37781. * Gets or sets a refresh rate when using 3D audio positioning
  37782. */
  37783. audioPositioningRefreshRate: number;
  37784. private _audioListenerPositionProvider;
  37785. /**
  37786. * Gets the current audio listener position provider
  37787. */
  37788. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37789. /**
  37790. * Sets a custom listener position for all sounds in the scene
  37791. * By default, this is the position of the first active camera
  37792. */
  37793. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37794. /**
  37795. * Creates a new instance of the component for the given scene
  37796. * @param scene Defines the scene to register the component in
  37797. */
  37798. constructor(scene: Scene);
  37799. /**
  37800. * Registers the component in a given scene
  37801. */
  37802. register(): void;
  37803. /**
  37804. * Rebuilds the elements related to this component in case of
  37805. * context lost for instance.
  37806. */
  37807. rebuild(): void;
  37808. /**
  37809. * Serializes the component data to the specified json object
  37810. * @param serializationObject The object to serialize to
  37811. */
  37812. serialize(serializationObject: any): void;
  37813. /**
  37814. * Adds all the elements from the container to the scene
  37815. * @param container the container holding the elements
  37816. */
  37817. addFromContainer(container: AbstractScene): void;
  37818. /**
  37819. * Removes all the elements in the container from the scene
  37820. * @param container contains the elements to remove
  37821. * @param dispose if the removed element should be disposed (default: false)
  37822. */
  37823. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37824. /**
  37825. * Disposes the component and the associated ressources.
  37826. */
  37827. dispose(): void;
  37828. /**
  37829. * Disables audio in the associated scene.
  37830. */
  37831. disableAudio(): void;
  37832. /**
  37833. * Enables audio in the associated scene.
  37834. */
  37835. enableAudio(): void;
  37836. /**
  37837. * Switch audio to headphone output.
  37838. */
  37839. switchAudioModeForHeadphones(): void;
  37840. /**
  37841. * Switch audio to normal speakers.
  37842. */
  37843. switchAudioModeForNormalSpeakers(): void;
  37844. private _cachedCameraDirection;
  37845. private _cachedCameraPosition;
  37846. private _lastCheck;
  37847. private _afterRender;
  37848. }
  37849. }
  37850. declare module BABYLON {
  37851. /**
  37852. * Wraps one or more Sound objects and selects one with random weight for playback.
  37853. */
  37854. export class WeightedSound {
  37855. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37856. loop: boolean;
  37857. private _coneInnerAngle;
  37858. private _coneOuterAngle;
  37859. private _volume;
  37860. /** A Sound is currently playing. */
  37861. isPlaying: boolean;
  37862. /** A Sound is currently paused. */
  37863. isPaused: boolean;
  37864. private _sounds;
  37865. private _weights;
  37866. private _currentIndex?;
  37867. /**
  37868. * Creates a new WeightedSound from the list of sounds given.
  37869. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37870. * @param sounds Array of Sounds that will be selected from.
  37871. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37872. */
  37873. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37874. /**
  37875. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37876. */
  37877. get directionalConeInnerAngle(): number;
  37878. /**
  37879. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37880. */
  37881. set directionalConeInnerAngle(value: number);
  37882. /**
  37883. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37884. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37885. */
  37886. get directionalConeOuterAngle(): number;
  37887. /**
  37888. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37889. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37890. */
  37891. set directionalConeOuterAngle(value: number);
  37892. /**
  37893. * Playback volume.
  37894. */
  37895. get volume(): number;
  37896. /**
  37897. * Playback volume.
  37898. */
  37899. set volume(value: number);
  37900. private _onended;
  37901. /**
  37902. * Suspend playback
  37903. */
  37904. pause(): void;
  37905. /**
  37906. * Stop playback
  37907. */
  37908. stop(): void;
  37909. /**
  37910. * Start playback.
  37911. * @param startOffset Position the clip head at a specific time in seconds.
  37912. */
  37913. play(startOffset?: number): void;
  37914. }
  37915. }
  37916. declare module BABYLON {
  37917. /**
  37918. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37919. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37920. */
  37921. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37922. /**
  37923. * Gets the name of the behavior.
  37924. */
  37925. get name(): string;
  37926. /**
  37927. * The easing function used by animations
  37928. */
  37929. static EasingFunction: BackEase;
  37930. /**
  37931. * The easing mode used by animations
  37932. */
  37933. static EasingMode: number;
  37934. /**
  37935. * The duration of the animation, in milliseconds
  37936. */
  37937. transitionDuration: number;
  37938. /**
  37939. * Length of the distance animated by the transition when lower radius is reached
  37940. */
  37941. lowerRadiusTransitionRange: number;
  37942. /**
  37943. * Length of the distance animated by the transition when upper radius is reached
  37944. */
  37945. upperRadiusTransitionRange: number;
  37946. private _autoTransitionRange;
  37947. /**
  37948. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37949. */
  37950. get autoTransitionRange(): boolean;
  37951. /**
  37952. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37953. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37954. */
  37955. set autoTransitionRange(value: boolean);
  37956. private _attachedCamera;
  37957. private _onAfterCheckInputsObserver;
  37958. private _onMeshTargetChangedObserver;
  37959. /**
  37960. * Initializes the behavior.
  37961. */
  37962. init(): void;
  37963. /**
  37964. * Attaches the behavior to its arc rotate camera.
  37965. * @param camera Defines the camera to attach the behavior to
  37966. */
  37967. attach(camera: ArcRotateCamera): void;
  37968. /**
  37969. * Detaches the behavior from its current arc rotate camera.
  37970. */
  37971. detach(): void;
  37972. private _radiusIsAnimating;
  37973. private _radiusBounceTransition;
  37974. private _animatables;
  37975. private _cachedWheelPrecision;
  37976. /**
  37977. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37978. * @param radiusLimit The limit to check against.
  37979. * @return Bool to indicate if at limit.
  37980. */
  37981. private _isRadiusAtLimit;
  37982. /**
  37983. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37984. * @param radiusDelta The delta by which to animate to. Can be negative.
  37985. */
  37986. private _applyBoundRadiusAnimation;
  37987. /**
  37988. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37989. */
  37990. protected _clearAnimationLocks(): void;
  37991. /**
  37992. * Stops and removes all animations that have been applied to the camera
  37993. */
  37994. stopAllAnimations(): void;
  37995. }
  37996. }
  37997. declare module BABYLON {
  37998. /**
  37999. * 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.
  38000. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38001. */
  38002. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38003. /**
  38004. * Gets the name of the behavior.
  38005. */
  38006. get name(): string;
  38007. private _mode;
  38008. private _radiusScale;
  38009. private _positionScale;
  38010. private _defaultElevation;
  38011. private _elevationReturnTime;
  38012. private _elevationReturnWaitTime;
  38013. private _zoomStopsAnimation;
  38014. private _framingTime;
  38015. /**
  38016. * The easing function used by animations
  38017. */
  38018. static EasingFunction: ExponentialEase;
  38019. /**
  38020. * The easing mode used by animations
  38021. */
  38022. static EasingMode: number;
  38023. /**
  38024. * Sets the current mode used by the behavior
  38025. */
  38026. set mode(mode: number);
  38027. /**
  38028. * Gets current mode used by the behavior.
  38029. */
  38030. get mode(): number;
  38031. /**
  38032. * Sets the scale applied to the radius (1 by default)
  38033. */
  38034. set radiusScale(radius: number);
  38035. /**
  38036. * Gets the scale applied to the radius
  38037. */
  38038. get radiusScale(): number;
  38039. /**
  38040. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38041. */
  38042. set positionScale(scale: number);
  38043. /**
  38044. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38045. */
  38046. get positionScale(): number;
  38047. /**
  38048. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38049. * behaviour is triggered, in radians.
  38050. */
  38051. set defaultElevation(elevation: number);
  38052. /**
  38053. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38054. * behaviour is triggered, in radians.
  38055. */
  38056. get defaultElevation(): number;
  38057. /**
  38058. * Sets the time (in milliseconds) taken to return to the default beta position.
  38059. * Negative value indicates camera should not return to default.
  38060. */
  38061. set elevationReturnTime(speed: number);
  38062. /**
  38063. * Gets the time (in milliseconds) taken to return to the default beta position.
  38064. * Negative value indicates camera should not return to default.
  38065. */
  38066. get elevationReturnTime(): number;
  38067. /**
  38068. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38069. */
  38070. set elevationReturnWaitTime(time: number);
  38071. /**
  38072. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38073. */
  38074. get elevationReturnWaitTime(): number;
  38075. /**
  38076. * Sets the flag that indicates if user zooming should stop animation.
  38077. */
  38078. set zoomStopsAnimation(flag: boolean);
  38079. /**
  38080. * Gets the flag that indicates if user zooming should stop animation.
  38081. */
  38082. get zoomStopsAnimation(): boolean;
  38083. /**
  38084. * Sets the transition time when framing the mesh, in milliseconds
  38085. */
  38086. set framingTime(time: number);
  38087. /**
  38088. * Gets the transition time when framing the mesh, in milliseconds
  38089. */
  38090. get framingTime(): number;
  38091. /**
  38092. * Define if the behavior should automatically change the configured
  38093. * camera limits and sensibilities.
  38094. */
  38095. autoCorrectCameraLimitsAndSensibility: boolean;
  38096. private _onPrePointerObservableObserver;
  38097. private _onAfterCheckInputsObserver;
  38098. private _onMeshTargetChangedObserver;
  38099. private _attachedCamera;
  38100. private _isPointerDown;
  38101. private _lastInteractionTime;
  38102. /**
  38103. * Initializes the behavior.
  38104. */
  38105. init(): void;
  38106. /**
  38107. * Attaches the behavior to its arc rotate camera.
  38108. * @param camera Defines the camera to attach the behavior to
  38109. */
  38110. attach(camera: ArcRotateCamera): void;
  38111. /**
  38112. * Detaches the behavior from its current arc rotate camera.
  38113. */
  38114. detach(): void;
  38115. private _animatables;
  38116. private _betaIsAnimating;
  38117. private _betaTransition;
  38118. private _radiusTransition;
  38119. private _vectorTransition;
  38120. /**
  38121. * Targets the given mesh and updates zoom level accordingly.
  38122. * @param mesh The mesh to target.
  38123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38125. */
  38126. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38127. /**
  38128. * Targets the given mesh with its children and updates zoom level accordingly.
  38129. * @param mesh The mesh to target.
  38130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38132. */
  38133. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38134. /**
  38135. * Targets the given meshes with their children and updates zoom level accordingly.
  38136. * @param meshes The mesh to target.
  38137. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38138. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38139. */
  38140. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38141. /**
  38142. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38143. * @param minimumWorld Determines the smaller position of the bounding box extend
  38144. * @param maximumWorld Determines the bigger position of the bounding box extend
  38145. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38146. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38147. */
  38148. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38149. /**
  38150. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38151. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38152. * frustum width.
  38153. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38154. * to fully enclose the mesh in the viewing frustum.
  38155. */
  38156. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38157. /**
  38158. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38159. * is automatically returned to its default position (expected to be above ground plane).
  38160. */
  38161. private _maintainCameraAboveGround;
  38162. /**
  38163. * Returns the frustum slope based on the canvas ratio and camera FOV
  38164. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38165. */
  38166. private _getFrustumSlope;
  38167. /**
  38168. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38169. */
  38170. private _clearAnimationLocks;
  38171. /**
  38172. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38173. */
  38174. private _applyUserInteraction;
  38175. /**
  38176. * Stops and removes all animations that have been applied to the camera
  38177. */
  38178. stopAllAnimations(): void;
  38179. /**
  38180. * Gets a value indicating if the user is moving the camera
  38181. */
  38182. get isUserIsMoving(): boolean;
  38183. /**
  38184. * The camera can move all the way towards the mesh.
  38185. */
  38186. static IgnoreBoundsSizeMode: number;
  38187. /**
  38188. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38189. */
  38190. static FitFrustumSidesMode: number;
  38191. }
  38192. }
  38193. declare module BABYLON {
  38194. /**
  38195. * Base class for Camera Pointer Inputs.
  38196. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38197. * for example usage.
  38198. */
  38199. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38200. /**
  38201. * Defines the camera the input is attached to.
  38202. */
  38203. abstract camera: Camera;
  38204. /**
  38205. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38206. */
  38207. protected _altKey: boolean;
  38208. protected _ctrlKey: boolean;
  38209. protected _metaKey: boolean;
  38210. protected _shiftKey: boolean;
  38211. /**
  38212. * Which mouse buttons were pressed at time of last mouse event.
  38213. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38214. */
  38215. protected _buttonsPressed: number;
  38216. /**
  38217. * Defines the buttons associated with the input to handle camera move.
  38218. */
  38219. buttons: number[];
  38220. /**
  38221. * Attach the input controls to a specific dom element to get the input from.
  38222. * @param element Defines the element the controls should be listened from
  38223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38224. */
  38225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38226. /**
  38227. * Detach the current controls from the specified dom element.
  38228. * @param element Defines the element to stop listening the inputs from
  38229. */
  38230. detachControl(element: Nullable<HTMLElement>): void;
  38231. /**
  38232. * Gets the class name of the current input.
  38233. * @returns the class name
  38234. */
  38235. getClassName(): string;
  38236. /**
  38237. * Get the friendly name associated with the input class.
  38238. * @returns the input friendly name
  38239. */
  38240. getSimpleName(): string;
  38241. /**
  38242. * Called on pointer POINTERDOUBLETAP event.
  38243. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38244. */
  38245. protected onDoubleTap(type: string): void;
  38246. /**
  38247. * Called on pointer POINTERMOVE event if only a single touch is active.
  38248. * Override this method to provide functionality.
  38249. */
  38250. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38251. /**
  38252. * Called on pointer POINTERMOVE event if multiple touches are active.
  38253. * Override this method to provide functionality.
  38254. */
  38255. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38256. /**
  38257. * Called on JS contextmenu event.
  38258. * Override this method to provide functionality.
  38259. */
  38260. protected onContextMenu(evt: PointerEvent): void;
  38261. /**
  38262. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38263. * press.
  38264. * Override this method to provide functionality.
  38265. */
  38266. protected onButtonDown(evt: PointerEvent): void;
  38267. /**
  38268. * Called each time a new POINTERUP event occurs. Ie, for each button
  38269. * release.
  38270. * Override this method to provide functionality.
  38271. */
  38272. protected onButtonUp(evt: PointerEvent): void;
  38273. /**
  38274. * Called when window becomes inactive.
  38275. * Override this method to provide functionality.
  38276. */
  38277. protected onLostFocus(): void;
  38278. private _pointerInput;
  38279. private _observer;
  38280. private _onLostFocus;
  38281. private pointA;
  38282. private pointB;
  38283. }
  38284. }
  38285. declare module BABYLON {
  38286. /**
  38287. * Manage the pointers inputs to control an arc rotate camera.
  38288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38289. */
  38290. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38291. /**
  38292. * Defines the camera the input is attached to.
  38293. */
  38294. camera: ArcRotateCamera;
  38295. /**
  38296. * Gets the class name of the current input.
  38297. * @returns the class name
  38298. */
  38299. getClassName(): string;
  38300. /**
  38301. * Defines the buttons associated with the input to handle camera move.
  38302. */
  38303. buttons: number[];
  38304. /**
  38305. * Defines the pointer angular sensibility along the X axis or how fast is
  38306. * the camera rotating.
  38307. */
  38308. angularSensibilityX: number;
  38309. /**
  38310. * Defines the pointer angular sensibility along the Y axis or how fast is
  38311. * the camera rotating.
  38312. */
  38313. angularSensibilityY: number;
  38314. /**
  38315. * Defines the pointer pinch precision or how fast is the camera zooming.
  38316. */
  38317. pinchPrecision: number;
  38318. /**
  38319. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38320. * from 0.
  38321. * It defines the percentage of current camera.radius to use as delta when
  38322. * pinch zoom is used.
  38323. */
  38324. pinchDeltaPercentage: number;
  38325. /**
  38326. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38327. * that any object in the plane at the camera's target point will scale
  38328. * perfectly with finger motion.
  38329. * Overrides pinchDeltaPercentage and pinchPrecision.
  38330. */
  38331. useNaturalPinchZoom: boolean;
  38332. /**
  38333. * Defines the pointer panning sensibility or how fast is the camera moving.
  38334. */
  38335. panningSensibility: number;
  38336. /**
  38337. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38338. */
  38339. multiTouchPanning: boolean;
  38340. /**
  38341. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38342. * zoom (pinch) through multitouch.
  38343. */
  38344. multiTouchPanAndZoom: boolean;
  38345. /**
  38346. * Revers pinch action direction.
  38347. */
  38348. pinchInwards: boolean;
  38349. private _isPanClick;
  38350. private _twoFingerActivityCount;
  38351. private _isPinching;
  38352. /**
  38353. * Called on pointer POINTERMOVE event if only a single touch is active.
  38354. */
  38355. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38356. /**
  38357. * Called on pointer POINTERDOUBLETAP event.
  38358. */
  38359. protected onDoubleTap(type: string): void;
  38360. /**
  38361. * Called on pointer POINTERMOVE event if multiple touches are active.
  38362. */
  38363. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38364. /**
  38365. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38366. * press.
  38367. */
  38368. protected onButtonDown(evt: PointerEvent): void;
  38369. /**
  38370. * Called each time a new POINTERUP event occurs. Ie, for each button
  38371. * release.
  38372. */
  38373. protected onButtonUp(evt: PointerEvent): void;
  38374. /**
  38375. * Called when window becomes inactive.
  38376. */
  38377. protected onLostFocus(): void;
  38378. }
  38379. }
  38380. declare module BABYLON {
  38381. /**
  38382. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38384. */
  38385. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38386. /**
  38387. * Defines the camera the input is attached to.
  38388. */
  38389. camera: ArcRotateCamera;
  38390. /**
  38391. * Defines the list of key codes associated with the up action (increase alpha)
  38392. */
  38393. keysUp: number[];
  38394. /**
  38395. * Defines the list of key codes associated with the down action (decrease alpha)
  38396. */
  38397. keysDown: number[];
  38398. /**
  38399. * Defines the list of key codes associated with the left action (increase beta)
  38400. */
  38401. keysLeft: number[];
  38402. /**
  38403. * Defines the list of key codes associated with the right action (decrease beta)
  38404. */
  38405. keysRight: number[];
  38406. /**
  38407. * Defines the list of key codes associated with the reset action.
  38408. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38409. */
  38410. keysReset: number[];
  38411. /**
  38412. * Defines the panning sensibility of the inputs.
  38413. * (How fast is the camera panning)
  38414. */
  38415. panningSensibility: number;
  38416. /**
  38417. * Defines the zooming sensibility of the inputs.
  38418. * (How fast is the camera zooming)
  38419. */
  38420. zoomingSensibility: number;
  38421. /**
  38422. * Defines whether maintaining the alt key down switch the movement mode from
  38423. * orientation to zoom.
  38424. */
  38425. useAltToZoom: boolean;
  38426. /**
  38427. * Rotation speed of the camera
  38428. */
  38429. angularSpeed: number;
  38430. private _keys;
  38431. private _ctrlPressed;
  38432. private _altPressed;
  38433. private _onCanvasBlurObserver;
  38434. private _onKeyboardObserver;
  38435. private _engine;
  38436. private _scene;
  38437. /**
  38438. * Attach the input controls to a specific dom element to get the input from.
  38439. * @param element Defines the element the controls should be listened from
  38440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38441. */
  38442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38443. /**
  38444. * Detach the current controls from the specified dom element.
  38445. * @param element Defines the element to stop listening the inputs from
  38446. */
  38447. detachControl(element: Nullable<HTMLElement>): void;
  38448. /**
  38449. * Update the current camera state depending on the inputs that have been used this frame.
  38450. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38451. */
  38452. checkInputs(): void;
  38453. /**
  38454. * Gets the class name of the current intput.
  38455. * @returns the class name
  38456. */
  38457. getClassName(): string;
  38458. /**
  38459. * Get the friendly name associated with the input class.
  38460. * @returns the input friendly name
  38461. */
  38462. getSimpleName(): string;
  38463. }
  38464. }
  38465. declare module BABYLON {
  38466. /**
  38467. * Manage the mouse wheel inputs to control an arc rotate camera.
  38468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38469. */
  38470. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38471. /**
  38472. * Defines the camera the input is attached to.
  38473. */
  38474. camera: ArcRotateCamera;
  38475. /**
  38476. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38477. */
  38478. wheelPrecision: number;
  38479. /**
  38480. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38481. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38482. */
  38483. wheelDeltaPercentage: number;
  38484. private _wheel;
  38485. private _observer;
  38486. private computeDeltaFromMouseWheelLegacyEvent;
  38487. /**
  38488. * Attach the input controls to a specific dom element to get the input from.
  38489. * @param element Defines the element the controls should be listened from
  38490. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38491. */
  38492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38493. /**
  38494. * Detach the current controls from the specified dom element.
  38495. * @param element Defines the element to stop listening the inputs from
  38496. */
  38497. detachControl(element: Nullable<HTMLElement>): void;
  38498. /**
  38499. * Gets the class name of the current intput.
  38500. * @returns the class name
  38501. */
  38502. getClassName(): string;
  38503. /**
  38504. * Get the friendly name associated with the input class.
  38505. * @returns the input friendly name
  38506. */
  38507. getSimpleName(): string;
  38508. }
  38509. }
  38510. declare module BABYLON {
  38511. /**
  38512. * Default Inputs manager for the ArcRotateCamera.
  38513. * It groups all the default supported inputs for ease of use.
  38514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38515. */
  38516. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38517. /**
  38518. * Instantiates a new ArcRotateCameraInputsManager.
  38519. * @param camera Defines the camera the inputs belong to
  38520. */
  38521. constructor(camera: ArcRotateCamera);
  38522. /**
  38523. * Add mouse wheel input support to the input manager.
  38524. * @returns the current input manager
  38525. */
  38526. addMouseWheel(): ArcRotateCameraInputsManager;
  38527. /**
  38528. * Add pointers input support to the input manager.
  38529. * @returns the current input manager
  38530. */
  38531. addPointers(): ArcRotateCameraInputsManager;
  38532. /**
  38533. * Add keyboard input support to the input manager.
  38534. * @returns the current input manager
  38535. */
  38536. addKeyboard(): ArcRotateCameraInputsManager;
  38537. }
  38538. }
  38539. declare module BABYLON {
  38540. /**
  38541. * This represents an orbital type of camera.
  38542. *
  38543. * 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.
  38544. * 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.
  38545. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38546. */
  38547. export class ArcRotateCamera extends TargetCamera {
  38548. /**
  38549. * Defines the rotation angle of the camera along the longitudinal axis.
  38550. */
  38551. alpha: number;
  38552. /**
  38553. * Defines the rotation angle of the camera along the latitudinal axis.
  38554. */
  38555. beta: number;
  38556. /**
  38557. * Defines the radius of the camera from it s target point.
  38558. */
  38559. radius: number;
  38560. protected _target: Vector3;
  38561. protected _targetHost: Nullable<AbstractMesh>;
  38562. /**
  38563. * Defines the target point of the camera.
  38564. * The camera looks towards it form the radius distance.
  38565. */
  38566. get target(): Vector3;
  38567. set target(value: Vector3);
  38568. /**
  38569. * Define the current local position of the camera in the scene
  38570. */
  38571. get position(): Vector3;
  38572. set position(newPosition: Vector3);
  38573. protected _upVector: Vector3;
  38574. protected _upToYMatrix: Matrix;
  38575. protected _YToUpMatrix: Matrix;
  38576. /**
  38577. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38578. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38579. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38580. */
  38581. set upVector(vec: Vector3);
  38582. get upVector(): Vector3;
  38583. /**
  38584. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38585. */
  38586. setMatUp(): void;
  38587. /**
  38588. * Current inertia value on the longitudinal axis.
  38589. * The bigger this number the longer it will take for the camera to stop.
  38590. */
  38591. inertialAlphaOffset: number;
  38592. /**
  38593. * Current inertia value on the latitudinal axis.
  38594. * The bigger this number the longer it will take for the camera to stop.
  38595. */
  38596. inertialBetaOffset: number;
  38597. /**
  38598. * Current inertia value on the radius axis.
  38599. * The bigger this number the longer it will take for the camera to stop.
  38600. */
  38601. inertialRadiusOffset: number;
  38602. /**
  38603. * Minimum allowed angle on the longitudinal axis.
  38604. * This can help limiting how the Camera is able to move in the scene.
  38605. */
  38606. lowerAlphaLimit: Nullable<number>;
  38607. /**
  38608. * Maximum allowed angle on the longitudinal axis.
  38609. * This can help limiting how the Camera is able to move in the scene.
  38610. */
  38611. upperAlphaLimit: Nullable<number>;
  38612. /**
  38613. * Minimum allowed angle on the latitudinal axis.
  38614. * This can help limiting how the Camera is able to move in the scene.
  38615. */
  38616. lowerBetaLimit: number;
  38617. /**
  38618. * Maximum allowed angle on the latitudinal axis.
  38619. * This can help limiting how the Camera is able to move in the scene.
  38620. */
  38621. upperBetaLimit: number;
  38622. /**
  38623. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38624. * This can help limiting how the Camera is able to move in the scene.
  38625. */
  38626. lowerRadiusLimit: Nullable<number>;
  38627. /**
  38628. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38629. * This can help limiting how the Camera is able to move in the scene.
  38630. */
  38631. upperRadiusLimit: Nullable<number>;
  38632. /**
  38633. * Defines the current inertia value used during panning of the camera along the X axis.
  38634. */
  38635. inertialPanningX: number;
  38636. /**
  38637. * Defines the current inertia value used during panning of the camera along the Y axis.
  38638. */
  38639. inertialPanningY: number;
  38640. /**
  38641. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38642. * Basically if your fingers moves away from more than this distance you will be considered
  38643. * in pinch mode.
  38644. */
  38645. pinchToPanMaxDistance: number;
  38646. /**
  38647. * Defines the maximum distance the camera can pan.
  38648. * This could help keeping the cammera always in your scene.
  38649. */
  38650. panningDistanceLimit: Nullable<number>;
  38651. /**
  38652. * Defines the target of the camera before paning.
  38653. */
  38654. panningOriginTarget: Vector3;
  38655. /**
  38656. * Defines the value of the inertia used during panning.
  38657. * 0 would mean stop inertia and one would mean no decelleration at all.
  38658. */
  38659. panningInertia: number;
  38660. /**
  38661. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38662. */
  38663. get angularSensibilityX(): number;
  38664. set angularSensibilityX(value: number);
  38665. /**
  38666. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38667. */
  38668. get angularSensibilityY(): number;
  38669. set angularSensibilityY(value: number);
  38670. /**
  38671. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38672. */
  38673. get pinchPrecision(): number;
  38674. set pinchPrecision(value: number);
  38675. /**
  38676. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38677. * It will be used instead of pinchDeltaPrecision if different from 0.
  38678. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38679. */
  38680. get pinchDeltaPercentage(): number;
  38681. set pinchDeltaPercentage(value: number);
  38682. /**
  38683. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38684. * and pinch delta percentage.
  38685. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38686. * that any object in the plane at the camera's target point will scale
  38687. * perfectly with finger motion.
  38688. */
  38689. get useNaturalPinchZoom(): boolean;
  38690. set useNaturalPinchZoom(value: boolean);
  38691. /**
  38692. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38693. */
  38694. get panningSensibility(): number;
  38695. set panningSensibility(value: number);
  38696. /**
  38697. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38698. */
  38699. get keysUp(): number[];
  38700. set keysUp(value: number[]);
  38701. /**
  38702. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38703. */
  38704. get keysDown(): number[];
  38705. set keysDown(value: number[]);
  38706. /**
  38707. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38708. */
  38709. get keysLeft(): number[];
  38710. set keysLeft(value: number[]);
  38711. /**
  38712. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38713. */
  38714. get keysRight(): number[];
  38715. set keysRight(value: number[]);
  38716. /**
  38717. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38718. */
  38719. get wheelPrecision(): number;
  38720. set wheelPrecision(value: number);
  38721. /**
  38722. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38723. * It will be used instead of pinchDeltaPrecision if different from 0.
  38724. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38725. */
  38726. get wheelDeltaPercentage(): number;
  38727. set wheelDeltaPercentage(value: number);
  38728. /**
  38729. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38730. */
  38731. zoomOnFactor: number;
  38732. /**
  38733. * Defines a screen offset for the camera position.
  38734. */
  38735. targetScreenOffset: Vector2;
  38736. /**
  38737. * Allows the camera to be completely reversed.
  38738. * If false the camera can not arrive upside down.
  38739. */
  38740. allowUpsideDown: boolean;
  38741. /**
  38742. * Define if double tap/click is used to restore the previously saved state of the camera.
  38743. */
  38744. useInputToRestoreState: boolean;
  38745. /** @hidden */
  38746. _viewMatrix: Matrix;
  38747. /** @hidden */
  38748. _useCtrlForPanning: boolean;
  38749. /** @hidden */
  38750. _panningMouseButton: number;
  38751. /**
  38752. * Defines the input associated to the camera.
  38753. */
  38754. inputs: ArcRotateCameraInputsManager;
  38755. /** @hidden */
  38756. _reset: () => void;
  38757. /**
  38758. * Defines the allowed panning axis.
  38759. */
  38760. panningAxis: Vector3;
  38761. protected _localDirection: Vector3;
  38762. protected _transformedDirection: Vector3;
  38763. private _bouncingBehavior;
  38764. /**
  38765. * Gets the bouncing behavior of the camera if it has been enabled.
  38766. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38767. */
  38768. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38769. /**
  38770. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38771. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38772. */
  38773. get useBouncingBehavior(): boolean;
  38774. set useBouncingBehavior(value: boolean);
  38775. private _framingBehavior;
  38776. /**
  38777. * Gets the framing behavior of the camera if it has been enabled.
  38778. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38779. */
  38780. get framingBehavior(): Nullable<FramingBehavior>;
  38781. /**
  38782. * Defines if the framing behavior of the camera is enabled on the camera.
  38783. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38784. */
  38785. get useFramingBehavior(): boolean;
  38786. set useFramingBehavior(value: boolean);
  38787. private _autoRotationBehavior;
  38788. /**
  38789. * Gets the auto rotation behavior of the camera if it has been enabled.
  38790. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38791. */
  38792. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38793. /**
  38794. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38795. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38796. */
  38797. get useAutoRotationBehavior(): boolean;
  38798. set useAutoRotationBehavior(value: boolean);
  38799. /**
  38800. * Observable triggered when the mesh target has been changed on the camera.
  38801. */
  38802. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38803. /**
  38804. * Event raised when the camera is colliding with a mesh.
  38805. */
  38806. onCollide: (collidedMesh: AbstractMesh) => void;
  38807. /**
  38808. * Defines whether the camera should check collision with the objects oh the scene.
  38809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38810. */
  38811. checkCollisions: boolean;
  38812. /**
  38813. * Defines the collision radius of the camera.
  38814. * This simulates a sphere around the camera.
  38815. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38816. */
  38817. collisionRadius: Vector3;
  38818. protected _collider: Collider;
  38819. protected _previousPosition: Vector3;
  38820. protected _collisionVelocity: Vector3;
  38821. protected _newPosition: Vector3;
  38822. protected _previousAlpha: number;
  38823. protected _previousBeta: number;
  38824. protected _previousRadius: number;
  38825. protected _collisionTriggered: boolean;
  38826. protected _targetBoundingCenter: Nullable<Vector3>;
  38827. private _computationVector;
  38828. /**
  38829. * Instantiates a new ArcRotateCamera in a given scene
  38830. * @param name Defines the name of the camera
  38831. * @param alpha Defines the camera rotation along the logitudinal axis
  38832. * @param beta Defines the camera rotation along the latitudinal axis
  38833. * @param radius Defines the camera distance from its target
  38834. * @param target Defines the camera target
  38835. * @param scene Defines the scene the camera belongs to
  38836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38837. */
  38838. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38839. /** @hidden */
  38840. _initCache(): void;
  38841. /** @hidden */
  38842. _updateCache(ignoreParentClass?: boolean): void;
  38843. protected _getTargetPosition(): Vector3;
  38844. private _storedAlpha;
  38845. private _storedBeta;
  38846. private _storedRadius;
  38847. private _storedTarget;
  38848. private _storedTargetScreenOffset;
  38849. /**
  38850. * Stores the current state of the camera (alpha, beta, radius and target)
  38851. * @returns the camera itself
  38852. */
  38853. storeState(): Camera;
  38854. /**
  38855. * @hidden
  38856. * Restored camera state. You must call storeState() first
  38857. */
  38858. _restoreStateValues(): boolean;
  38859. /** @hidden */
  38860. _isSynchronizedViewMatrix(): boolean;
  38861. /**
  38862. * Attached controls to the current camera.
  38863. * @param element Defines the element the controls should be listened from
  38864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38865. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38866. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38867. */
  38868. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38869. /**
  38870. * Detach the current controls from the camera.
  38871. * The camera will stop reacting to inputs.
  38872. * @param element Defines the element to stop listening the inputs from
  38873. */
  38874. detachControl(element: HTMLElement): void;
  38875. /** @hidden */
  38876. _checkInputs(): void;
  38877. protected _checkLimits(): void;
  38878. /**
  38879. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38880. */
  38881. rebuildAnglesAndRadius(): void;
  38882. /**
  38883. * Use a position to define the current camera related information like alpha, beta and radius
  38884. * @param position Defines the position to set the camera at
  38885. */
  38886. setPosition(position: Vector3): void;
  38887. /**
  38888. * Defines the target the camera should look at.
  38889. * This will automatically adapt alpha beta and radius to fit within the new target.
  38890. * @param target Defines the new target as a Vector or a mesh
  38891. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38892. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38893. */
  38894. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38895. /** @hidden */
  38896. _getViewMatrix(): Matrix;
  38897. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38898. /**
  38899. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38900. * @param meshes Defines the mesh to zoom on
  38901. * @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)
  38902. */
  38903. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38904. /**
  38905. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38906. * The target will be changed but the radius
  38907. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38908. * @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)
  38909. */
  38910. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38911. min: Vector3;
  38912. max: Vector3;
  38913. distance: number;
  38914. }, doNotUpdateMaxZ?: boolean): void;
  38915. /**
  38916. * @override
  38917. * Override Camera.createRigCamera
  38918. */
  38919. createRigCamera(name: string, cameraIndex: number): Camera;
  38920. /**
  38921. * @hidden
  38922. * @override
  38923. * Override Camera._updateRigCameras
  38924. */
  38925. _updateRigCameras(): void;
  38926. /**
  38927. * Destroy the camera and release the current resources hold by it.
  38928. */
  38929. dispose(): void;
  38930. /**
  38931. * Gets the current object class name.
  38932. * @return the class name
  38933. */
  38934. getClassName(): string;
  38935. }
  38936. }
  38937. declare module BABYLON {
  38938. /**
  38939. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38941. */
  38942. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38943. /**
  38944. * Gets the name of the behavior.
  38945. */
  38946. get name(): string;
  38947. private _zoomStopsAnimation;
  38948. private _idleRotationSpeed;
  38949. private _idleRotationWaitTime;
  38950. private _idleRotationSpinupTime;
  38951. /**
  38952. * Sets the flag that indicates if user zooming should stop animation.
  38953. */
  38954. set zoomStopsAnimation(flag: boolean);
  38955. /**
  38956. * Gets the flag that indicates if user zooming should stop animation.
  38957. */
  38958. get zoomStopsAnimation(): boolean;
  38959. /**
  38960. * Sets the default speed at which the camera rotates around the model.
  38961. */
  38962. set idleRotationSpeed(speed: number);
  38963. /**
  38964. * Gets the default speed at which the camera rotates around the model.
  38965. */
  38966. get idleRotationSpeed(): number;
  38967. /**
  38968. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38969. */
  38970. set idleRotationWaitTime(time: number);
  38971. /**
  38972. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38973. */
  38974. get idleRotationWaitTime(): number;
  38975. /**
  38976. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38977. */
  38978. set idleRotationSpinupTime(time: number);
  38979. /**
  38980. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38981. */
  38982. get idleRotationSpinupTime(): number;
  38983. /**
  38984. * Gets a value indicating if the camera is currently rotating because of this behavior
  38985. */
  38986. get rotationInProgress(): boolean;
  38987. private _onPrePointerObservableObserver;
  38988. private _onAfterCheckInputsObserver;
  38989. private _attachedCamera;
  38990. private _isPointerDown;
  38991. private _lastFrameTime;
  38992. private _lastInteractionTime;
  38993. private _cameraRotationSpeed;
  38994. /**
  38995. * Initializes the behavior.
  38996. */
  38997. init(): void;
  38998. /**
  38999. * Attaches the behavior to its arc rotate camera.
  39000. * @param camera Defines the camera to attach the behavior to
  39001. */
  39002. attach(camera: ArcRotateCamera): void;
  39003. /**
  39004. * Detaches the behavior from its current arc rotate camera.
  39005. */
  39006. detach(): void;
  39007. /**
  39008. * Returns true if user is scrolling.
  39009. * @return true if user is scrolling.
  39010. */
  39011. private _userIsZooming;
  39012. private _lastFrameRadius;
  39013. private _shouldAnimationStopForInteraction;
  39014. /**
  39015. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39016. */
  39017. private _applyUserInteraction;
  39018. private _userIsMoving;
  39019. }
  39020. }
  39021. declare module BABYLON {
  39022. /**
  39023. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39024. */
  39025. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39026. private ui;
  39027. /**
  39028. * The name of the behavior
  39029. */
  39030. name: string;
  39031. /**
  39032. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39033. */
  39034. distanceAwayFromFace: number;
  39035. /**
  39036. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39037. */
  39038. distanceAwayFromBottomOfFace: number;
  39039. private _faceVectors;
  39040. private _target;
  39041. private _scene;
  39042. private _onRenderObserver;
  39043. private _tmpMatrix;
  39044. private _tmpVector;
  39045. /**
  39046. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39047. * @param ui The transform node that should be attched to the mesh
  39048. */
  39049. constructor(ui: TransformNode);
  39050. /**
  39051. * Initializes the behavior
  39052. */
  39053. init(): void;
  39054. private _closestFace;
  39055. private _zeroVector;
  39056. private _lookAtTmpMatrix;
  39057. private _lookAtToRef;
  39058. /**
  39059. * Attaches the AttachToBoxBehavior to the passed in mesh
  39060. * @param target The mesh that the specified node will be attached to
  39061. */
  39062. attach(target: Mesh): void;
  39063. /**
  39064. * Detaches the behavior from the mesh
  39065. */
  39066. detach(): void;
  39067. }
  39068. }
  39069. declare module BABYLON {
  39070. /**
  39071. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39072. */
  39073. export class FadeInOutBehavior implements Behavior<Mesh> {
  39074. /**
  39075. * Time in milliseconds to delay before fading in (Default: 0)
  39076. */
  39077. delay: number;
  39078. /**
  39079. * Time in milliseconds for the mesh to fade in (Default: 300)
  39080. */
  39081. fadeInTime: number;
  39082. private _millisecondsPerFrame;
  39083. private _hovered;
  39084. private _hoverValue;
  39085. private _ownerNode;
  39086. /**
  39087. * Instatiates the FadeInOutBehavior
  39088. */
  39089. constructor();
  39090. /**
  39091. * The name of the behavior
  39092. */
  39093. get name(): string;
  39094. /**
  39095. * Initializes the behavior
  39096. */
  39097. init(): void;
  39098. /**
  39099. * Attaches the fade behavior on the passed in mesh
  39100. * @param ownerNode The mesh that will be faded in/out once attached
  39101. */
  39102. attach(ownerNode: Mesh): void;
  39103. /**
  39104. * Detaches the behavior from the mesh
  39105. */
  39106. detach(): void;
  39107. /**
  39108. * Triggers the mesh to begin fading in or out
  39109. * @param value if the object should fade in or out (true to fade in)
  39110. */
  39111. fadeIn(value: boolean): void;
  39112. private _update;
  39113. private _setAllVisibility;
  39114. }
  39115. }
  39116. declare module BABYLON {
  39117. /**
  39118. * Class containing a set of static utilities functions for managing Pivots
  39119. * @hidden
  39120. */
  39121. export class PivotTools {
  39122. private static _PivotCached;
  39123. private static _OldPivotPoint;
  39124. private static _PivotTranslation;
  39125. private static _PivotTmpVector;
  39126. /** @hidden */
  39127. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39128. /** @hidden */
  39129. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39130. }
  39131. }
  39132. declare module BABYLON {
  39133. /**
  39134. * Class containing static functions to help procedurally build meshes
  39135. */
  39136. export class PlaneBuilder {
  39137. /**
  39138. * Creates a plane mesh
  39139. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39140. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39141. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39143. * * 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
  39144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39145. * @param name defines the name of the mesh
  39146. * @param options defines the options used to create the mesh
  39147. * @param scene defines the hosting scene
  39148. * @returns the plane mesh
  39149. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39150. */
  39151. static CreatePlane(name: string, options: {
  39152. size?: number;
  39153. width?: number;
  39154. height?: number;
  39155. sideOrientation?: number;
  39156. frontUVs?: Vector4;
  39157. backUVs?: Vector4;
  39158. updatable?: boolean;
  39159. sourcePlane?: Plane;
  39160. }, scene?: Nullable<Scene>): Mesh;
  39161. }
  39162. }
  39163. declare module BABYLON {
  39164. /**
  39165. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39166. */
  39167. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39168. private static _AnyMouseID;
  39169. /**
  39170. * Abstract mesh the behavior is set on
  39171. */
  39172. attachedNode: AbstractMesh;
  39173. private _dragPlane;
  39174. private _scene;
  39175. private _pointerObserver;
  39176. private _beforeRenderObserver;
  39177. private static _planeScene;
  39178. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39179. /**
  39180. * 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)
  39181. */
  39182. maxDragAngle: number;
  39183. /**
  39184. * @hidden
  39185. */
  39186. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39187. /**
  39188. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39189. */
  39190. currentDraggingPointerID: number;
  39191. /**
  39192. * The last position where the pointer hit the drag plane in world space
  39193. */
  39194. lastDragPosition: Vector3;
  39195. /**
  39196. * If the behavior is currently in a dragging state
  39197. */
  39198. dragging: boolean;
  39199. /**
  39200. * 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)
  39201. */
  39202. dragDeltaRatio: number;
  39203. /**
  39204. * If the drag plane orientation should be updated during the dragging (Default: true)
  39205. */
  39206. updateDragPlane: boolean;
  39207. private _debugMode;
  39208. private _moving;
  39209. /**
  39210. * Fires each time the attached mesh is dragged with the pointer
  39211. * * delta between last drag position and current drag position in world space
  39212. * * dragDistance along the drag axis
  39213. * * dragPlaneNormal normal of the current drag plane used during the drag
  39214. * * dragPlanePoint in world space where the drag intersects the drag plane
  39215. */
  39216. onDragObservable: Observable<{
  39217. delta: Vector3;
  39218. dragPlanePoint: Vector3;
  39219. dragPlaneNormal: Vector3;
  39220. dragDistance: number;
  39221. pointerId: number;
  39222. }>;
  39223. /**
  39224. * Fires each time a drag begins (eg. mouse down on mesh)
  39225. */
  39226. onDragStartObservable: Observable<{
  39227. dragPlanePoint: Vector3;
  39228. pointerId: number;
  39229. }>;
  39230. /**
  39231. * Fires each time a drag ends (eg. mouse release after drag)
  39232. */
  39233. onDragEndObservable: Observable<{
  39234. dragPlanePoint: Vector3;
  39235. pointerId: number;
  39236. }>;
  39237. /**
  39238. * If the attached mesh should be moved when dragged
  39239. */
  39240. moveAttached: boolean;
  39241. /**
  39242. * If the drag behavior will react to drag events (Default: true)
  39243. */
  39244. enabled: boolean;
  39245. /**
  39246. * If pointer events should start and release the drag (Default: true)
  39247. */
  39248. startAndReleaseDragOnPointerEvents: boolean;
  39249. /**
  39250. * If camera controls should be detached during the drag
  39251. */
  39252. detachCameraControls: boolean;
  39253. /**
  39254. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39255. */
  39256. useObjectOrientationForDragging: boolean;
  39257. private _options;
  39258. /**
  39259. * Gets the options used by the behavior
  39260. */
  39261. get options(): {
  39262. dragAxis?: Vector3;
  39263. dragPlaneNormal?: Vector3;
  39264. };
  39265. /**
  39266. * Sets the options used by the behavior
  39267. */
  39268. set options(options: {
  39269. dragAxis?: Vector3;
  39270. dragPlaneNormal?: Vector3;
  39271. });
  39272. /**
  39273. * Creates a pointer drag behavior that can be attached to a mesh
  39274. * @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)
  39275. */
  39276. constructor(options?: {
  39277. dragAxis?: Vector3;
  39278. dragPlaneNormal?: Vector3;
  39279. });
  39280. /**
  39281. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39282. */
  39283. validateDrag: (targetPosition: Vector3) => boolean;
  39284. /**
  39285. * The name of the behavior
  39286. */
  39287. get name(): string;
  39288. /**
  39289. * Initializes the behavior
  39290. */
  39291. init(): void;
  39292. private _tmpVector;
  39293. private _alternatePickedPoint;
  39294. private _worldDragAxis;
  39295. private _targetPosition;
  39296. private _attachedElement;
  39297. /**
  39298. * Attaches the drag behavior the passed in mesh
  39299. * @param ownerNode The mesh that will be dragged around once attached
  39300. * @param predicate Predicate to use for pick filtering
  39301. */
  39302. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39303. /**
  39304. * Force relase the drag action by code.
  39305. */
  39306. releaseDrag(): void;
  39307. private _startDragRay;
  39308. private _lastPointerRay;
  39309. /**
  39310. * Simulates the start of a pointer drag event on the behavior
  39311. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39312. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39313. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39314. */
  39315. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39316. private _startDrag;
  39317. private _dragDelta;
  39318. private _moveDrag;
  39319. private _pickWithRayOnDragPlane;
  39320. private _pointA;
  39321. private _pointB;
  39322. private _pointC;
  39323. private _lineA;
  39324. private _lineB;
  39325. private _localAxis;
  39326. private _lookAt;
  39327. private _updateDragPlanePosition;
  39328. /**
  39329. * Detaches the behavior from the mesh
  39330. */
  39331. detach(): void;
  39332. }
  39333. }
  39334. declare module BABYLON {
  39335. /**
  39336. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39337. */
  39338. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39339. private _dragBehaviorA;
  39340. private _dragBehaviorB;
  39341. private _startDistance;
  39342. private _initialScale;
  39343. private _targetScale;
  39344. private _ownerNode;
  39345. private _sceneRenderObserver;
  39346. /**
  39347. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39348. */
  39349. constructor();
  39350. /**
  39351. * The name of the behavior
  39352. */
  39353. get name(): string;
  39354. /**
  39355. * Initializes the behavior
  39356. */
  39357. init(): void;
  39358. private _getCurrentDistance;
  39359. /**
  39360. * Attaches the scale behavior the passed in mesh
  39361. * @param ownerNode The mesh that will be scaled around once attached
  39362. */
  39363. attach(ownerNode: Mesh): void;
  39364. /**
  39365. * Detaches the behavior from the mesh
  39366. */
  39367. detach(): void;
  39368. }
  39369. }
  39370. declare module BABYLON {
  39371. /**
  39372. * 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
  39373. */
  39374. export class SixDofDragBehavior implements Behavior<Mesh> {
  39375. private static _virtualScene;
  39376. private _ownerNode;
  39377. private _sceneRenderObserver;
  39378. private _scene;
  39379. private _targetPosition;
  39380. private _virtualOriginMesh;
  39381. private _virtualDragMesh;
  39382. private _pointerObserver;
  39383. private _moving;
  39384. private _startingOrientation;
  39385. /**
  39386. * 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)
  39387. */
  39388. private zDragFactor;
  39389. /**
  39390. * If the object should rotate to face the drag origin
  39391. */
  39392. rotateDraggedObject: boolean;
  39393. /**
  39394. * If the behavior is currently in a dragging state
  39395. */
  39396. dragging: boolean;
  39397. /**
  39398. * 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)
  39399. */
  39400. dragDeltaRatio: number;
  39401. /**
  39402. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39403. */
  39404. currentDraggingPointerID: number;
  39405. /**
  39406. * If camera controls should be detached during the drag
  39407. */
  39408. detachCameraControls: boolean;
  39409. /**
  39410. * Fires each time a drag starts
  39411. */
  39412. onDragStartObservable: Observable<{}>;
  39413. /**
  39414. * Fires each time a drag ends (eg. mouse release after drag)
  39415. */
  39416. onDragEndObservable: Observable<{}>;
  39417. /**
  39418. * 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
  39419. */
  39420. constructor();
  39421. /**
  39422. * The name of the behavior
  39423. */
  39424. get name(): string;
  39425. /**
  39426. * Initializes the behavior
  39427. */
  39428. init(): void;
  39429. /**
  39430. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39431. */
  39432. private get _pointerCamera();
  39433. /**
  39434. * Attaches the scale behavior the passed in mesh
  39435. * @param ownerNode The mesh that will be scaled around once attached
  39436. */
  39437. attach(ownerNode: Mesh): void;
  39438. /**
  39439. * Detaches the behavior from the mesh
  39440. */
  39441. detach(): void;
  39442. }
  39443. }
  39444. declare module BABYLON {
  39445. /**
  39446. * Class used to apply inverse kinematics to bones
  39447. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39448. */
  39449. export class BoneIKController {
  39450. private static _tmpVecs;
  39451. private static _tmpQuat;
  39452. private static _tmpMats;
  39453. /**
  39454. * Gets or sets the target mesh
  39455. */
  39456. targetMesh: AbstractMesh;
  39457. /** Gets or sets the mesh used as pole */
  39458. poleTargetMesh: AbstractMesh;
  39459. /**
  39460. * Gets or sets the bone used as pole
  39461. */
  39462. poleTargetBone: Nullable<Bone>;
  39463. /**
  39464. * Gets or sets the target position
  39465. */
  39466. targetPosition: Vector3;
  39467. /**
  39468. * Gets or sets the pole target position
  39469. */
  39470. poleTargetPosition: Vector3;
  39471. /**
  39472. * Gets or sets the pole target local offset
  39473. */
  39474. poleTargetLocalOffset: Vector3;
  39475. /**
  39476. * Gets or sets the pole angle
  39477. */
  39478. poleAngle: number;
  39479. /**
  39480. * Gets or sets the mesh associated with the controller
  39481. */
  39482. mesh: AbstractMesh;
  39483. /**
  39484. * 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)
  39485. */
  39486. slerpAmount: number;
  39487. private _bone1Quat;
  39488. private _bone1Mat;
  39489. private _bone2Ang;
  39490. private _bone1;
  39491. private _bone2;
  39492. private _bone1Length;
  39493. private _bone2Length;
  39494. private _maxAngle;
  39495. private _maxReach;
  39496. private _rightHandedSystem;
  39497. private _bendAxis;
  39498. private _slerping;
  39499. private _adjustRoll;
  39500. /**
  39501. * Gets or sets maximum allowed angle
  39502. */
  39503. get maxAngle(): number;
  39504. set maxAngle(value: number);
  39505. /**
  39506. * Creates a new BoneIKController
  39507. * @param mesh defines the mesh to control
  39508. * @param bone defines the bone to control
  39509. * @param options defines options to set up the controller
  39510. */
  39511. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39512. targetMesh?: AbstractMesh;
  39513. poleTargetMesh?: AbstractMesh;
  39514. poleTargetBone?: Bone;
  39515. poleTargetLocalOffset?: Vector3;
  39516. poleAngle?: number;
  39517. bendAxis?: Vector3;
  39518. maxAngle?: number;
  39519. slerpAmount?: number;
  39520. });
  39521. private _setMaxAngle;
  39522. /**
  39523. * Force the controller to update the bones
  39524. */
  39525. update(): void;
  39526. }
  39527. }
  39528. declare module BABYLON {
  39529. /**
  39530. * Class used to make a bone look toward a point in space
  39531. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39532. */
  39533. export class BoneLookController {
  39534. private static _tmpVecs;
  39535. private static _tmpQuat;
  39536. private static _tmpMats;
  39537. /**
  39538. * The target Vector3 that the bone will look at
  39539. */
  39540. target: Vector3;
  39541. /**
  39542. * The mesh that the bone is attached to
  39543. */
  39544. mesh: AbstractMesh;
  39545. /**
  39546. * The bone that will be looking to the target
  39547. */
  39548. bone: Bone;
  39549. /**
  39550. * The up axis of the coordinate system that is used when the bone is rotated
  39551. */
  39552. upAxis: Vector3;
  39553. /**
  39554. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39555. */
  39556. upAxisSpace: Space;
  39557. /**
  39558. * Used to make an adjustment to the yaw of the bone
  39559. */
  39560. adjustYaw: number;
  39561. /**
  39562. * Used to make an adjustment to the pitch of the bone
  39563. */
  39564. adjustPitch: number;
  39565. /**
  39566. * Used to make an adjustment to the roll of the bone
  39567. */
  39568. adjustRoll: number;
  39569. /**
  39570. * 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)
  39571. */
  39572. slerpAmount: number;
  39573. private _minYaw;
  39574. private _maxYaw;
  39575. private _minPitch;
  39576. private _maxPitch;
  39577. private _minYawSin;
  39578. private _minYawCos;
  39579. private _maxYawSin;
  39580. private _maxYawCos;
  39581. private _midYawConstraint;
  39582. private _minPitchTan;
  39583. private _maxPitchTan;
  39584. private _boneQuat;
  39585. private _slerping;
  39586. private _transformYawPitch;
  39587. private _transformYawPitchInv;
  39588. private _firstFrameSkipped;
  39589. private _yawRange;
  39590. private _fowardAxis;
  39591. /**
  39592. * Gets or sets the minimum yaw angle that the bone can look to
  39593. */
  39594. get minYaw(): number;
  39595. set minYaw(value: number);
  39596. /**
  39597. * Gets or sets the maximum yaw angle that the bone can look to
  39598. */
  39599. get maxYaw(): number;
  39600. set maxYaw(value: number);
  39601. /**
  39602. * Gets or sets the minimum pitch angle that the bone can look to
  39603. */
  39604. get minPitch(): number;
  39605. set minPitch(value: number);
  39606. /**
  39607. * Gets or sets the maximum pitch angle that the bone can look to
  39608. */
  39609. get maxPitch(): number;
  39610. set maxPitch(value: number);
  39611. /**
  39612. * Create a BoneLookController
  39613. * @param mesh the mesh that the bone belongs to
  39614. * @param bone the bone that will be looking to the target
  39615. * @param target the target Vector3 to look at
  39616. * @param options optional settings:
  39617. * * maxYaw: the maximum angle the bone will yaw to
  39618. * * minYaw: the minimum angle the bone will yaw to
  39619. * * maxPitch: the maximum angle the bone will pitch to
  39620. * * minPitch: the minimum angle the bone will yaw to
  39621. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39622. * * upAxis: the up axis of the coordinate system
  39623. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39624. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39625. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39626. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39627. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39628. * * adjustRoll: used to make an adjustment to the roll of the bone
  39629. **/
  39630. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39631. maxYaw?: number;
  39632. minYaw?: number;
  39633. maxPitch?: number;
  39634. minPitch?: number;
  39635. slerpAmount?: number;
  39636. upAxis?: Vector3;
  39637. upAxisSpace?: Space;
  39638. yawAxis?: Vector3;
  39639. pitchAxis?: Vector3;
  39640. adjustYaw?: number;
  39641. adjustPitch?: number;
  39642. adjustRoll?: number;
  39643. });
  39644. /**
  39645. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39646. */
  39647. update(): void;
  39648. private _getAngleDiff;
  39649. private _getAngleBetween;
  39650. private _isAngleBetween;
  39651. }
  39652. }
  39653. declare module BABYLON {
  39654. /**
  39655. * Manage the gamepad inputs to control an arc rotate camera.
  39656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39657. */
  39658. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39659. /**
  39660. * Defines the camera the input is attached to.
  39661. */
  39662. camera: ArcRotateCamera;
  39663. /**
  39664. * Defines the gamepad the input is gathering event from.
  39665. */
  39666. gamepad: Nullable<Gamepad>;
  39667. /**
  39668. * Defines the gamepad rotation sensiblity.
  39669. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39670. */
  39671. gamepadRotationSensibility: number;
  39672. /**
  39673. * Defines the gamepad move sensiblity.
  39674. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39675. */
  39676. gamepadMoveSensibility: number;
  39677. private _yAxisScale;
  39678. /**
  39679. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39680. */
  39681. get invertYAxis(): boolean;
  39682. set invertYAxis(value: boolean);
  39683. private _onGamepadConnectedObserver;
  39684. private _onGamepadDisconnectedObserver;
  39685. /**
  39686. * Attach the input controls to a specific dom element to get the input from.
  39687. * @param element Defines the element the controls should be listened from
  39688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39689. */
  39690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39691. /**
  39692. * Detach the current controls from the specified dom element.
  39693. * @param element Defines the element to stop listening the inputs from
  39694. */
  39695. detachControl(element: Nullable<HTMLElement>): void;
  39696. /**
  39697. * Update the current camera state depending on the inputs that have been used this frame.
  39698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39699. */
  39700. checkInputs(): void;
  39701. /**
  39702. * Gets the class name of the current intput.
  39703. * @returns the class name
  39704. */
  39705. getClassName(): string;
  39706. /**
  39707. * Get the friendly name associated with the input class.
  39708. * @returns the input friendly name
  39709. */
  39710. getSimpleName(): string;
  39711. }
  39712. }
  39713. declare module BABYLON {
  39714. interface ArcRotateCameraInputsManager {
  39715. /**
  39716. * Add orientation input support to the input manager.
  39717. * @returns the current input manager
  39718. */
  39719. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39720. }
  39721. /**
  39722. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39724. */
  39725. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39726. /**
  39727. * Defines the camera the input is attached to.
  39728. */
  39729. camera: ArcRotateCamera;
  39730. /**
  39731. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39732. */
  39733. alphaCorrection: number;
  39734. /**
  39735. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39736. */
  39737. gammaCorrection: number;
  39738. private _alpha;
  39739. private _gamma;
  39740. private _dirty;
  39741. private _deviceOrientationHandler;
  39742. /**
  39743. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39744. */
  39745. constructor();
  39746. /**
  39747. * Attach the input controls to a specific dom element to get the input from.
  39748. * @param element Defines the element the controls should be listened from
  39749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39750. */
  39751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39752. /** @hidden */
  39753. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39754. /**
  39755. * Update the current camera state depending on the inputs that have been used this frame.
  39756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39757. */
  39758. checkInputs(): void;
  39759. /**
  39760. * Detach the current controls from the specified dom element.
  39761. * @param element Defines the element to stop listening the inputs from
  39762. */
  39763. detachControl(element: Nullable<HTMLElement>): void;
  39764. /**
  39765. * Gets the class name of the current intput.
  39766. * @returns the class name
  39767. */
  39768. getClassName(): string;
  39769. /**
  39770. * Get the friendly name associated with the input class.
  39771. * @returns the input friendly name
  39772. */
  39773. getSimpleName(): string;
  39774. }
  39775. }
  39776. declare module BABYLON {
  39777. /**
  39778. * Listen to mouse events to control the camera.
  39779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39780. */
  39781. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39782. /**
  39783. * Defines the camera the input is attached to.
  39784. */
  39785. camera: FlyCamera;
  39786. /**
  39787. * Defines if touch is enabled. (Default is true.)
  39788. */
  39789. touchEnabled: boolean;
  39790. /**
  39791. * Defines the buttons associated with the input to handle camera rotation.
  39792. */
  39793. buttons: number[];
  39794. /**
  39795. * Assign buttons for Yaw control.
  39796. */
  39797. buttonsYaw: number[];
  39798. /**
  39799. * Assign buttons for Pitch control.
  39800. */
  39801. buttonsPitch: number[];
  39802. /**
  39803. * Assign buttons for Roll control.
  39804. */
  39805. buttonsRoll: number[];
  39806. /**
  39807. * Detect if any button is being pressed while mouse is moved.
  39808. * -1 = Mouse locked.
  39809. * 0 = Left button.
  39810. * 1 = Middle Button.
  39811. * 2 = Right Button.
  39812. */
  39813. activeButton: number;
  39814. /**
  39815. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39816. * Higher values reduce its sensitivity.
  39817. */
  39818. angularSensibility: number;
  39819. private _mousemoveCallback;
  39820. private _observer;
  39821. private _rollObserver;
  39822. private previousPosition;
  39823. private noPreventDefault;
  39824. private element;
  39825. /**
  39826. * Listen to mouse events to control the camera.
  39827. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39829. */
  39830. constructor(touchEnabled?: boolean);
  39831. /**
  39832. * Attach the mouse control to the HTML DOM element.
  39833. * @param element Defines the element that listens to the input events.
  39834. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39835. */
  39836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39837. /**
  39838. * Detach the current controls from the specified dom element.
  39839. * @param element Defines the element to stop listening the inputs from
  39840. */
  39841. detachControl(element: Nullable<HTMLElement>): void;
  39842. /**
  39843. * Gets the class name of the current input.
  39844. * @returns the class name.
  39845. */
  39846. getClassName(): string;
  39847. /**
  39848. * Get the friendly name associated with the input class.
  39849. * @returns the input's friendly name.
  39850. */
  39851. getSimpleName(): string;
  39852. private _pointerInput;
  39853. private _onMouseMove;
  39854. /**
  39855. * Rotate camera by mouse offset.
  39856. */
  39857. private rotateCamera;
  39858. }
  39859. }
  39860. declare module BABYLON {
  39861. /**
  39862. * Default Inputs manager for the FlyCamera.
  39863. * It groups all the default supported inputs for ease of use.
  39864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39865. */
  39866. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39867. /**
  39868. * Instantiates a new FlyCameraInputsManager.
  39869. * @param camera Defines the camera the inputs belong to.
  39870. */
  39871. constructor(camera: FlyCamera);
  39872. /**
  39873. * Add keyboard input support to the input manager.
  39874. * @returns the new FlyCameraKeyboardMoveInput().
  39875. */
  39876. addKeyboard(): FlyCameraInputsManager;
  39877. /**
  39878. * Add mouse input support to the input manager.
  39879. * @param touchEnabled Enable touch screen support.
  39880. * @returns the new FlyCameraMouseInput().
  39881. */
  39882. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39883. }
  39884. }
  39885. declare module BABYLON {
  39886. /**
  39887. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39888. * such as in a 3D Space Shooter or a Flight Simulator.
  39889. */
  39890. export class FlyCamera extends TargetCamera {
  39891. /**
  39892. * Define the collision ellipsoid of the camera.
  39893. * This is helpful for simulating a camera body, like a player's body.
  39894. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39895. */
  39896. ellipsoid: Vector3;
  39897. /**
  39898. * Define an offset for the position of the ellipsoid around the camera.
  39899. * This can be helpful if the camera is attached away from the player's body center,
  39900. * such as at its head.
  39901. */
  39902. ellipsoidOffset: Vector3;
  39903. /**
  39904. * Enable or disable collisions of the camera with the rest of the scene objects.
  39905. */
  39906. checkCollisions: boolean;
  39907. /**
  39908. * Enable or disable gravity on the camera.
  39909. */
  39910. applyGravity: boolean;
  39911. /**
  39912. * Define the current direction the camera is moving to.
  39913. */
  39914. cameraDirection: Vector3;
  39915. /**
  39916. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39917. * This overrides and empties cameraRotation.
  39918. */
  39919. rotationQuaternion: Quaternion;
  39920. /**
  39921. * Track Roll to maintain the wanted Rolling when looking around.
  39922. */
  39923. _trackRoll: number;
  39924. /**
  39925. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39926. */
  39927. rollCorrect: number;
  39928. /**
  39929. * Mimic a banked turn, Rolling the camera when Yawing.
  39930. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39931. */
  39932. bankedTurn: boolean;
  39933. /**
  39934. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39935. */
  39936. bankedTurnLimit: number;
  39937. /**
  39938. * Value of 0 disables the banked Roll.
  39939. * Value of 1 is equal to the Yaw angle in radians.
  39940. */
  39941. bankedTurnMultiplier: number;
  39942. /**
  39943. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39944. */
  39945. inputs: FlyCameraInputsManager;
  39946. /**
  39947. * Gets the input sensibility for mouse input.
  39948. * Higher values reduce sensitivity.
  39949. */
  39950. get angularSensibility(): number;
  39951. /**
  39952. * Sets the input sensibility for a mouse input.
  39953. * Higher values reduce sensitivity.
  39954. */
  39955. set angularSensibility(value: number);
  39956. /**
  39957. * Get the keys for camera movement forward.
  39958. */
  39959. get keysForward(): number[];
  39960. /**
  39961. * Set the keys for camera movement forward.
  39962. */
  39963. set keysForward(value: number[]);
  39964. /**
  39965. * Get the keys for camera movement backward.
  39966. */
  39967. get keysBackward(): number[];
  39968. set keysBackward(value: number[]);
  39969. /**
  39970. * Get the keys for camera movement up.
  39971. */
  39972. get keysUp(): number[];
  39973. /**
  39974. * Set the keys for camera movement up.
  39975. */
  39976. set keysUp(value: number[]);
  39977. /**
  39978. * Get the keys for camera movement down.
  39979. */
  39980. get keysDown(): number[];
  39981. /**
  39982. * Set the keys for camera movement down.
  39983. */
  39984. set keysDown(value: number[]);
  39985. /**
  39986. * Get the keys for camera movement left.
  39987. */
  39988. get keysLeft(): number[];
  39989. /**
  39990. * Set the keys for camera movement left.
  39991. */
  39992. set keysLeft(value: number[]);
  39993. /**
  39994. * Set the keys for camera movement right.
  39995. */
  39996. get keysRight(): number[];
  39997. /**
  39998. * Set the keys for camera movement right.
  39999. */
  40000. set keysRight(value: number[]);
  40001. /**
  40002. * Event raised when the camera collides with a mesh in the scene.
  40003. */
  40004. onCollide: (collidedMesh: AbstractMesh) => void;
  40005. private _collider;
  40006. private _needMoveForGravity;
  40007. private _oldPosition;
  40008. private _diffPosition;
  40009. private _newPosition;
  40010. /** @hidden */
  40011. _localDirection: Vector3;
  40012. /** @hidden */
  40013. _transformedDirection: Vector3;
  40014. /**
  40015. * Instantiates a FlyCamera.
  40016. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40017. * such as in a 3D Space Shooter or a Flight Simulator.
  40018. * @param name Define the name of the camera in the scene.
  40019. * @param position Define the starting position of the camera in the scene.
  40020. * @param scene Define the scene the camera belongs to.
  40021. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40022. */
  40023. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40024. /**
  40025. * Attach a control to the HTML DOM element.
  40026. * @param element Defines the element that listens to the input events.
  40027. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40028. */
  40029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40030. /**
  40031. * Detach a control from the HTML DOM element.
  40032. * The camera will stop reacting to that input.
  40033. * @param element Defines the element that listens to the input events.
  40034. */
  40035. detachControl(element: HTMLElement): void;
  40036. private _collisionMask;
  40037. /**
  40038. * Get the mask that the camera ignores in collision events.
  40039. */
  40040. get collisionMask(): number;
  40041. /**
  40042. * Set the mask that the camera ignores in collision events.
  40043. */
  40044. set collisionMask(mask: number);
  40045. /** @hidden */
  40046. _collideWithWorld(displacement: Vector3): void;
  40047. /** @hidden */
  40048. private _onCollisionPositionChange;
  40049. /** @hidden */
  40050. _checkInputs(): void;
  40051. /** @hidden */
  40052. _decideIfNeedsToMove(): boolean;
  40053. /** @hidden */
  40054. _updatePosition(): void;
  40055. /**
  40056. * Restore the Roll to its target value at the rate specified.
  40057. * @param rate - Higher means slower restoring.
  40058. * @hidden
  40059. */
  40060. restoreRoll(rate: number): void;
  40061. /**
  40062. * Destroy the camera and release the current resources held by it.
  40063. */
  40064. dispose(): void;
  40065. /**
  40066. * Get the current object class name.
  40067. * @returns the class name.
  40068. */
  40069. getClassName(): string;
  40070. }
  40071. }
  40072. declare module BABYLON {
  40073. /**
  40074. * Listen to keyboard events to control the camera.
  40075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40076. */
  40077. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40078. /**
  40079. * Defines the camera the input is attached to.
  40080. */
  40081. camera: FlyCamera;
  40082. /**
  40083. * The list of keyboard keys used to control the forward move of the camera.
  40084. */
  40085. keysForward: number[];
  40086. /**
  40087. * The list of keyboard keys used to control the backward move of the camera.
  40088. */
  40089. keysBackward: number[];
  40090. /**
  40091. * The list of keyboard keys used to control the forward move of the camera.
  40092. */
  40093. keysUp: number[];
  40094. /**
  40095. * The list of keyboard keys used to control the backward move of the camera.
  40096. */
  40097. keysDown: number[];
  40098. /**
  40099. * The list of keyboard keys used to control the right strafe move of the camera.
  40100. */
  40101. keysRight: number[];
  40102. /**
  40103. * The list of keyboard keys used to control the left strafe move of the camera.
  40104. */
  40105. keysLeft: number[];
  40106. private _keys;
  40107. private _onCanvasBlurObserver;
  40108. private _onKeyboardObserver;
  40109. private _engine;
  40110. private _scene;
  40111. /**
  40112. * Attach the input controls to a specific dom element to get the input from.
  40113. * @param element Defines the element the controls should be listened from
  40114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40115. */
  40116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40117. /**
  40118. * Detach the current controls from the specified dom element.
  40119. * @param element Defines the element to stop listening the inputs from
  40120. */
  40121. detachControl(element: Nullable<HTMLElement>): void;
  40122. /**
  40123. * Gets the class name of the current intput.
  40124. * @returns the class name
  40125. */
  40126. getClassName(): string;
  40127. /** @hidden */
  40128. _onLostFocus(e: FocusEvent): void;
  40129. /**
  40130. * Get the friendly name associated with the input class.
  40131. * @returns the input friendly name
  40132. */
  40133. getSimpleName(): string;
  40134. /**
  40135. * Update the current camera state depending on the inputs that have been used this frame.
  40136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40137. */
  40138. checkInputs(): void;
  40139. }
  40140. }
  40141. declare module BABYLON {
  40142. /**
  40143. * Manage the mouse wheel inputs to control a follow camera.
  40144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40145. */
  40146. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40147. /**
  40148. * Defines the camera the input is attached to.
  40149. */
  40150. camera: FollowCamera;
  40151. /**
  40152. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40153. */
  40154. axisControlRadius: boolean;
  40155. /**
  40156. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40157. */
  40158. axisControlHeight: boolean;
  40159. /**
  40160. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40161. */
  40162. axisControlRotation: boolean;
  40163. /**
  40164. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40165. * relation to mouseWheel events.
  40166. */
  40167. wheelPrecision: number;
  40168. /**
  40169. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40170. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40171. */
  40172. wheelDeltaPercentage: number;
  40173. private _wheel;
  40174. private _observer;
  40175. /**
  40176. * Attach the input controls to a specific dom element to get the input from.
  40177. * @param element Defines the element the controls should be listened from
  40178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40179. */
  40180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40181. /**
  40182. * Detach the current controls from the specified dom element.
  40183. * @param element Defines the element to stop listening the inputs from
  40184. */
  40185. detachControl(element: Nullable<HTMLElement>): void;
  40186. /**
  40187. * Gets the class name of the current intput.
  40188. * @returns the class name
  40189. */
  40190. getClassName(): string;
  40191. /**
  40192. * Get the friendly name associated with the input class.
  40193. * @returns the input friendly name
  40194. */
  40195. getSimpleName(): string;
  40196. }
  40197. }
  40198. declare module BABYLON {
  40199. /**
  40200. * Manage the pointers inputs to control an follow camera.
  40201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40202. */
  40203. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40204. /**
  40205. * Defines the camera the input is attached to.
  40206. */
  40207. camera: FollowCamera;
  40208. /**
  40209. * Gets the class name of the current input.
  40210. * @returns the class name
  40211. */
  40212. getClassName(): string;
  40213. /**
  40214. * Defines the pointer angular sensibility along the X axis or how fast is
  40215. * the camera rotating.
  40216. * A negative number will reverse the axis direction.
  40217. */
  40218. angularSensibilityX: number;
  40219. /**
  40220. * Defines the pointer angular sensibility along the Y axis or how fast is
  40221. * the camera rotating.
  40222. * A negative number will reverse the axis direction.
  40223. */
  40224. angularSensibilityY: number;
  40225. /**
  40226. * Defines the pointer pinch precision or how fast is the camera zooming.
  40227. * A negative number will reverse the axis direction.
  40228. */
  40229. pinchPrecision: number;
  40230. /**
  40231. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40232. * from 0.
  40233. * It defines the percentage of current camera.radius to use as delta when
  40234. * pinch zoom is used.
  40235. */
  40236. pinchDeltaPercentage: number;
  40237. /**
  40238. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40239. */
  40240. axisXControlRadius: boolean;
  40241. /**
  40242. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40243. */
  40244. axisXControlHeight: boolean;
  40245. /**
  40246. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40247. */
  40248. axisXControlRotation: boolean;
  40249. /**
  40250. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40251. */
  40252. axisYControlRadius: boolean;
  40253. /**
  40254. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40255. */
  40256. axisYControlHeight: boolean;
  40257. /**
  40258. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40259. */
  40260. axisYControlRotation: boolean;
  40261. /**
  40262. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40263. */
  40264. axisPinchControlRadius: boolean;
  40265. /**
  40266. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40267. */
  40268. axisPinchControlHeight: boolean;
  40269. /**
  40270. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40271. */
  40272. axisPinchControlRotation: boolean;
  40273. /**
  40274. * Log error messages if basic misconfiguration has occurred.
  40275. */
  40276. warningEnable: boolean;
  40277. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40278. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40279. private _warningCounter;
  40280. private _warning;
  40281. }
  40282. }
  40283. declare module BABYLON {
  40284. /**
  40285. * Default Inputs manager for the FollowCamera.
  40286. * It groups all the default supported inputs for ease of use.
  40287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40288. */
  40289. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40290. /**
  40291. * Instantiates a new FollowCameraInputsManager.
  40292. * @param camera Defines the camera the inputs belong to
  40293. */
  40294. constructor(camera: FollowCamera);
  40295. /**
  40296. * Add keyboard input support to the input manager.
  40297. * @returns the current input manager
  40298. */
  40299. addKeyboard(): FollowCameraInputsManager;
  40300. /**
  40301. * Add mouse wheel input support to the input manager.
  40302. * @returns the current input manager
  40303. */
  40304. addMouseWheel(): FollowCameraInputsManager;
  40305. /**
  40306. * Add pointers input support to the input manager.
  40307. * @returns the current input manager
  40308. */
  40309. addPointers(): FollowCameraInputsManager;
  40310. /**
  40311. * Add orientation input support to the input manager.
  40312. * @returns the current input manager
  40313. */
  40314. addVRDeviceOrientation(): FollowCameraInputsManager;
  40315. }
  40316. }
  40317. declare module BABYLON {
  40318. /**
  40319. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40320. * an arc rotate version arcFollowCamera are available.
  40321. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40322. */
  40323. export class FollowCamera extends TargetCamera {
  40324. /**
  40325. * Distance the follow camera should follow an object at
  40326. */
  40327. radius: number;
  40328. /**
  40329. * Minimum allowed distance of the camera to the axis of rotation
  40330. * (The camera can not get closer).
  40331. * This can help limiting how the Camera is able to move in the scene.
  40332. */
  40333. lowerRadiusLimit: Nullable<number>;
  40334. /**
  40335. * Maximum allowed distance of the camera to the axis of rotation
  40336. * (The camera can not get further).
  40337. * This can help limiting how the Camera is able to move in the scene.
  40338. */
  40339. upperRadiusLimit: Nullable<number>;
  40340. /**
  40341. * Define a rotation offset between the camera and the object it follows
  40342. */
  40343. rotationOffset: number;
  40344. /**
  40345. * Minimum allowed angle to camera position relative to target object.
  40346. * This can help limiting how the Camera is able to move in the scene.
  40347. */
  40348. lowerRotationOffsetLimit: Nullable<number>;
  40349. /**
  40350. * Maximum allowed angle to camera position relative to target object.
  40351. * This can help limiting how the Camera is able to move in the scene.
  40352. */
  40353. upperRotationOffsetLimit: Nullable<number>;
  40354. /**
  40355. * Define a height offset between the camera and the object it follows.
  40356. * It can help following an object from the top (like a car chaing a plane)
  40357. */
  40358. heightOffset: number;
  40359. /**
  40360. * Minimum allowed height of camera position relative to target object.
  40361. * This can help limiting how the Camera is able to move in the scene.
  40362. */
  40363. lowerHeightOffsetLimit: Nullable<number>;
  40364. /**
  40365. * Maximum allowed height of camera position relative to target object.
  40366. * This can help limiting how the Camera is able to move in the scene.
  40367. */
  40368. upperHeightOffsetLimit: Nullable<number>;
  40369. /**
  40370. * Define how fast the camera can accelerate to follow it s target.
  40371. */
  40372. cameraAcceleration: number;
  40373. /**
  40374. * Define the speed limit of the camera following an object.
  40375. */
  40376. maxCameraSpeed: number;
  40377. /**
  40378. * Define the target of the camera.
  40379. */
  40380. lockedTarget: Nullable<AbstractMesh>;
  40381. /**
  40382. * Defines the input associated with the camera.
  40383. */
  40384. inputs: FollowCameraInputsManager;
  40385. /**
  40386. * Instantiates the follow camera.
  40387. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40388. * @param name Define the name of the camera in the scene
  40389. * @param position Define the position of the camera
  40390. * @param scene Define the scene the camera belong to
  40391. * @param lockedTarget Define the target of the camera
  40392. */
  40393. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40394. private _follow;
  40395. /**
  40396. * Attached controls to the current camera.
  40397. * @param element Defines the element the controls should be listened from
  40398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40399. */
  40400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40401. /**
  40402. * Detach the current controls from the camera.
  40403. * The camera will stop reacting to inputs.
  40404. * @param element Defines the element to stop listening the inputs from
  40405. */
  40406. detachControl(element: HTMLElement): void;
  40407. /** @hidden */
  40408. _checkInputs(): void;
  40409. private _checkLimits;
  40410. /**
  40411. * Gets the camera class name.
  40412. * @returns the class name
  40413. */
  40414. getClassName(): string;
  40415. }
  40416. /**
  40417. * Arc Rotate version of the follow camera.
  40418. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40419. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40420. */
  40421. export class ArcFollowCamera extends TargetCamera {
  40422. /** The longitudinal angle of the camera */
  40423. alpha: number;
  40424. /** The latitudinal angle of the camera */
  40425. beta: number;
  40426. /** The radius of the camera from its target */
  40427. radius: number;
  40428. /** Define the camera target (the messh it should follow) */
  40429. target: Nullable<AbstractMesh>;
  40430. private _cartesianCoordinates;
  40431. /**
  40432. * Instantiates a new ArcFollowCamera
  40433. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40434. * @param name Define the name of the camera
  40435. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40436. * @param beta Define the rotation angle of the camera around the elevation axis
  40437. * @param radius Define the radius of the camera from its target point
  40438. * @param target Define the target of the camera
  40439. * @param scene Define the scene the camera belongs to
  40440. */
  40441. constructor(name: string,
  40442. /** The longitudinal angle of the camera */
  40443. alpha: number,
  40444. /** The latitudinal angle of the camera */
  40445. beta: number,
  40446. /** The radius of the camera from its target */
  40447. radius: number,
  40448. /** Define the camera target (the messh it should follow) */
  40449. target: Nullable<AbstractMesh>, scene: Scene);
  40450. private _follow;
  40451. /** @hidden */
  40452. _checkInputs(): void;
  40453. /**
  40454. * Returns the class name of the object.
  40455. * It is mostly used internally for serialization purposes.
  40456. */
  40457. getClassName(): string;
  40458. }
  40459. }
  40460. declare module BABYLON {
  40461. /**
  40462. * Manage the keyboard inputs to control the movement of a follow camera.
  40463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40464. */
  40465. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40466. /**
  40467. * Defines the camera the input is attached to.
  40468. */
  40469. camera: FollowCamera;
  40470. /**
  40471. * Defines the list of key codes associated with the up action (increase heightOffset)
  40472. */
  40473. keysHeightOffsetIncr: number[];
  40474. /**
  40475. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40476. */
  40477. keysHeightOffsetDecr: number[];
  40478. /**
  40479. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40480. */
  40481. keysHeightOffsetModifierAlt: boolean;
  40482. /**
  40483. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40484. */
  40485. keysHeightOffsetModifierCtrl: boolean;
  40486. /**
  40487. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40488. */
  40489. keysHeightOffsetModifierShift: boolean;
  40490. /**
  40491. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40492. */
  40493. keysRotationOffsetIncr: number[];
  40494. /**
  40495. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40496. */
  40497. keysRotationOffsetDecr: number[];
  40498. /**
  40499. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40500. */
  40501. keysRotationOffsetModifierAlt: boolean;
  40502. /**
  40503. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40504. */
  40505. keysRotationOffsetModifierCtrl: boolean;
  40506. /**
  40507. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40508. */
  40509. keysRotationOffsetModifierShift: boolean;
  40510. /**
  40511. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40512. */
  40513. keysRadiusIncr: number[];
  40514. /**
  40515. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40516. */
  40517. keysRadiusDecr: number[];
  40518. /**
  40519. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40520. */
  40521. keysRadiusModifierAlt: boolean;
  40522. /**
  40523. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40524. */
  40525. keysRadiusModifierCtrl: boolean;
  40526. /**
  40527. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40528. */
  40529. keysRadiusModifierShift: boolean;
  40530. /**
  40531. * Defines the rate of change of heightOffset.
  40532. */
  40533. heightSensibility: number;
  40534. /**
  40535. * Defines the rate of change of rotationOffset.
  40536. */
  40537. rotationSensibility: number;
  40538. /**
  40539. * Defines the rate of change of radius.
  40540. */
  40541. radiusSensibility: number;
  40542. private _keys;
  40543. private _ctrlPressed;
  40544. private _altPressed;
  40545. private _shiftPressed;
  40546. private _onCanvasBlurObserver;
  40547. private _onKeyboardObserver;
  40548. private _engine;
  40549. private _scene;
  40550. /**
  40551. * Attach the input controls to a specific dom element to get the input from.
  40552. * @param element Defines the element the controls should be listened from
  40553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40554. */
  40555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40556. /**
  40557. * Detach the current controls from the specified dom element.
  40558. * @param element Defines the element to stop listening the inputs from
  40559. */
  40560. detachControl(element: Nullable<HTMLElement>): void;
  40561. /**
  40562. * Update the current camera state depending on the inputs that have been used this frame.
  40563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40564. */
  40565. checkInputs(): void;
  40566. /**
  40567. * Gets the class name of the current input.
  40568. * @returns the class name
  40569. */
  40570. getClassName(): string;
  40571. /**
  40572. * Get the friendly name associated with the input class.
  40573. * @returns the input friendly name
  40574. */
  40575. getSimpleName(): string;
  40576. /**
  40577. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40578. * allow modification of the heightOffset value.
  40579. */
  40580. private _modifierHeightOffset;
  40581. /**
  40582. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40583. * allow modification of the rotationOffset value.
  40584. */
  40585. private _modifierRotationOffset;
  40586. /**
  40587. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40588. * allow modification of the radius value.
  40589. */
  40590. private _modifierRadius;
  40591. }
  40592. }
  40593. declare module BABYLON {
  40594. interface FreeCameraInputsManager {
  40595. /**
  40596. * @hidden
  40597. */
  40598. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40599. /**
  40600. * Add orientation input support to the input manager.
  40601. * @returns the current input manager
  40602. */
  40603. addDeviceOrientation(): FreeCameraInputsManager;
  40604. }
  40605. /**
  40606. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40607. * Screen rotation is taken into account.
  40608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40609. */
  40610. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40611. private _camera;
  40612. private _screenOrientationAngle;
  40613. private _constantTranform;
  40614. private _screenQuaternion;
  40615. private _alpha;
  40616. private _beta;
  40617. private _gamma;
  40618. /**
  40619. * Can be used to detect if a device orientation sensor is available on a device
  40620. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40621. * @returns a promise that will resolve on orientation change
  40622. */
  40623. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40624. /**
  40625. * @hidden
  40626. */
  40627. _onDeviceOrientationChangedObservable: Observable<void>;
  40628. /**
  40629. * Instantiates a new input
  40630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40631. */
  40632. constructor();
  40633. /**
  40634. * Define the camera controlled by the input.
  40635. */
  40636. get camera(): FreeCamera;
  40637. set camera(camera: FreeCamera);
  40638. /**
  40639. * Attach the input controls to a specific dom element to get the input from.
  40640. * @param element Defines the element the controls should be listened from
  40641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40642. */
  40643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40644. private _orientationChanged;
  40645. private _deviceOrientation;
  40646. /**
  40647. * Detach the current controls from the specified dom element.
  40648. * @param element Defines the element to stop listening the inputs from
  40649. */
  40650. detachControl(element: Nullable<HTMLElement>): void;
  40651. /**
  40652. * Update the current camera state depending on the inputs that have been used this frame.
  40653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40654. */
  40655. checkInputs(): void;
  40656. /**
  40657. * Gets the class name of the current intput.
  40658. * @returns the class name
  40659. */
  40660. getClassName(): string;
  40661. /**
  40662. * Get the friendly name associated with the input class.
  40663. * @returns the input friendly name
  40664. */
  40665. getSimpleName(): string;
  40666. }
  40667. }
  40668. declare module BABYLON {
  40669. /**
  40670. * Manage the gamepad inputs to control a free camera.
  40671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40672. */
  40673. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40674. /**
  40675. * Define the camera the input is attached to.
  40676. */
  40677. camera: FreeCamera;
  40678. /**
  40679. * Define the Gamepad controlling the input
  40680. */
  40681. gamepad: Nullable<Gamepad>;
  40682. /**
  40683. * Defines the gamepad rotation sensiblity.
  40684. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40685. */
  40686. gamepadAngularSensibility: number;
  40687. /**
  40688. * Defines the gamepad move sensiblity.
  40689. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40690. */
  40691. gamepadMoveSensibility: number;
  40692. private _yAxisScale;
  40693. /**
  40694. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40695. */
  40696. get invertYAxis(): boolean;
  40697. set invertYAxis(value: boolean);
  40698. private _onGamepadConnectedObserver;
  40699. private _onGamepadDisconnectedObserver;
  40700. private _cameraTransform;
  40701. private _deltaTransform;
  40702. private _vector3;
  40703. private _vector2;
  40704. /**
  40705. * Attach the input controls to a specific dom element to get the input from.
  40706. * @param element Defines the element the controls should be listened from
  40707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40708. */
  40709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40710. /**
  40711. * Detach the current controls from the specified dom element.
  40712. * @param element Defines the element to stop listening the inputs from
  40713. */
  40714. detachControl(element: Nullable<HTMLElement>): void;
  40715. /**
  40716. * Update the current camera state depending on the inputs that have been used this frame.
  40717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40718. */
  40719. checkInputs(): void;
  40720. /**
  40721. * Gets the class name of the current intput.
  40722. * @returns the class name
  40723. */
  40724. getClassName(): string;
  40725. /**
  40726. * Get the friendly name associated with the input class.
  40727. * @returns the input friendly name
  40728. */
  40729. getSimpleName(): string;
  40730. }
  40731. }
  40732. declare module BABYLON {
  40733. /**
  40734. * Defines the potential axis of a Joystick
  40735. */
  40736. export enum JoystickAxis {
  40737. /** X axis */
  40738. X = 0,
  40739. /** Y axis */
  40740. Y = 1,
  40741. /** Z axis */
  40742. Z = 2
  40743. }
  40744. /**
  40745. * Class used to define virtual joystick (used in touch mode)
  40746. */
  40747. export class VirtualJoystick {
  40748. /**
  40749. * Gets or sets a boolean indicating that left and right values must be inverted
  40750. */
  40751. reverseLeftRight: boolean;
  40752. /**
  40753. * Gets or sets a boolean indicating that up and down values must be inverted
  40754. */
  40755. reverseUpDown: boolean;
  40756. /**
  40757. * Gets the offset value for the position (ie. the change of the position value)
  40758. */
  40759. deltaPosition: Vector3;
  40760. /**
  40761. * Gets a boolean indicating if the virtual joystick was pressed
  40762. */
  40763. pressed: boolean;
  40764. /**
  40765. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40766. */
  40767. static Canvas: Nullable<HTMLCanvasElement>;
  40768. private static _globalJoystickIndex;
  40769. private static vjCanvasContext;
  40770. private static vjCanvasWidth;
  40771. private static vjCanvasHeight;
  40772. private static halfWidth;
  40773. private _action;
  40774. private _axisTargetedByLeftAndRight;
  40775. private _axisTargetedByUpAndDown;
  40776. private _joystickSensibility;
  40777. private _inversedSensibility;
  40778. private _joystickPointerID;
  40779. private _joystickColor;
  40780. private _joystickPointerPos;
  40781. private _joystickPreviousPointerPos;
  40782. private _joystickPointerStartPos;
  40783. private _deltaJoystickVector;
  40784. private _leftJoystick;
  40785. private _touches;
  40786. private _onPointerDownHandlerRef;
  40787. private _onPointerMoveHandlerRef;
  40788. private _onPointerUpHandlerRef;
  40789. private _onResize;
  40790. /**
  40791. * Creates a new virtual joystick
  40792. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40793. */
  40794. constructor(leftJoystick?: boolean);
  40795. /**
  40796. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40797. * @param newJoystickSensibility defines the new sensibility
  40798. */
  40799. setJoystickSensibility(newJoystickSensibility: number): void;
  40800. private _onPointerDown;
  40801. private _onPointerMove;
  40802. private _onPointerUp;
  40803. /**
  40804. * Change the color of the virtual joystick
  40805. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40806. */
  40807. setJoystickColor(newColor: string): void;
  40808. /**
  40809. * Defines a callback to call when the joystick is touched
  40810. * @param action defines the callback
  40811. */
  40812. setActionOnTouch(action: () => any): void;
  40813. /**
  40814. * Defines which axis you'd like to control for left & right
  40815. * @param axis defines the axis to use
  40816. */
  40817. setAxisForLeftRight(axis: JoystickAxis): void;
  40818. /**
  40819. * Defines which axis you'd like to control for up & down
  40820. * @param axis defines the axis to use
  40821. */
  40822. setAxisForUpDown(axis: JoystickAxis): void;
  40823. private _drawVirtualJoystick;
  40824. /**
  40825. * Release internal HTML canvas
  40826. */
  40827. releaseCanvas(): void;
  40828. }
  40829. }
  40830. declare module BABYLON {
  40831. interface FreeCameraInputsManager {
  40832. /**
  40833. * Add virtual joystick input support to the input manager.
  40834. * @returns the current input manager
  40835. */
  40836. addVirtualJoystick(): FreeCameraInputsManager;
  40837. }
  40838. /**
  40839. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40841. */
  40842. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40843. /**
  40844. * Defines the camera the input is attached to.
  40845. */
  40846. camera: FreeCamera;
  40847. private _leftjoystick;
  40848. private _rightjoystick;
  40849. /**
  40850. * Gets the left stick of the virtual joystick.
  40851. * @returns The virtual Joystick
  40852. */
  40853. getLeftJoystick(): VirtualJoystick;
  40854. /**
  40855. * Gets the right stick of the virtual joystick.
  40856. * @returns The virtual Joystick
  40857. */
  40858. getRightJoystick(): VirtualJoystick;
  40859. /**
  40860. * Update the current camera state depending on the inputs that have been used this frame.
  40861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40862. */
  40863. checkInputs(): void;
  40864. /**
  40865. * Attach the input controls to a specific dom element to get the input from.
  40866. * @param element Defines the element the controls should be listened from
  40867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40868. */
  40869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40870. /**
  40871. * Detach the current controls from the specified dom element.
  40872. * @param element Defines the element to stop listening the inputs from
  40873. */
  40874. detachControl(element: Nullable<HTMLElement>): void;
  40875. /**
  40876. * Gets the class name of the current intput.
  40877. * @returns the class name
  40878. */
  40879. getClassName(): string;
  40880. /**
  40881. * Get the friendly name associated with the input class.
  40882. * @returns the input friendly name
  40883. */
  40884. getSimpleName(): string;
  40885. }
  40886. }
  40887. declare module BABYLON {
  40888. /**
  40889. * This represents a FPS type of camera controlled by touch.
  40890. * This is like a universal camera minus the Gamepad controls.
  40891. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40892. */
  40893. export class TouchCamera extends FreeCamera {
  40894. /**
  40895. * Defines the touch sensibility for rotation.
  40896. * The higher the faster.
  40897. */
  40898. get touchAngularSensibility(): number;
  40899. set touchAngularSensibility(value: number);
  40900. /**
  40901. * Defines the touch sensibility for move.
  40902. * The higher the faster.
  40903. */
  40904. get touchMoveSensibility(): number;
  40905. set touchMoveSensibility(value: number);
  40906. /**
  40907. * Instantiates a new touch camera.
  40908. * This represents a FPS type of camera controlled by touch.
  40909. * This is like a universal camera minus the Gamepad controls.
  40910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40911. * @param name Define the name of the camera in the scene
  40912. * @param position Define the start position of the camera in the scene
  40913. * @param scene Define the scene the camera belongs to
  40914. */
  40915. constructor(name: string, position: Vector3, scene: Scene);
  40916. /**
  40917. * Gets the current object class name.
  40918. * @return the class name
  40919. */
  40920. getClassName(): string;
  40921. /** @hidden */
  40922. _setupInputs(): void;
  40923. }
  40924. }
  40925. declare module BABYLON {
  40926. /**
  40927. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40928. * being tilted forward or back and left or right.
  40929. */
  40930. export class DeviceOrientationCamera extends FreeCamera {
  40931. private _initialQuaternion;
  40932. private _quaternionCache;
  40933. private _tmpDragQuaternion;
  40934. private _disablePointerInputWhenUsingDeviceOrientation;
  40935. /**
  40936. * Creates a new device orientation camera
  40937. * @param name The name of the camera
  40938. * @param position The start position camera
  40939. * @param scene The scene the camera belongs to
  40940. */
  40941. constructor(name: string, position: Vector3, scene: Scene);
  40942. /**
  40943. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40944. */
  40945. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40946. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40947. private _dragFactor;
  40948. /**
  40949. * Enabled turning on the y axis when the orientation sensor is active
  40950. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40951. */
  40952. enableHorizontalDragging(dragFactor?: number): void;
  40953. /**
  40954. * Gets the current instance class name ("DeviceOrientationCamera").
  40955. * This helps avoiding instanceof at run time.
  40956. * @returns the class name
  40957. */
  40958. getClassName(): string;
  40959. /**
  40960. * @hidden
  40961. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40962. */
  40963. _checkInputs(): void;
  40964. /**
  40965. * Reset the camera to its default orientation on the specified axis only.
  40966. * @param axis The axis to reset
  40967. */
  40968. resetToCurrentRotation(axis?: Axis): void;
  40969. }
  40970. }
  40971. declare module BABYLON {
  40972. /**
  40973. * Defines supported buttons for XBox360 compatible gamepads
  40974. */
  40975. export enum Xbox360Button {
  40976. /** A */
  40977. A = 0,
  40978. /** B */
  40979. B = 1,
  40980. /** X */
  40981. X = 2,
  40982. /** Y */
  40983. Y = 3,
  40984. /** Left button */
  40985. LB = 4,
  40986. /** Right button */
  40987. RB = 5,
  40988. /** Back */
  40989. Back = 8,
  40990. /** Start */
  40991. Start = 9,
  40992. /** Left stick */
  40993. LeftStick = 10,
  40994. /** Right stick */
  40995. RightStick = 11
  40996. }
  40997. /** Defines values for XBox360 DPad */
  40998. export enum Xbox360Dpad {
  40999. /** Up */
  41000. Up = 12,
  41001. /** Down */
  41002. Down = 13,
  41003. /** Left */
  41004. Left = 14,
  41005. /** Right */
  41006. Right = 15
  41007. }
  41008. /**
  41009. * Defines a XBox360 gamepad
  41010. */
  41011. export class Xbox360Pad extends Gamepad {
  41012. private _leftTrigger;
  41013. private _rightTrigger;
  41014. private _onlefttriggerchanged;
  41015. private _onrighttriggerchanged;
  41016. private _onbuttondown;
  41017. private _onbuttonup;
  41018. private _ondpaddown;
  41019. private _ondpadup;
  41020. /** Observable raised when a button is pressed */
  41021. onButtonDownObservable: Observable<Xbox360Button>;
  41022. /** Observable raised when a button is released */
  41023. onButtonUpObservable: Observable<Xbox360Button>;
  41024. /** Observable raised when a pad is pressed */
  41025. onPadDownObservable: Observable<Xbox360Dpad>;
  41026. /** Observable raised when a pad is released */
  41027. onPadUpObservable: Observable<Xbox360Dpad>;
  41028. private _buttonA;
  41029. private _buttonB;
  41030. private _buttonX;
  41031. private _buttonY;
  41032. private _buttonBack;
  41033. private _buttonStart;
  41034. private _buttonLB;
  41035. private _buttonRB;
  41036. private _buttonLeftStick;
  41037. private _buttonRightStick;
  41038. private _dPadUp;
  41039. private _dPadDown;
  41040. private _dPadLeft;
  41041. private _dPadRight;
  41042. private _isXboxOnePad;
  41043. /**
  41044. * Creates a new XBox360 gamepad object
  41045. * @param id defines the id of this gamepad
  41046. * @param index defines its index
  41047. * @param gamepad defines the internal HTML gamepad object
  41048. * @param xboxOne defines if it is a XBox One gamepad
  41049. */
  41050. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41051. /**
  41052. * Defines the callback to call when left trigger is pressed
  41053. * @param callback defines the callback to use
  41054. */
  41055. onlefttriggerchanged(callback: (value: number) => void): void;
  41056. /**
  41057. * Defines the callback to call when right trigger is pressed
  41058. * @param callback defines the callback to use
  41059. */
  41060. onrighttriggerchanged(callback: (value: number) => void): void;
  41061. /**
  41062. * Gets the left trigger value
  41063. */
  41064. get leftTrigger(): number;
  41065. /**
  41066. * Sets the left trigger value
  41067. */
  41068. set leftTrigger(newValue: number);
  41069. /**
  41070. * Gets the right trigger value
  41071. */
  41072. get rightTrigger(): number;
  41073. /**
  41074. * Sets the right trigger value
  41075. */
  41076. set rightTrigger(newValue: number);
  41077. /**
  41078. * Defines the callback to call when a button is pressed
  41079. * @param callback defines the callback to use
  41080. */
  41081. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41082. /**
  41083. * Defines the callback to call when a button is released
  41084. * @param callback defines the callback to use
  41085. */
  41086. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41087. /**
  41088. * Defines the callback to call when a pad is pressed
  41089. * @param callback defines the callback to use
  41090. */
  41091. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41092. /**
  41093. * Defines the callback to call when a pad is released
  41094. * @param callback defines the callback to use
  41095. */
  41096. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41097. private _setButtonValue;
  41098. private _setDPadValue;
  41099. /**
  41100. * Gets the value of the `A` button
  41101. */
  41102. get buttonA(): number;
  41103. /**
  41104. * Sets the value of the `A` button
  41105. */
  41106. set buttonA(value: number);
  41107. /**
  41108. * Gets the value of the `B` button
  41109. */
  41110. get buttonB(): number;
  41111. /**
  41112. * Sets the value of the `B` button
  41113. */
  41114. set buttonB(value: number);
  41115. /**
  41116. * Gets the value of the `X` button
  41117. */
  41118. get buttonX(): number;
  41119. /**
  41120. * Sets the value of the `X` button
  41121. */
  41122. set buttonX(value: number);
  41123. /**
  41124. * Gets the value of the `Y` button
  41125. */
  41126. get buttonY(): number;
  41127. /**
  41128. * Sets the value of the `Y` button
  41129. */
  41130. set buttonY(value: number);
  41131. /**
  41132. * Gets the value of the `Start` button
  41133. */
  41134. get buttonStart(): number;
  41135. /**
  41136. * Sets the value of the `Start` button
  41137. */
  41138. set buttonStart(value: number);
  41139. /**
  41140. * Gets the value of the `Back` button
  41141. */
  41142. get buttonBack(): number;
  41143. /**
  41144. * Sets the value of the `Back` button
  41145. */
  41146. set buttonBack(value: number);
  41147. /**
  41148. * Gets the value of the `Left` button
  41149. */
  41150. get buttonLB(): number;
  41151. /**
  41152. * Sets the value of the `Left` button
  41153. */
  41154. set buttonLB(value: number);
  41155. /**
  41156. * Gets the value of the `Right` button
  41157. */
  41158. get buttonRB(): number;
  41159. /**
  41160. * Sets the value of the `Right` button
  41161. */
  41162. set buttonRB(value: number);
  41163. /**
  41164. * Gets the value of the Left joystick
  41165. */
  41166. get buttonLeftStick(): number;
  41167. /**
  41168. * Sets the value of the Left joystick
  41169. */
  41170. set buttonLeftStick(value: number);
  41171. /**
  41172. * Gets the value of the Right joystick
  41173. */
  41174. get buttonRightStick(): number;
  41175. /**
  41176. * Sets the value of the Right joystick
  41177. */
  41178. set buttonRightStick(value: number);
  41179. /**
  41180. * Gets the value of D-pad up
  41181. */
  41182. get dPadUp(): number;
  41183. /**
  41184. * Sets the value of D-pad up
  41185. */
  41186. set dPadUp(value: number);
  41187. /**
  41188. * Gets the value of D-pad down
  41189. */
  41190. get dPadDown(): number;
  41191. /**
  41192. * Sets the value of D-pad down
  41193. */
  41194. set dPadDown(value: number);
  41195. /**
  41196. * Gets the value of D-pad left
  41197. */
  41198. get dPadLeft(): number;
  41199. /**
  41200. * Sets the value of D-pad left
  41201. */
  41202. set dPadLeft(value: number);
  41203. /**
  41204. * Gets the value of D-pad right
  41205. */
  41206. get dPadRight(): number;
  41207. /**
  41208. * Sets the value of D-pad right
  41209. */
  41210. set dPadRight(value: number);
  41211. /**
  41212. * Force the gamepad to synchronize with device values
  41213. */
  41214. update(): void;
  41215. /**
  41216. * Disposes the gamepad
  41217. */
  41218. dispose(): void;
  41219. }
  41220. }
  41221. declare module BABYLON {
  41222. /**
  41223. * Defines supported buttons for DualShock compatible gamepads
  41224. */
  41225. export enum DualShockButton {
  41226. /** Cross */
  41227. Cross = 0,
  41228. /** Circle */
  41229. Circle = 1,
  41230. /** Square */
  41231. Square = 2,
  41232. /** Triangle */
  41233. Triangle = 3,
  41234. /** L1 */
  41235. L1 = 4,
  41236. /** R1 */
  41237. R1 = 5,
  41238. /** Share */
  41239. Share = 8,
  41240. /** Options */
  41241. Options = 9,
  41242. /** Left stick */
  41243. LeftStick = 10,
  41244. /** Right stick */
  41245. RightStick = 11
  41246. }
  41247. /** Defines values for DualShock DPad */
  41248. export enum DualShockDpad {
  41249. /** Up */
  41250. Up = 12,
  41251. /** Down */
  41252. Down = 13,
  41253. /** Left */
  41254. Left = 14,
  41255. /** Right */
  41256. Right = 15
  41257. }
  41258. /**
  41259. * Defines a DualShock gamepad
  41260. */
  41261. export class DualShockPad extends Gamepad {
  41262. private _leftTrigger;
  41263. private _rightTrigger;
  41264. private _onlefttriggerchanged;
  41265. private _onrighttriggerchanged;
  41266. private _onbuttondown;
  41267. private _onbuttonup;
  41268. private _ondpaddown;
  41269. private _ondpadup;
  41270. /** Observable raised when a button is pressed */
  41271. onButtonDownObservable: Observable<DualShockButton>;
  41272. /** Observable raised when a button is released */
  41273. onButtonUpObservable: Observable<DualShockButton>;
  41274. /** Observable raised when a pad is pressed */
  41275. onPadDownObservable: Observable<DualShockDpad>;
  41276. /** Observable raised when a pad is released */
  41277. onPadUpObservable: Observable<DualShockDpad>;
  41278. private _buttonCross;
  41279. private _buttonCircle;
  41280. private _buttonSquare;
  41281. private _buttonTriangle;
  41282. private _buttonShare;
  41283. private _buttonOptions;
  41284. private _buttonL1;
  41285. private _buttonR1;
  41286. private _buttonLeftStick;
  41287. private _buttonRightStick;
  41288. private _dPadUp;
  41289. private _dPadDown;
  41290. private _dPadLeft;
  41291. private _dPadRight;
  41292. /**
  41293. * Creates a new DualShock gamepad object
  41294. * @param id defines the id of this gamepad
  41295. * @param index defines its index
  41296. * @param gamepad defines the internal HTML gamepad object
  41297. */
  41298. constructor(id: string, index: number, gamepad: any);
  41299. /**
  41300. * Defines the callback to call when left trigger is pressed
  41301. * @param callback defines the callback to use
  41302. */
  41303. onlefttriggerchanged(callback: (value: number) => void): void;
  41304. /**
  41305. * Defines the callback to call when right trigger is pressed
  41306. * @param callback defines the callback to use
  41307. */
  41308. onrighttriggerchanged(callback: (value: number) => void): void;
  41309. /**
  41310. * Gets the left trigger value
  41311. */
  41312. get leftTrigger(): number;
  41313. /**
  41314. * Sets the left trigger value
  41315. */
  41316. set leftTrigger(newValue: number);
  41317. /**
  41318. * Gets the right trigger value
  41319. */
  41320. get rightTrigger(): number;
  41321. /**
  41322. * Sets the right trigger value
  41323. */
  41324. set rightTrigger(newValue: number);
  41325. /**
  41326. * Defines the callback to call when a button is pressed
  41327. * @param callback defines the callback to use
  41328. */
  41329. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41330. /**
  41331. * Defines the callback to call when a button is released
  41332. * @param callback defines the callback to use
  41333. */
  41334. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41335. /**
  41336. * Defines the callback to call when a pad is pressed
  41337. * @param callback defines the callback to use
  41338. */
  41339. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41340. /**
  41341. * Defines the callback to call when a pad is released
  41342. * @param callback defines the callback to use
  41343. */
  41344. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41345. private _setButtonValue;
  41346. private _setDPadValue;
  41347. /**
  41348. * Gets the value of the `Cross` button
  41349. */
  41350. get buttonCross(): number;
  41351. /**
  41352. * Sets the value of the `Cross` button
  41353. */
  41354. set buttonCross(value: number);
  41355. /**
  41356. * Gets the value of the `Circle` button
  41357. */
  41358. get buttonCircle(): number;
  41359. /**
  41360. * Sets the value of the `Circle` button
  41361. */
  41362. set buttonCircle(value: number);
  41363. /**
  41364. * Gets the value of the `Square` button
  41365. */
  41366. get buttonSquare(): number;
  41367. /**
  41368. * Sets the value of the `Square` button
  41369. */
  41370. set buttonSquare(value: number);
  41371. /**
  41372. * Gets the value of the `Triangle` button
  41373. */
  41374. get buttonTriangle(): number;
  41375. /**
  41376. * Sets the value of the `Triangle` button
  41377. */
  41378. set buttonTriangle(value: number);
  41379. /**
  41380. * Gets the value of the `Options` button
  41381. */
  41382. get buttonOptions(): number;
  41383. /**
  41384. * Sets the value of the `Options` button
  41385. */
  41386. set buttonOptions(value: number);
  41387. /**
  41388. * Gets the value of the `Share` button
  41389. */
  41390. get buttonShare(): number;
  41391. /**
  41392. * Sets the value of the `Share` button
  41393. */
  41394. set buttonShare(value: number);
  41395. /**
  41396. * Gets the value of the `L1` button
  41397. */
  41398. get buttonL1(): number;
  41399. /**
  41400. * Sets the value of the `L1` button
  41401. */
  41402. set buttonL1(value: number);
  41403. /**
  41404. * Gets the value of the `R1` button
  41405. */
  41406. get buttonR1(): number;
  41407. /**
  41408. * Sets the value of the `R1` button
  41409. */
  41410. set buttonR1(value: number);
  41411. /**
  41412. * Gets the value of the Left joystick
  41413. */
  41414. get buttonLeftStick(): number;
  41415. /**
  41416. * Sets the value of the Left joystick
  41417. */
  41418. set buttonLeftStick(value: number);
  41419. /**
  41420. * Gets the value of the Right joystick
  41421. */
  41422. get buttonRightStick(): number;
  41423. /**
  41424. * Sets the value of the Right joystick
  41425. */
  41426. set buttonRightStick(value: number);
  41427. /**
  41428. * Gets the value of D-pad up
  41429. */
  41430. get dPadUp(): number;
  41431. /**
  41432. * Sets the value of D-pad up
  41433. */
  41434. set dPadUp(value: number);
  41435. /**
  41436. * Gets the value of D-pad down
  41437. */
  41438. get dPadDown(): number;
  41439. /**
  41440. * Sets the value of D-pad down
  41441. */
  41442. set dPadDown(value: number);
  41443. /**
  41444. * Gets the value of D-pad left
  41445. */
  41446. get dPadLeft(): number;
  41447. /**
  41448. * Sets the value of D-pad left
  41449. */
  41450. set dPadLeft(value: number);
  41451. /**
  41452. * Gets the value of D-pad right
  41453. */
  41454. get dPadRight(): number;
  41455. /**
  41456. * Sets the value of D-pad right
  41457. */
  41458. set dPadRight(value: number);
  41459. /**
  41460. * Force the gamepad to synchronize with device values
  41461. */
  41462. update(): void;
  41463. /**
  41464. * Disposes the gamepad
  41465. */
  41466. dispose(): void;
  41467. }
  41468. }
  41469. declare module BABYLON {
  41470. /**
  41471. * Manager for handling gamepads
  41472. */
  41473. export class GamepadManager {
  41474. private _scene?;
  41475. private _babylonGamepads;
  41476. private _oneGamepadConnected;
  41477. /** @hidden */
  41478. _isMonitoring: boolean;
  41479. private _gamepadEventSupported;
  41480. private _gamepadSupport?;
  41481. /**
  41482. * observable to be triggered when the gamepad controller has been connected
  41483. */
  41484. onGamepadConnectedObservable: Observable<Gamepad>;
  41485. /**
  41486. * observable to be triggered when the gamepad controller has been disconnected
  41487. */
  41488. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41489. private _onGamepadConnectedEvent;
  41490. private _onGamepadDisconnectedEvent;
  41491. /**
  41492. * Initializes the gamepad manager
  41493. * @param _scene BabylonJS scene
  41494. */
  41495. constructor(_scene?: Scene | undefined);
  41496. /**
  41497. * The gamepads in the game pad manager
  41498. */
  41499. get gamepads(): Gamepad[];
  41500. /**
  41501. * Get the gamepad controllers based on type
  41502. * @param type The type of gamepad controller
  41503. * @returns Nullable gamepad
  41504. */
  41505. getGamepadByType(type?: number): Nullable<Gamepad>;
  41506. /**
  41507. * Disposes the gamepad manager
  41508. */
  41509. dispose(): void;
  41510. private _addNewGamepad;
  41511. private _startMonitoringGamepads;
  41512. private _stopMonitoringGamepads;
  41513. /** @hidden */
  41514. _checkGamepadsStatus(): void;
  41515. private _updateGamepadObjects;
  41516. }
  41517. }
  41518. declare module BABYLON {
  41519. interface Scene {
  41520. /** @hidden */
  41521. _gamepadManager: Nullable<GamepadManager>;
  41522. /**
  41523. * Gets the gamepad manager associated with the scene
  41524. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41525. */
  41526. gamepadManager: GamepadManager;
  41527. }
  41528. /**
  41529. * Interface representing a free camera inputs manager
  41530. */
  41531. interface FreeCameraInputsManager {
  41532. /**
  41533. * Adds gamepad input support to the FreeCameraInputsManager.
  41534. * @returns the FreeCameraInputsManager
  41535. */
  41536. addGamepad(): FreeCameraInputsManager;
  41537. }
  41538. /**
  41539. * Interface representing an arc rotate camera inputs manager
  41540. */
  41541. interface ArcRotateCameraInputsManager {
  41542. /**
  41543. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41544. * @returns the camera inputs manager
  41545. */
  41546. addGamepad(): ArcRotateCameraInputsManager;
  41547. }
  41548. /**
  41549. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41550. */
  41551. export class GamepadSystemSceneComponent implements ISceneComponent {
  41552. /**
  41553. * The component name helpfull to identify the component in the list of scene components.
  41554. */
  41555. readonly name: string;
  41556. /**
  41557. * The scene the component belongs to.
  41558. */
  41559. scene: Scene;
  41560. /**
  41561. * Creates a new instance of the component for the given scene
  41562. * @param scene Defines the scene to register the component in
  41563. */
  41564. constructor(scene: Scene);
  41565. /**
  41566. * Registers the component in a given scene
  41567. */
  41568. register(): void;
  41569. /**
  41570. * Rebuilds the elements related to this component in case of
  41571. * context lost for instance.
  41572. */
  41573. rebuild(): void;
  41574. /**
  41575. * Disposes the component and the associated ressources
  41576. */
  41577. dispose(): void;
  41578. private _beforeCameraUpdate;
  41579. }
  41580. }
  41581. declare module BABYLON {
  41582. /**
  41583. * 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,
  41584. * which still works and will still be found in many Playgrounds.
  41585. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41586. */
  41587. export class UniversalCamera extends TouchCamera {
  41588. /**
  41589. * Defines the gamepad rotation sensiblity.
  41590. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41591. */
  41592. get gamepadAngularSensibility(): number;
  41593. set gamepadAngularSensibility(value: number);
  41594. /**
  41595. * Defines the gamepad move sensiblity.
  41596. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41597. */
  41598. get gamepadMoveSensibility(): number;
  41599. set gamepadMoveSensibility(value: number);
  41600. /**
  41601. * 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,
  41602. * which still works and will still be found in many Playgrounds.
  41603. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41604. * @param name Define the name of the camera in the scene
  41605. * @param position Define the start position of the camera in the scene
  41606. * @param scene Define the scene the camera belongs to
  41607. */
  41608. constructor(name: string, position: Vector3, scene: Scene);
  41609. /**
  41610. * Gets the current object class name.
  41611. * @return the class name
  41612. */
  41613. getClassName(): string;
  41614. }
  41615. }
  41616. declare module BABYLON {
  41617. /**
  41618. * This represents a FPS type of camera. This is only here for back compat purpose.
  41619. * Please use the UniversalCamera instead as both are identical.
  41620. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41621. */
  41622. export class GamepadCamera extends UniversalCamera {
  41623. /**
  41624. * Instantiates a new Gamepad Camera
  41625. * This represents a FPS type of camera. This is only here for back compat purpose.
  41626. * Please use the UniversalCamera instead as both are identical.
  41627. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41628. * @param name Define the name of the camera in the scene
  41629. * @param position Define the start position of the camera in the scene
  41630. * @param scene Define the scene the camera belongs to
  41631. */
  41632. constructor(name: string, position: Vector3, scene: Scene);
  41633. /**
  41634. * Gets the current object class name.
  41635. * @return the class name
  41636. */
  41637. getClassName(): string;
  41638. }
  41639. }
  41640. declare module BABYLON {
  41641. /** @hidden */
  41642. export var passPixelShader: {
  41643. name: string;
  41644. shader: string;
  41645. };
  41646. }
  41647. declare module BABYLON {
  41648. /** @hidden */
  41649. export var passCubePixelShader: {
  41650. name: string;
  41651. shader: string;
  41652. };
  41653. }
  41654. declare module BABYLON {
  41655. /**
  41656. * PassPostProcess which produces an output the same as it's input
  41657. */
  41658. export class PassPostProcess extends PostProcess {
  41659. /**
  41660. * Creates the PassPostProcess
  41661. * @param name The name of the effect.
  41662. * @param options The required width/height ratio to downsize to before computing the render pass.
  41663. * @param camera The camera to apply the render pass to.
  41664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41665. * @param engine The engine which the post process will be applied. (default: current engine)
  41666. * @param reusable If the post process can be reused on the same frame. (default: false)
  41667. * @param textureType The type of texture to be used when performing the post processing.
  41668. * @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)
  41669. */
  41670. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41671. }
  41672. /**
  41673. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41674. */
  41675. export class PassCubePostProcess extends PostProcess {
  41676. private _face;
  41677. /**
  41678. * Gets or sets the cube face to display.
  41679. * * 0 is +X
  41680. * * 1 is -X
  41681. * * 2 is +Y
  41682. * * 3 is -Y
  41683. * * 4 is +Z
  41684. * * 5 is -Z
  41685. */
  41686. get face(): number;
  41687. set face(value: number);
  41688. /**
  41689. * Creates the PassCubePostProcess
  41690. * @param name The name of the effect.
  41691. * @param options The required width/height ratio to downsize to before computing the render pass.
  41692. * @param camera The camera to apply the render pass to.
  41693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41694. * @param engine The engine which the post process will be applied. (default: current engine)
  41695. * @param reusable If the post process can be reused on the same frame. (default: false)
  41696. * @param textureType The type of texture to be used when performing the post processing.
  41697. * @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)
  41698. */
  41699. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41700. }
  41701. }
  41702. declare module BABYLON {
  41703. /** @hidden */
  41704. export var anaglyphPixelShader: {
  41705. name: string;
  41706. shader: string;
  41707. };
  41708. }
  41709. declare module BABYLON {
  41710. /**
  41711. * Postprocess used to generate anaglyphic rendering
  41712. */
  41713. export class AnaglyphPostProcess extends PostProcess {
  41714. private _passedProcess;
  41715. /**
  41716. * Creates a new AnaglyphPostProcess
  41717. * @param name defines postprocess name
  41718. * @param options defines creation options or target ratio scale
  41719. * @param rigCameras defines cameras using this postprocess
  41720. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41721. * @param engine defines hosting engine
  41722. * @param reusable defines if the postprocess will be reused multiple times per frame
  41723. */
  41724. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41730. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41731. */
  41732. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41733. /**
  41734. * Creates a new AnaglyphArcRotateCamera
  41735. * @param name defines camera name
  41736. * @param alpha defines alpha angle (in radians)
  41737. * @param beta defines beta angle (in radians)
  41738. * @param radius defines radius
  41739. * @param target defines camera target
  41740. * @param interaxialDistance defines distance between each color axis
  41741. * @param scene defines the hosting scene
  41742. */
  41743. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41744. /**
  41745. * Gets camera class name
  41746. * @returns AnaglyphArcRotateCamera
  41747. */
  41748. getClassName(): string;
  41749. }
  41750. }
  41751. declare module BABYLON {
  41752. /**
  41753. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41754. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41755. */
  41756. export class AnaglyphFreeCamera extends FreeCamera {
  41757. /**
  41758. * Creates a new AnaglyphFreeCamera
  41759. * @param name defines camera name
  41760. * @param position defines initial position
  41761. * @param interaxialDistance defines distance between each color axis
  41762. * @param scene defines the hosting scene
  41763. */
  41764. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41765. /**
  41766. * Gets camera class name
  41767. * @returns AnaglyphFreeCamera
  41768. */
  41769. getClassName(): string;
  41770. }
  41771. }
  41772. declare module BABYLON {
  41773. /**
  41774. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41775. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41776. */
  41777. export class AnaglyphGamepadCamera extends GamepadCamera {
  41778. /**
  41779. * Creates a new AnaglyphGamepadCamera
  41780. * @param name defines camera name
  41781. * @param position defines initial position
  41782. * @param interaxialDistance defines distance between each color axis
  41783. * @param scene defines the hosting scene
  41784. */
  41785. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41786. /**
  41787. * Gets camera class name
  41788. * @returns AnaglyphGamepadCamera
  41789. */
  41790. getClassName(): string;
  41791. }
  41792. }
  41793. declare module BABYLON {
  41794. /**
  41795. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41796. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41797. */
  41798. export class AnaglyphUniversalCamera extends UniversalCamera {
  41799. /**
  41800. * Creates a new AnaglyphUniversalCamera
  41801. * @param name defines camera name
  41802. * @param position defines initial position
  41803. * @param interaxialDistance defines distance between each color axis
  41804. * @param scene defines the hosting scene
  41805. */
  41806. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41807. /**
  41808. * Gets camera class name
  41809. * @returns AnaglyphUniversalCamera
  41810. */
  41811. getClassName(): string;
  41812. }
  41813. }
  41814. declare module BABYLON {
  41815. /** @hidden */
  41816. export var stereoscopicInterlacePixelShader: {
  41817. name: string;
  41818. shader: string;
  41819. };
  41820. }
  41821. declare module BABYLON {
  41822. /**
  41823. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41824. */
  41825. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41826. private _stepSize;
  41827. private _passedProcess;
  41828. /**
  41829. * Initializes a StereoscopicInterlacePostProcessI
  41830. * @param name The name of the effect.
  41831. * @param rigCameras The rig cameras to be appled to the post process
  41832. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41833. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41835. * @param engine The engine which the post process will be applied. (default: current engine)
  41836. * @param reusable If the post process can be reused on the same frame. (default: false)
  41837. */
  41838. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41839. }
  41840. /**
  41841. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41842. */
  41843. export class StereoscopicInterlacePostProcess extends PostProcess {
  41844. private _stepSize;
  41845. private _passedProcess;
  41846. /**
  41847. * Initializes a StereoscopicInterlacePostProcess
  41848. * @param name The name of the effect.
  41849. * @param rigCameras The rig cameras to be appled to the post process
  41850. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41852. * @param engine The engine which the post process will be applied. (default: current engine)
  41853. * @param reusable If the post process can be reused on the same frame. (default: false)
  41854. */
  41855. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41856. }
  41857. }
  41858. declare module BABYLON {
  41859. /**
  41860. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41861. * @see http://doc.babylonjs.com/features/cameras
  41862. */
  41863. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41864. /**
  41865. * Creates a new StereoscopicArcRotateCamera
  41866. * @param name defines camera name
  41867. * @param alpha defines alpha angle (in radians)
  41868. * @param beta defines beta angle (in radians)
  41869. * @param radius defines radius
  41870. * @param target defines camera target
  41871. * @param interaxialDistance defines distance between each color axis
  41872. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41873. * @param scene defines the hosting scene
  41874. */
  41875. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41876. /**
  41877. * Gets camera class name
  41878. * @returns StereoscopicArcRotateCamera
  41879. */
  41880. getClassName(): string;
  41881. }
  41882. }
  41883. declare module BABYLON {
  41884. /**
  41885. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41886. * @see http://doc.babylonjs.com/features/cameras
  41887. */
  41888. export class StereoscopicFreeCamera extends FreeCamera {
  41889. /**
  41890. * Creates a new StereoscopicFreeCamera
  41891. * @param name defines camera name
  41892. * @param position defines initial position
  41893. * @param interaxialDistance defines distance between each color axis
  41894. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41895. * @param scene defines the hosting scene
  41896. */
  41897. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41898. /**
  41899. * Gets camera class name
  41900. * @returns StereoscopicFreeCamera
  41901. */
  41902. getClassName(): string;
  41903. }
  41904. }
  41905. declare module BABYLON {
  41906. /**
  41907. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41908. * @see http://doc.babylonjs.com/features/cameras
  41909. */
  41910. export class StereoscopicGamepadCamera extends GamepadCamera {
  41911. /**
  41912. * Creates a new StereoscopicGamepadCamera
  41913. * @param name defines camera name
  41914. * @param position defines initial position
  41915. * @param interaxialDistance defines distance between each color axis
  41916. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41917. * @param scene defines the hosting scene
  41918. */
  41919. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41920. /**
  41921. * Gets camera class name
  41922. * @returns StereoscopicGamepadCamera
  41923. */
  41924. getClassName(): string;
  41925. }
  41926. }
  41927. declare module BABYLON {
  41928. /**
  41929. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41930. * @see http://doc.babylonjs.com/features/cameras
  41931. */
  41932. export class StereoscopicUniversalCamera extends UniversalCamera {
  41933. /**
  41934. * Creates a new StereoscopicUniversalCamera
  41935. * @param name defines camera name
  41936. * @param position defines initial position
  41937. * @param interaxialDistance defines distance between each color axis
  41938. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41939. * @param scene defines the hosting scene
  41940. */
  41941. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41942. /**
  41943. * Gets camera class name
  41944. * @returns StereoscopicUniversalCamera
  41945. */
  41946. getClassName(): string;
  41947. }
  41948. }
  41949. declare module BABYLON {
  41950. /**
  41951. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41952. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41953. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41954. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41955. */
  41956. export class VirtualJoysticksCamera extends FreeCamera {
  41957. /**
  41958. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41959. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41960. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41961. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41962. * @param name Define the name of the camera in the scene
  41963. * @param position Define the start position of the camera in the scene
  41964. * @param scene Define the scene the camera belongs to
  41965. */
  41966. constructor(name: string, position: Vector3, scene: Scene);
  41967. /**
  41968. * Gets the current object class name.
  41969. * @return the class name
  41970. */
  41971. getClassName(): string;
  41972. }
  41973. }
  41974. declare module BABYLON {
  41975. /**
  41976. * This represents all the required metrics to create a VR camera.
  41977. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41978. */
  41979. export class VRCameraMetrics {
  41980. /**
  41981. * Define the horizontal resolution off the screen.
  41982. */
  41983. hResolution: number;
  41984. /**
  41985. * Define the vertical resolution off the screen.
  41986. */
  41987. vResolution: number;
  41988. /**
  41989. * Define the horizontal screen size.
  41990. */
  41991. hScreenSize: number;
  41992. /**
  41993. * Define the vertical screen size.
  41994. */
  41995. vScreenSize: number;
  41996. /**
  41997. * Define the vertical screen center position.
  41998. */
  41999. vScreenCenter: number;
  42000. /**
  42001. * Define the distance of the eyes to the screen.
  42002. */
  42003. eyeToScreenDistance: number;
  42004. /**
  42005. * Define the distance between both lenses
  42006. */
  42007. lensSeparationDistance: number;
  42008. /**
  42009. * Define the distance between both viewer's eyes.
  42010. */
  42011. interpupillaryDistance: number;
  42012. /**
  42013. * Define the distortion factor of the VR postprocess.
  42014. * Please, touch with care.
  42015. */
  42016. distortionK: number[];
  42017. /**
  42018. * Define the chromatic aberration correction factors for the VR post process.
  42019. */
  42020. chromaAbCorrection: number[];
  42021. /**
  42022. * Define the scale factor of the post process.
  42023. * The smaller the better but the slower.
  42024. */
  42025. postProcessScaleFactor: number;
  42026. /**
  42027. * Define an offset for the lens center.
  42028. */
  42029. lensCenterOffset: number;
  42030. /**
  42031. * Define if the current vr camera should compensate the distortion of the lense or not.
  42032. */
  42033. compensateDistortion: boolean;
  42034. /**
  42035. * Defines if multiview should be enabled when rendering (Default: false)
  42036. */
  42037. multiviewEnabled: boolean;
  42038. /**
  42039. * Gets the rendering aspect ratio based on the provided resolutions.
  42040. */
  42041. get aspectRatio(): number;
  42042. /**
  42043. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42044. */
  42045. get aspectRatioFov(): number;
  42046. /**
  42047. * @hidden
  42048. */
  42049. get leftHMatrix(): Matrix;
  42050. /**
  42051. * @hidden
  42052. */
  42053. get rightHMatrix(): Matrix;
  42054. /**
  42055. * @hidden
  42056. */
  42057. get leftPreViewMatrix(): Matrix;
  42058. /**
  42059. * @hidden
  42060. */
  42061. get rightPreViewMatrix(): Matrix;
  42062. /**
  42063. * Get the default VRMetrics based on the most generic setup.
  42064. * @returns the default vr metrics
  42065. */
  42066. static GetDefault(): VRCameraMetrics;
  42067. }
  42068. }
  42069. declare module BABYLON {
  42070. /** @hidden */
  42071. export var vrDistortionCorrectionPixelShader: {
  42072. name: string;
  42073. shader: string;
  42074. };
  42075. }
  42076. declare module BABYLON {
  42077. /**
  42078. * VRDistortionCorrectionPostProcess used for mobile VR
  42079. */
  42080. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42081. private _isRightEye;
  42082. private _distortionFactors;
  42083. private _postProcessScaleFactor;
  42084. private _lensCenterOffset;
  42085. private _scaleIn;
  42086. private _scaleFactor;
  42087. private _lensCenter;
  42088. /**
  42089. * Initializes the VRDistortionCorrectionPostProcess
  42090. * @param name The name of the effect.
  42091. * @param camera The camera to apply the render pass to.
  42092. * @param isRightEye If this is for the right eye distortion
  42093. * @param vrMetrics All the required metrics for the VR camera
  42094. */
  42095. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42096. }
  42097. }
  42098. declare module BABYLON {
  42099. /**
  42100. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42101. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42102. */
  42103. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42104. /**
  42105. * Creates a new VRDeviceOrientationArcRotateCamera
  42106. * @param name defines camera name
  42107. * @param alpha defines the camera rotation along the logitudinal axis
  42108. * @param beta defines the camera rotation along the latitudinal axis
  42109. * @param radius defines the camera distance from its target
  42110. * @param target defines the camera target
  42111. * @param scene defines the scene the camera belongs to
  42112. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42113. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42114. */
  42115. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42116. /**
  42117. * Gets camera class name
  42118. * @returns VRDeviceOrientationArcRotateCamera
  42119. */
  42120. getClassName(): string;
  42121. }
  42122. }
  42123. declare module BABYLON {
  42124. /**
  42125. * Camera used to simulate VR rendering (based on FreeCamera)
  42126. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42127. */
  42128. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42129. /**
  42130. * Creates a new VRDeviceOrientationFreeCamera
  42131. * @param name defines camera name
  42132. * @param position defines the start position of the camera
  42133. * @param scene defines the scene the camera belongs to
  42134. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42135. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42136. */
  42137. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42138. /**
  42139. * Gets camera class name
  42140. * @returns VRDeviceOrientationFreeCamera
  42141. */
  42142. getClassName(): string;
  42143. }
  42144. }
  42145. declare module BABYLON {
  42146. /**
  42147. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42148. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42149. */
  42150. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42151. /**
  42152. * Creates a new VRDeviceOrientationGamepadCamera
  42153. * @param name defines camera name
  42154. * @param position defines the start position of the camera
  42155. * @param scene defines the scene the camera belongs to
  42156. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42157. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42158. */
  42159. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42160. /**
  42161. * Gets camera class name
  42162. * @returns VRDeviceOrientationGamepadCamera
  42163. */
  42164. getClassName(): string;
  42165. }
  42166. }
  42167. declare module BABYLON {
  42168. /** @hidden */
  42169. export var imageProcessingPixelShader: {
  42170. name: string;
  42171. shader: string;
  42172. };
  42173. }
  42174. declare module BABYLON {
  42175. /**
  42176. * ImageProcessingPostProcess
  42177. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42178. */
  42179. export class ImageProcessingPostProcess extends PostProcess {
  42180. /**
  42181. * Default configuration related to image processing available in the PBR Material.
  42182. */
  42183. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42184. /**
  42185. * Gets the image processing configuration used either in this material.
  42186. */
  42187. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42188. /**
  42189. * Sets the Default image processing configuration used either in the this material.
  42190. *
  42191. * If sets to null, the scene one is in use.
  42192. */
  42193. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42194. /**
  42195. * Keep track of the image processing observer to allow dispose and replace.
  42196. */
  42197. private _imageProcessingObserver;
  42198. /**
  42199. * Attaches a new image processing configuration to the PBR Material.
  42200. * @param configuration
  42201. */
  42202. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42203. /**
  42204. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42205. */
  42206. get colorCurves(): Nullable<ColorCurves>;
  42207. /**
  42208. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42209. */
  42210. set colorCurves(value: Nullable<ColorCurves>);
  42211. /**
  42212. * Gets wether the color curves effect is enabled.
  42213. */
  42214. get colorCurvesEnabled(): boolean;
  42215. /**
  42216. * Sets wether the color curves effect is enabled.
  42217. */
  42218. set colorCurvesEnabled(value: boolean);
  42219. /**
  42220. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42221. */
  42222. get colorGradingTexture(): Nullable<BaseTexture>;
  42223. /**
  42224. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42225. */
  42226. set colorGradingTexture(value: Nullable<BaseTexture>);
  42227. /**
  42228. * Gets wether the color grading effect is enabled.
  42229. */
  42230. get colorGradingEnabled(): boolean;
  42231. /**
  42232. * Gets wether the color grading effect is enabled.
  42233. */
  42234. set colorGradingEnabled(value: boolean);
  42235. /**
  42236. * Gets exposure used in the effect.
  42237. */
  42238. get exposure(): number;
  42239. /**
  42240. * Sets exposure used in the effect.
  42241. */
  42242. set exposure(value: number);
  42243. /**
  42244. * Gets wether tonemapping is enabled or not.
  42245. */
  42246. get toneMappingEnabled(): boolean;
  42247. /**
  42248. * Sets wether tonemapping is enabled or not
  42249. */
  42250. set toneMappingEnabled(value: boolean);
  42251. /**
  42252. * Gets the type of tone mapping effect.
  42253. */
  42254. get toneMappingType(): number;
  42255. /**
  42256. * Sets the type of tone mapping effect.
  42257. */
  42258. set toneMappingType(value: number);
  42259. /**
  42260. * Gets contrast used in the effect.
  42261. */
  42262. get contrast(): number;
  42263. /**
  42264. * Sets contrast used in the effect.
  42265. */
  42266. set contrast(value: number);
  42267. /**
  42268. * Gets Vignette stretch size.
  42269. */
  42270. get vignetteStretch(): number;
  42271. /**
  42272. * Sets Vignette stretch size.
  42273. */
  42274. set vignetteStretch(value: number);
  42275. /**
  42276. * Gets Vignette centre X Offset.
  42277. */
  42278. get vignetteCentreX(): number;
  42279. /**
  42280. * Sets Vignette centre X Offset.
  42281. */
  42282. set vignetteCentreX(value: number);
  42283. /**
  42284. * Gets Vignette centre Y Offset.
  42285. */
  42286. get vignetteCentreY(): number;
  42287. /**
  42288. * Sets Vignette centre Y Offset.
  42289. */
  42290. set vignetteCentreY(value: number);
  42291. /**
  42292. * Gets Vignette weight or intensity of the vignette effect.
  42293. */
  42294. get vignetteWeight(): number;
  42295. /**
  42296. * Sets Vignette weight or intensity of the vignette effect.
  42297. */
  42298. set vignetteWeight(value: number);
  42299. /**
  42300. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42301. * if vignetteEnabled is set to true.
  42302. */
  42303. get vignetteColor(): Color4;
  42304. /**
  42305. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42306. * if vignetteEnabled is set to true.
  42307. */
  42308. set vignetteColor(value: Color4);
  42309. /**
  42310. * Gets Camera field of view used by the Vignette effect.
  42311. */
  42312. get vignetteCameraFov(): number;
  42313. /**
  42314. * Sets Camera field of view used by the Vignette effect.
  42315. */
  42316. set vignetteCameraFov(value: number);
  42317. /**
  42318. * Gets the vignette blend mode allowing different kind of effect.
  42319. */
  42320. get vignetteBlendMode(): number;
  42321. /**
  42322. * Sets the vignette blend mode allowing different kind of effect.
  42323. */
  42324. set vignetteBlendMode(value: number);
  42325. /**
  42326. * Gets wether the vignette effect is enabled.
  42327. */
  42328. get vignetteEnabled(): boolean;
  42329. /**
  42330. * Sets wether the vignette effect is enabled.
  42331. */
  42332. set vignetteEnabled(value: boolean);
  42333. private _fromLinearSpace;
  42334. /**
  42335. * Gets wether the input of the processing is in Gamma or Linear Space.
  42336. */
  42337. get fromLinearSpace(): boolean;
  42338. /**
  42339. * Sets wether the input of the processing is in Gamma or Linear Space.
  42340. */
  42341. set fromLinearSpace(value: boolean);
  42342. /**
  42343. * Defines cache preventing GC.
  42344. */
  42345. private _defines;
  42346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42347. /**
  42348. * "ImageProcessingPostProcess"
  42349. * @returns "ImageProcessingPostProcess"
  42350. */
  42351. getClassName(): string;
  42352. protected _updateParameters(): void;
  42353. dispose(camera?: Camera): void;
  42354. }
  42355. }
  42356. declare module BABYLON {
  42357. /**
  42358. * Class containing static functions to help procedurally build meshes
  42359. */
  42360. export class GroundBuilder {
  42361. /**
  42362. * Creates a ground mesh
  42363. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42364. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42366. * @param name defines the name of the mesh
  42367. * @param options defines the options used to create the mesh
  42368. * @param scene defines the hosting scene
  42369. * @returns the ground mesh
  42370. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42371. */
  42372. static CreateGround(name: string, options: {
  42373. width?: number;
  42374. height?: number;
  42375. subdivisions?: number;
  42376. subdivisionsX?: number;
  42377. subdivisionsY?: number;
  42378. updatable?: boolean;
  42379. }, scene: any): Mesh;
  42380. /**
  42381. * Creates a tiled ground mesh
  42382. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42383. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42384. * * 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
  42385. * * 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
  42386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42387. * @param name defines the name of the mesh
  42388. * @param options defines the options used to create the mesh
  42389. * @param scene defines the hosting scene
  42390. * @returns the tiled ground mesh
  42391. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42392. */
  42393. static CreateTiledGround(name: string, options: {
  42394. xmin: number;
  42395. zmin: number;
  42396. xmax: number;
  42397. zmax: number;
  42398. subdivisions?: {
  42399. w: number;
  42400. h: number;
  42401. };
  42402. precision?: {
  42403. w: number;
  42404. h: number;
  42405. };
  42406. updatable?: boolean;
  42407. }, scene?: Nullable<Scene>): Mesh;
  42408. /**
  42409. * Creates a ground mesh from a height map
  42410. * * The parameter `url` sets the URL of the height map image resource.
  42411. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42412. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42413. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42414. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42415. * * 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.
  42416. * * 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).
  42417. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42419. * @param name defines the name of the mesh
  42420. * @param url defines the url to the height map
  42421. * @param options defines the options used to create the mesh
  42422. * @param scene defines the hosting scene
  42423. * @returns the ground mesh
  42424. * @see https://doc.babylonjs.com/babylon101/height_map
  42425. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42426. */
  42427. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42428. width?: number;
  42429. height?: number;
  42430. subdivisions?: number;
  42431. minHeight?: number;
  42432. maxHeight?: number;
  42433. colorFilter?: Color3;
  42434. alphaFilter?: number;
  42435. updatable?: boolean;
  42436. onReady?: (mesh: GroundMesh) => void;
  42437. }, scene?: Nullable<Scene>): GroundMesh;
  42438. }
  42439. }
  42440. declare module BABYLON {
  42441. /**
  42442. * Class containing static functions to help procedurally build meshes
  42443. */
  42444. export class TorusBuilder {
  42445. /**
  42446. * Creates a torus mesh
  42447. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42448. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42449. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42451. * * 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
  42452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42453. * @param name defines the name of the mesh
  42454. * @param options defines the options used to create the mesh
  42455. * @param scene defines the hosting scene
  42456. * @returns the torus mesh
  42457. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42458. */
  42459. static CreateTorus(name: string, options: {
  42460. diameter?: number;
  42461. thickness?: number;
  42462. tessellation?: number;
  42463. updatable?: boolean;
  42464. sideOrientation?: number;
  42465. frontUVs?: Vector4;
  42466. backUVs?: Vector4;
  42467. }, scene: any): Mesh;
  42468. }
  42469. }
  42470. declare module BABYLON {
  42471. /**
  42472. * Class containing static functions to help procedurally build meshes
  42473. */
  42474. export class CylinderBuilder {
  42475. /**
  42476. * Creates a cylinder or a cone mesh
  42477. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42478. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42479. * * 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.
  42480. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42481. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42482. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42483. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42484. * * 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).
  42485. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42486. * * 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).
  42487. * * 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
  42488. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42489. * * 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
  42490. * * 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.
  42491. * * If `enclose` is false, a ring surface is one element.
  42492. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42493. * * 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
  42494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42495. * * 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
  42496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42497. * @param name defines the name of the mesh
  42498. * @param options defines the options used to create the mesh
  42499. * @param scene defines the hosting scene
  42500. * @returns the cylinder mesh
  42501. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42502. */
  42503. static CreateCylinder(name: string, options: {
  42504. height?: number;
  42505. diameterTop?: number;
  42506. diameterBottom?: number;
  42507. diameter?: number;
  42508. tessellation?: number;
  42509. subdivisions?: number;
  42510. arc?: number;
  42511. faceColors?: Color4[];
  42512. faceUV?: Vector4[];
  42513. updatable?: boolean;
  42514. hasRings?: boolean;
  42515. enclose?: boolean;
  42516. cap?: number;
  42517. sideOrientation?: number;
  42518. frontUVs?: Vector4;
  42519. backUVs?: Vector4;
  42520. }, scene: any): Mesh;
  42521. }
  42522. }
  42523. declare module BABYLON {
  42524. /**
  42525. * States of the webXR experience
  42526. */
  42527. export enum WebXRState {
  42528. /**
  42529. * Transitioning to being in XR mode
  42530. */
  42531. ENTERING_XR = 0,
  42532. /**
  42533. * Transitioning to non XR mode
  42534. */
  42535. EXITING_XR = 1,
  42536. /**
  42537. * In XR mode and presenting
  42538. */
  42539. IN_XR = 2,
  42540. /**
  42541. * Not entered XR mode
  42542. */
  42543. NOT_IN_XR = 3
  42544. }
  42545. /**
  42546. * Abstraction of the XR render target
  42547. */
  42548. export interface WebXRRenderTarget extends IDisposable {
  42549. /**
  42550. * xrpresent context of the canvas which can be used to display/mirror xr content
  42551. */
  42552. canvasContext: WebGLRenderingContext;
  42553. /**
  42554. * xr layer for the canvas
  42555. */
  42556. xrLayer: Nullable<XRWebGLLayer>;
  42557. /**
  42558. * Initializes the xr layer for the session
  42559. * @param xrSession xr session
  42560. * @returns a promise that will resolve once the XR Layer has been created
  42561. */
  42562. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * COnfiguration object for WebXR output canvas
  42568. */
  42569. export class WebXRManagedOutputCanvasOptions {
  42570. /**
  42571. * An optional canvas in case you wish to create it yourself and provide it here.
  42572. * If not provided, a new canvas will be created
  42573. */
  42574. canvasElement?: HTMLCanvasElement;
  42575. /**
  42576. * Options for this XR Layer output
  42577. */
  42578. canvasOptions?: XRWebGLLayerOptions;
  42579. /**
  42580. * CSS styling for a newly created canvas (if not provided)
  42581. */
  42582. newCanvasCssStyle?: string;
  42583. /**
  42584. * Get the default values of the configuration object
  42585. * @returns default values of this configuration object
  42586. */
  42587. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42588. }
  42589. /**
  42590. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42591. */
  42592. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42593. private _options;
  42594. private _canvas;
  42595. private _engine;
  42596. /**
  42597. * Rendering context of the canvas which can be used to display/mirror xr content
  42598. */
  42599. canvasContext: WebGLRenderingContext;
  42600. /**
  42601. * xr layer for the canvas
  42602. */
  42603. xrLayer: Nullable<XRWebGLLayer>;
  42604. /**
  42605. * Initializes the canvas to be added/removed upon entering/exiting xr
  42606. * @param _xrSessionManager The XR Session manager
  42607. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42608. */
  42609. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42610. /**
  42611. * Disposes of the object
  42612. */
  42613. dispose(): void;
  42614. /**
  42615. * Initializes the xr layer for the session
  42616. * @param xrSession xr session
  42617. * @returns a promise that will resolve once the XR Layer has been created
  42618. */
  42619. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42620. private _addCanvas;
  42621. private _removeCanvas;
  42622. private _setManagedOutputCanvas;
  42623. }
  42624. }
  42625. declare module BABYLON {
  42626. /**
  42627. * Manages an XRSession to work with Babylon's engine
  42628. * @see https://doc.babylonjs.com/how_to/webxr
  42629. */
  42630. export class WebXRSessionManager implements IDisposable {
  42631. /** The scene which the session should be created for */
  42632. scene: Scene;
  42633. private _referenceSpace;
  42634. private _rttProvider;
  42635. private _sessionEnded;
  42636. private _xrNavigator;
  42637. private baseLayer;
  42638. /**
  42639. * The base reference space from which the session started. good if you want to reset your
  42640. * reference space
  42641. */
  42642. baseReferenceSpace: XRReferenceSpace;
  42643. /**
  42644. * Current XR frame
  42645. */
  42646. currentFrame: Nullable<XRFrame>;
  42647. /** WebXR timestamp updated every frame */
  42648. currentTimestamp: number;
  42649. /**
  42650. * Used just in case of a failure to initialize an immersive session.
  42651. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42652. */
  42653. defaultHeightCompensation: number;
  42654. /**
  42655. * Fires every time a new xrFrame arrives which can be used to update the camera
  42656. */
  42657. onXRFrameObservable: Observable<XRFrame>;
  42658. /**
  42659. * Fires when the reference space changed
  42660. */
  42661. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42662. /**
  42663. * Fires when the xr session is ended either by the device or manually done
  42664. */
  42665. onXRSessionEnded: Observable<any>;
  42666. /**
  42667. * Fires when the xr session is ended either by the device or manually done
  42668. */
  42669. onXRSessionInit: Observable<XRSession>;
  42670. /**
  42671. * Underlying xr session
  42672. */
  42673. session: XRSession;
  42674. /**
  42675. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42676. * or get the offset the player is currently at.
  42677. */
  42678. viewerReferenceSpace: XRReferenceSpace;
  42679. /**
  42680. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42681. * @param scene The scene which the session should be created for
  42682. */
  42683. constructor(
  42684. /** The scene which the session should be created for */
  42685. scene: Scene);
  42686. /**
  42687. * The current reference space used in this session. This reference space can constantly change!
  42688. * It is mainly used to offset the camera's position.
  42689. */
  42690. get referenceSpace(): XRReferenceSpace;
  42691. /**
  42692. * Set a new reference space and triggers the observable
  42693. */
  42694. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42695. /**
  42696. * Disposes of the session manager
  42697. */
  42698. dispose(): void;
  42699. /**
  42700. * Stops the xrSession and restores the render loop
  42701. * @returns Promise which resolves after it exits XR
  42702. */
  42703. exitXRAsync(): Promise<void>;
  42704. /**
  42705. * Gets the correct render target texture to be rendered this frame for this eye
  42706. * @param eye the eye for which to get the render target
  42707. * @returns the render target for the specified eye
  42708. */
  42709. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42710. /**
  42711. * Creates a WebXRRenderTarget object for the XR session
  42712. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42713. * @param options optional options to provide when creating a new render target
  42714. * @returns a WebXR render target to which the session can render
  42715. */
  42716. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42717. /**
  42718. * Initializes the manager
  42719. * After initialization enterXR can be called to start an XR session
  42720. * @returns Promise which resolves after it is initialized
  42721. */
  42722. initializeAsync(): Promise<void>;
  42723. /**
  42724. * Initializes an xr session
  42725. * @param xrSessionMode mode to initialize
  42726. * @param xrSessionInit defines optional and required values to pass to the session builder
  42727. * @returns a promise which will resolve once the session has been initialized
  42728. */
  42729. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42730. /**
  42731. * Checks if a session would be supported for the creation options specified
  42732. * @param sessionMode session mode to check if supported eg. immersive-vr
  42733. * @returns A Promise that resolves to true if supported and false if not
  42734. */
  42735. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42736. /**
  42737. * Resets the reference space to the one started the session
  42738. */
  42739. resetReferenceSpace(): void;
  42740. /**
  42741. * Starts rendering to the xr layer
  42742. */
  42743. runXRRenderLoop(): void;
  42744. /**
  42745. * Sets the reference space on the xr session
  42746. * @param referenceSpaceType space to set
  42747. * @returns a promise that will resolve once the reference space has been set
  42748. */
  42749. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42750. /**
  42751. * Updates the render state of the session
  42752. * @param state state to set
  42753. * @returns a promise that resolves once the render state has been updated
  42754. */
  42755. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42756. /**
  42757. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42758. * @param sessionMode defines the session to test
  42759. * @returns a promise with boolean as final value
  42760. */
  42761. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42762. private _createRenderTargetTexture;
  42763. }
  42764. }
  42765. declare module BABYLON {
  42766. /**
  42767. * WebXR Camera which holds the views for the xrSession
  42768. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42769. */
  42770. export class WebXRCamera extends FreeCamera {
  42771. private _xrSessionManager;
  42772. private _firstFrame;
  42773. private _referenceQuaternion;
  42774. private _referencedPosition;
  42775. private _xrInvPositionCache;
  42776. private _xrInvQuaternionCache;
  42777. /**
  42778. * Should position compensation execute on first frame.
  42779. * This is used when copying the position from a native (non XR) camera
  42780. */
  42781. compensateOnFirstFrame: boolean;
  42782. /**
  42783. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42784. * @param name the name of the camera
  42785. * @param scene the scene to add the camera to
  42786. * @param _xrSessionManager a constructed xr session manager
  42787. */
  42788. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42789. /**
  42790. * Return the user's height, unrelated to the current ground.
  42791. * This will be the y position of this camera, when ground level is 0.
  42792. */
  42793. get realWorldHeight(): number;
  42794. /** @hidden */
  42795. _updateForDualEyeDebugging(): void;
  42796. /**
  42797. * Sets this camera's transformation based on a non-vr camera
  42798. * @param otherCamera the non-vr camera to copy the transformation from
  42799. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42800. */
  42801. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42802. /**
  42803. * Gets the current instance class name ("WebXRCamera").
  42804. * @returns the class name
  42805. */
  42806. getClassName(): string;
  42807. private _updateFromXRSession;
  42808. private _updateNumberOfRigCameras;
  42809. private _updateReferenceSpace;
  42810. private _updateReferenceSpaceOffset;
  42811. }
  42812. }
  42813. declare module BABYLON {
  42814. /**
  42815. * Defining the interface required for a (webxr) feature
  42816. */
  42817. export interface IWebXRFeature extends IDisposable {
  42818. /**
  42819. * Is this feature attached
  42820. */
  42821. attached: boolean;
  42822. /**
  42823. * Should auto-attach be disabled?
  42824. */
  42825. disableAutoAttach: boolean;
  42826. /**
  42827. * Attach the feature to the session
  42828. * Will usually be called by the features manager
  42829. *
  42830. * @param force should attachment be forced (even when already attached)
  42831. * @returns true if successful.
  42832. */
  42833. attach(force?: boolean): boolean;
  42834. /**
  42835. * Detach the feature from the session
  42836. * Will usually be called by the features manager
  42837. *
  42838. * @returns true if successful.
  42839. */
  42840. detach(): boolean;
  42841. }
  42842. /**
  42843. * A list of the currently available features without referencing them
  42844. */
  42845. export class WebXRFeatureName {
  42846. /**
  42847. * The name of the anchor system feature
  42848. */
  42849. static ANCHOR_SYSTEM: string;
  42850. /**
  42851. * The name of the background remover feature
  42852. */
  42853. static BACKGROUND_REMOVER: string;
  42854. /**
  42855. * The name of the hit test feature
  42856. */
  42857. static HIT_TEST: string;
  42858. /**
  42859. * physics impostors for xr controllers feature
  42860. */
  42861. static PHYSICS_CONTROLLERS: string;
  42862. /**
  42863. * The name of the plane detection feature
  42864. */
  42865. static PLANE_DETECTION: string;
  42866. /**
  42867. * The name of the pointer selection feature
  42868. */
  42869. static POINTER_SELECTION: string;
  42870. /**
  42871. * The name of the teleportation feature
  42872. */
  42873. static TELEPORTATION: string;
  42874. }
  42875. /**
  42876. * Defining the constructor of a feature. Used to register the modules.
  42877. */
  42878. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42879. /**
  42880. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42881. * It is mainly used in AR sessions.
  42882. *
  42883. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42884. */
  42885. export class WebXRFeaturesManager implements IDisposable {
  42886. private _xrSessionManager;
  42887. private static readonly _AvailableFeatures;
  42888. private _features;
  42889. /**
  42890. * constructs a new features manages.
  42891. *
  42892. * @param _xrSessionManager an instance of WebXRSessionManager
  42893. */
  42894. constructor(_xrSessionManager: WebXRSessionManager);
  42895. /**
  42896. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42897. * Mainly used internally.
  42898. *
  42899. * @param featureName the name of the feature to register
  42900. * @param constructorFunction the function used to construct the module
  42901. * @param version the (babylon) version of the module
  42902. * @param stable is that a stable version of this module
  42903. */
  42904. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42905. /**
  42906. * Returns a constructor of a specific feature.
  42907. *
  42908. * @param featureName the name of the feature to construct
  42909. * @param version the version of the feature to load
  42910. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42911. * @param options optional options provided to the module.
  42912. * @returns a function that, when called, will return a new instance of this feature
  42913. */
  42914. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42915. /**
  42916. * Can be used to return the list of features currently registered
  42917. *
  42918. * @returns an Array of available features
  42919. */
  42920. static GetAvailableFeatures(): string[];
  42921. /**
  42922. * Gets the versions available for a specific feature
  42923. * @param featureName the name of the feature
  42924. * @returns an array with the available versions
  42925. */
  42926. static GetAvailableVersions(featureName: string): string[];
  42927. /**
  42928. * Return the latest unstable version of this feature
  42929. * @param featureName the name of the feature to search
  42930. * @returns the version number. if not found will return -1
  42931. */
  42932. static GetLatestVersionOfFeature(featureName: string): number;
  42933. /**
  42934. * Return the latest stable version of this feature
  42935. * @param featureName the name of the feature to search
  42936. * @returns the version number. if not found will return -1
  42937. */
  42938. static GetStableVersionOfFeature(featureName: string): number;
  42939. /**
  42940. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42941. * Can be used during a session to start a feature
  42942. * @param featureName the name of feature to attach
  42943. */
  42944. attachFeature(featureName: string): void;
  42945. /**
  42946. * Can be used inside a session or when the session ends to detach a specific feature
  42947. * @param featureName the name of the feature to detach
  42948. */
  42949. detachFeature(featureName: string): void;
  42950. /**
  42951. * Used to disable an already-enabled feature
  42952. * The feature will be disposed and will be recreated once enabled.
  42953. * @param featureName the feature to disable
  42954. * @returns true if disable was successful
  42955. */
  42956. disableFeature(featureName: string | {
  42957. Name: string;
  42958. }): boolean;
  42959. /**
  42960. * dispose this features manager
  42961. */
  42962. dispose(): void;
  42963. /**
  42964. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  42965. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  42966. *
  42967. * @param featureName the name of the feature to load or the class of the feature
  42968. * @param version optional version to load. if not provided the latest version will be enabled
  42969. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42970. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42971. * @returns a new constructed feature or throws an error if feature not found.
  42972. */
  42973. enableFeature(featureName: string | {
  42974. Name: string;
  42975. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42976. /**
  42977. * get the implementation of an enabled feature.
  42978. * @param featureName the name of the feature to load
  42979. * @returns the feature class, if found
  42980. */
  42981. getEnabledFeature(featureName: string): IWebXRFeature;
  42982. /**
  42983. * Get the list of enabled features
  42984. * @returns an array of enabled features
  42985. */
  42986. getEnabledFeatures(): string[];
  42987. }
  42988. }
  42989. declare module BABYLON {
  42990. /**
  42991. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  42992. * @see https://doc.babylonjs.com/how_to/webxr
  42993. */
  42994. export class WebXRExperienceHelper implements IDisposable {
  42995. private scene;
  42996. private _nonVRCamera;
  42997. private _originalSceneAutoClear;
  42998. private _supported;
  42999. /**
  43000. * Camera used to render xr content
  43001. */
  43002. camera: WebXRCamera;
  43003. /** A features manager for this xr session */
  43004. featuresManager: WebXRFeaturesManager;
  43005. /**
  43006. * Observers registered here will be triggered after the camera's initial transformation is set
  43007. * This can be used to set a different ground level or an extra rotation.
  43008. *
  43009. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43010. * to the position set after this observable is done executing.
  43011. */
  43012. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43013. /**
  43014. * Fires when the state of the experience helper has changed
  43015. */
  43016. onStateChangedObservable: Observable<WebXRState>;
  43017. /** Session manager used to keep track of xr session */
  43018. sessionManager: WebXRSessionManager;
  43019. /**
  43020. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43021. */
  43022. state: WebXRState;
  43023. /**
  43024. * Creates a WebXRExperienceHelper
  43025. * @param scene The scene the helper should be created in
  43026. */
  43027. private constructor();
  43028. /**
  43029. * Creates the experience helper
  43030. * @param scene the scene to attach the experience helper to
  43031. * @returns a promise for the experience helper
  43032. */
  43033. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43034. /**
  43035. * Disposes of the experience helper
  43036. */
  43037. dispose(): void;
  43038. /**
  43039. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43040. * @param sessionMode options for the XR session
  43041. * @param referenceSpaceType frame of reference of the XR session
  43042. * @param renderTarget the output canvas that will be used to enter XR mode
  43043. * @returns promise that resolves after xr mode has entered
  43044. */
  43045. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43046. /**
  43047. * Exits XR mode and returns the scene to its original state
  43048. * @returns promise that resolves after xr mode has exited
  43049. */
  43050. exitXRAsync(): Promise<void>;
  43051. private _nonXRToXRCamera;
  43052. private _setState;
  43053. }
  43054. }
  43055. declare module BABYLON {
  43056. /**
  43057. * X-Y values for axes in WebXR
  43058. */
  43059. export interface IWebXRMotionControllerAxesValue {
  43060. /**
  43061. * The value of the x axis
  43062. */
  43063. x: number;
  43064. /**
  43065. * The value of the y-axis
  43066. */
  43067. y: number;
  43068. }
  43069. /**
  43070. * changed / previous values for the values of this component
  43071. */
  43072. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43073. /**
  43074. * current (this frame) value
  43075. */
  43076. current: T;
  43077. /**
  43078. * previous (last change) value
  43079. */
  43080. previous: T;
  43081. }
  43082. /**
  43083. * Represents changes in the component between current frame and last values recorded
  43084. */
  43085. export interface IWebXRMotionControllerComponentChanges {
  43086. /**
  43087. * will be populated with previous and current values if axes changed
  43088. */
  43089. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43090. /**
  43091. * will be populated with previous and current values if pressed changed
  43092. */
  43093. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43094. /**
  43095. * will be populated with previous and current values if touched changed
  43096. */
  43097. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43098. /**
  43099. * will be populated with previous and current values if value changed
  43100. */
  43101. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43102. }
  43103. /**
  43104. * This class represents a single component (for example button or thumbstick) of a motion controller
  43105. */
  43106. export class WebXRControllerComponent implements IDisposable {
  43107. /**
  43108. * the id of this component
  43109. */
  43110. id: string;
  43111. /**
  43112. * the type of the component
  43113. */
  43114. type: MotionControllerComponentType;
  43115. private _buttonIndex;
  43116. private _axesIndices;
  43117. private _axes;
  43118. private _changes;
  43119. private _currentValue;
  43120. private _hasChanges;
  43121. private _pressed;
  43122. private _touched;
  43123. /**
  43124. * button component type
  43125. */
  43126. static BUTTON_TYPE: MotionControllerComponentType;
  43127. /**
  43128. * squeeze component type
  43129. */
  43130. static SQUEEZE_TYPE: MotionControllerComponentType;
  43131. /**
  43132. * Thumbstick component type
  43133. */
  43134. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43135. /**
  43136. * Touchpad component type
  43137. */
  43138. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43139. /**
  43140. * trigger component type
  43141. */
  43142. static TRIGGER_TYPE: MotionControllerComponentType;
  43143. /**
  43144. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43145. * the axes data changes
  43146. */
  43147. onAxisValueChangedObservable: Observable<{
  43148. x: number;
  43149. y: number;
  43150. }>;
  43151. /**
  43152. * Observers registered here will be triggered when the state of a button changes
  43153. * State change is either pressed / touched / value
  43154. */
  43155. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43156. /**
  43157. * Creates a new component for a motion controller.
  43158. * It is created by the motion controller itself
  43159. *
  43160. * @param id the id of this component
  43161. * @param type the type of the component
  43162. * @param _buttonIndex index in the buttons array of the gamepad
  43163. * @param _axesIndices indices of the values in the axes array of the gamepad
  43164. */
  43165. constructor(
  43166. /**
  43167. * the id of this component
  43168. */
  43169. id: string,
  43170. /**
  43171. * the type of the component
  43172. */
  43173. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43174. /**
  43175. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43176. */
  43177. get axes(): IWebXRMotionControllerAxesValue;
  43178. /**
  43179. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43180. */
  43181. get changes(): IWebXRMotionControllerComponentChanges;
  43182. /**
  43183. * Return whether or not the component changed the last frame
  43184. */
  43185. get hasChanges(): boolean;
  43186. /**
  43187. * is the button currently pressed
  43188. */
  43189. get pressed(): boolean;
  43190. /**
  43191. * is the button currently touched
  43192. */
  43193. get touched(): boolean;
  43194. /**
  43195. * Get the current value of this component
  43196. */
  43197. get value(): number;
  43198. /**
  43199. * Dispose this component
  43200. */
  43201. dispose(): void;
  43202. /**
  43203. * Are there axes correlating to this component
  43204. * @return true is axes data is available
  43205. */
  43206. isAxes(): boolean;
  43207. /**
  43208. * Is this component a button (hence - pressable)
  43209. * @returns true if can be pressed
  43210. */
  43211. isButton(): boolean;
  43212. /**
  43213. * update this component using the gamepad object it is in. Called on every frame
  43214. * @param nativeController the native gamepad controller object
  43215. */
  43216. update(nativeController: IMinimalMotionControllerObject): void;
  43217. }
  43218. }
  43219. declare module BABYLON {
  43220. /**
  43221. * Class used to represent data loading progression
  43222. */
  43223. export class SceneLoaderProgressEvent {
  43224. /** defines if data length to load can be evaluated */
  43225. readonly lengthComputable: boolean;
  43226. /** defines the loaded data length */
  43227. readonly loaded: number;
  43228. /** defines the data length to load */
  43229. readonly total: number;
  43230. /**
  43231. * Create a new progress event
  43232. * @param lengthComputable defines if data length to load can be evaluated
  43233. * @param loaded defines the loaded data length
  43234. * @param total defines the data length to load
  43235. */
  43236. constructor(
  43237. /** defines if data length to load can be evaluated */
  43238. lengthComputable: boolean,
  43239. /** defines the loaded data length */
  43240. loaded: number,
  43241. /** defines the data length to load */
  43242. total: number);
  43243. /**
  43244. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43245. * @param event defines the source event
  43246. * @returns a new SceneLoaderProgressEvent
  43247. */
  43248. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43249. }
  43250. /**
  43251. * Interface used by SceneLoader plugins to define supported file extensions
  43252. */
  43253. export interface ISceneLoaderPluginExtensions {
  43254. /**
  43255. * Defines the list of supported extensions
  43256. */
  43257. [extension: string]: {
  43258. isBinary: boolean;
  43259. };
  43260. }
  43261. /**
  43262. * Interface used by SceneLoader plugin factory
  43263. */
  43264. export interface ISceneLoaderPluginFactory {
  43265. /**
  43266. * Defines the name of the factory
  43267. */
  43268. name: string;
  43269. /**
  43270. * Function called to create a new plugin
  43271. * @return the new plugin
  43272. */
  43273. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43274. /**
  43275. * The callback that returns true if the data can be directly loaded.
  43276. * @param data string containing the file data
  43277. * @returns if the data can be loaded directly
  43278. */
  43279. canDirectLoad?(data: string): boolean;
  43280. }
  43281. /**
  43282. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43283. */
  43284. export interface ISceneLoaderPluginBase {
  43285. /**
  43286. * The friendly name of this plugin.
  43287. */
  43288. name: string;
  43289. /**
  43290. * The file extensions supported by this plugin.
  43291. */
  43292. extensions: string | ISceneLoaderPluginExtensions;
  43293. /**
  43294. * The callback called when loading from a url.
  43295. * @param scene scene loading this url
  43296. * @param url url to load
  43297. * @param onSuccess callback called when the file successfully loads
  43298. * @param onProgress callback called while file is loading (if the server supports this mode)
  43299. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43300. * @param onError callback called when the file fails to load
  43301. * @returns a file request object
  43302. */
  43303. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43304. /**
  43305. * The callback called when loading from a file object.
  43306. * @param scene scene loading this file
  43307. * @param file defines the file to load
  43308. * @param onSuccess defines the callback to call when data is loaded
  43309. * @param onProgress defines the callback to call during loading process
  43310. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43311. * @param onError defines the callback to call when an error occurs
  43312. * @returns a file request object
  43313. */
  43314. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43315. /**
  43316. * The callback that returns true if the data can be directly loaded.
  43317. * @param data string containing the file data
  43318. * @returns if the data can be loaded directly
  43319. */
  43320. canDirectLoad?(data: string): boolean;
  43321. /**
  43322. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43323. * @param scene scene loading this data
  43324. * @param data string containing the data
  43325. * @returns data to pass to the plugin
  43326. */
  43327. directLoad?(scene: Scene, data: string): any;
  43328. /**
  43329. * The callback that allows custom handling of the root url based on the response url.
  43330. * @param rootUrl the original root url
  43331. * @param responseURL the response url if available
  43332. * @returns the new root url
  43333. */
  43334. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43335. }
  43336. /**
  43337. * Interface used to define a SceneLoader plugin
  43338. */
  43339. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43340. /**
  43341. * Import meshes into a scene.
  43342. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43343. * @param scene The scene to import into
  43344. * @param data The data to import
  43345. * @param rootUrl The root url for scene and resources
  43346. * @param meshes The meshes array to import into
  43347. * @param particleSystems The particle systems array to import into
  43348. * @param skeletons The skeletons array to import into
  43349. * @param onError The callback when import fails
  43350. * @returns True if successful or false otherwise
  43351. */
  43352. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43353. /**
  43354. * Load into a scene.
  43355. * @param scene The scene to load into
  43356. * @param data The data to import
  43357. * @param rootUrl The root url for scene and resources
  43358. * @param onError The callback when import fails
  43359. * @returns True if successful or false otherwise
  43360. */
  43361. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43362. /**
  43363. * Load into an asset container.
  43364. * @param scene The scene to load into
  43365. * @param data The data to import
  43366. * @param rootUrl The root url for scene and resources
  43367. * @param onError The callback when import fails
  43368. * @returns The loaded asset container
  43369. */
  43370. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43371. }
  43372. /**
  43373. * Interface used to define an async SceneLoader plugin
  43374. */
  43375. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43376. /**
  43377. * Import meshes into a scene.
  43378. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43379. * @param scene The scene to import into
  43380. * @param data The data to import
  43381. * @param rootUrl The root url for scene and resources
  43382. * @param onProgress The callback when the load progresses
  43383. * @param fileName Defines the name of the file to load
  43384. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43385. */
  43386. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43387. meshes: AbstractMesh[];
  43388. particleSystems: IParticleSystem[];
  43389. skeletons: Skeleton[];
  43390. animationGroups: AnimationGroup[];
  43391. }>;
  43392. /**
  43393. * Load into a scene.
  43394. * @param scene The scene to load into
  43395. * @param data The data to import
  43396. * @param rootUrl The root url for scene and resources
  43397. * @param onProgress The callback when the load progresses
  43398. * @param fileName Defines the name of the file to load
  43399. * @returns Nothing
  43400. */
  43401. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43402. /**
  43403. * Load into an asset container.
  43404. * @param scene The scene to load into
  43405. * @param data The data to import
  43406. * @param rootUrl The root url for scene and resources
  43407. * @param onProgress The callback when the load progresses
  43408. * @param fileName Defines the name of the file to load
  43409. * @returns The loaded asset container
  43410. */
  43411. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43412. }
  43413. /**
  43414. * Mode that determines how to handle old animation groups before loading new ones.
  43415. */
  43416. export enum SceneLoaderAnimationGroupLoadingMode {
  43417. /**
  43418. * Reset all old animations to initial state then dispose them.
  43419. */
  43420. Clean = 0,
  43421. /**
  43422. * Stop all old animations.
  43423. */
  43424. Stop = 1,
  43425. /**
  43426. * Restart old animations from first frame.
  43427. */
  43428. Sync = 2,
  43429. /**
  43430. * Old animations remains untouched.
  43431. */
  43432. NoSync = 3
  43433. }
  43434. /**
  43435. * Class used to load scene from various file formats using registered plugins
  43436. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43437. */
  43438. export class SceneLoader {
  43439. /**
  43440. * No logging while loading
  43441. */
  43442. static readonly NO_LOGGING: number;
  43443. /**
  43444. * Minimal logging while loading
  43445. */
  43446. static readonly MINIMAL_LOGGING: number;
  43447. /**
  43448. * Summary logging while loading
  43449. */
  43450. static readonly SUMMARY_LOGGING: number;
  43451. /**
  43452. * Detailled logging while loading
  43453. */
  43454. static readonly DETAILED_LOGGING: number;
  43455. /**
  43456. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43457. */
  43458. static get ForceFullSceneLoadingForIncremental(): boolean;
  43459. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43460. /**
  43461. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43462. */
  43463. static get ShowLoadingScreen(): boolean;
  43464. static set ShowLoadingScreen(value: boolean);
  43465. /**
  43466. * Defines the current logging level (while loading the scene)
  43467. * @ignorenaming
  43468. */
  43469. static get loggingLevel(): number;
  43470. static set loggingLevel(value: number);
  43471. /**
  43472. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43473. */
  43474. static get CleanBoneMatrixWeights(): boolean;
  43475. static set CleanBoneMatrixWeights(value: boolean);
  43476. /**
  43477. * Event raised when a plugin is used to load a scene
  43478. */
  43479. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43480. private static _registeredPlugins;
  43481. private static _getDefaultPlugin;
  43482. private static _getPluginForExtension;
  43483. private static _getPluginForDirectLoad;
  43484. private static _getPluginForFilename;
  43485. private static _getDirectLoad;
  43486. private static _loadData;
  43487. private static _getFileInfo;
  43488. /**
  43489. * Gets a plugin that can load the given extension
  43490. * @param extension defines the extension to load
  43491. * @returns a plugin or null if none works
  43492. */
  43493. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43494. /**
  43495. * Gets a boolean indicating that the given extension can be loaded
  43496. * @param extension defines the extension to load
  43497. * @returns true if the extension is supported
  43498. */
  43499. static IsPluginForExtensionAvailable(extension: string): boolean;
  43500. /**
  43501. * Adds a new plugin to the list of registered plugins
  43502. * @param plugin defines the plugin to add
  43503. */
  43504. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43505. /**
  43506. * Import meshes into a scene
  43507. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43508. * @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)
  43509. * @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)
  43510. * @param scene the instance of BABYLON.Scene to append to
  43511. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43512. * @param onProgress a callback with a progress event for each file being loaded
  43513. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43514. * @param pluginExtension the extension used to determine the plugin
  43515. * @returns The loaded plugin
  43516. */
  43517. 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>;
  43518. /**
  43519. * Import meshes into a scene
  43520. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43521. * @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)
  43522. * @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)
  43523. * @param scene the instance of BABYLON.Scene to append to
  43524. * @param onProgress a callback with a progress event for each file being loaded
  43525. * @param pluginExtension the extension used to determine the plugin
  43526. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43527. */
  43528. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43529. meshes: AbstractMesh[];
  43530. particleSystems: IParticleSystem[];
  43531. skeletons: Skeleton[];
  43532. animationGroups: AnimationGroup[];
  43533. }>;
  43534. /**
  43535. * Load a scene
  43536. * @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)
  43537. * @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)
  43538. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43539. * @param onSuccess a callback with the scene when import succeeds
  43540. * @param onProgress a callback with a progress event for each file being loaded
  43541. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43542. * @param pluginExtension the extension used to determine the plugin
  43543. * @returns The loaded plugin
  43544. */
  43545. 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>;
  43546. /**
  43547. * Load a scene
  43548. * @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)
  43549. * @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)
  43550. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43551. * @param onProgress a callback with a progress event for each file being loaded
  43552. * @param pluginExtension the extension used to determine the plugin
  43553. * @returns The loaded scene
  43554. */
  43555. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43556. /**
  43557. * Append a scene
  43558. * @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)
  43559. * @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)
  43560. * @param scene is the instance of BABYLON.Scene to append to
  43561. * @param onSuccess a callback with the scene when import succeeds
  43562. * @param onProgress a callback with a progress event for each file being loaded
  43563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43564. * @param pluginExtension the extension used to determine the plugin
  43565. * @returns The loaded plugin
  43566. */
  43567. 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>;
  43568. /**
  43569. * Append a scene
  43570. * @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)
  43571. * @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)
  43572. * @param scene is the instance of BABYLON.Scene to append to
  43573. * @param onProgress a callback with a progress event for each file being loaded
  43574. * @param pluginExtension the extension used to determine the plugin
  43575. * @returns The given scene
  43576. */
  43577. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43578. /**
  43579. * Load a scene into an asset container
  43580. * @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)
  43581. * @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)
  43582. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43583. * @param onSuccess a callback with the scene when import succeeds
  43584. * @param onProgress a callback with a progress event for each file being loaded
  43585. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43586. * @param pluginExtension the extension used to determine the plugin
  43587. * @returns The loaded plugin
  43588. */
  43589. 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>;
  43590. /**
  43591. * Load a scene into an asset container
  43592. * @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)
  43593. * @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)
  43594. * @param scene is the instance of Scene to append to
  43595. * @param onProgress a callback with a progress event for each file being loaded
  43596. * @param pluginExtension the extension used to determine the plugin
  43597. * @returns The loaded asset container
  43598. */
  43599. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43600. /**
  43601. * Import animations from a file into a scene
  43602. * @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)
  43603. * @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)
  43604. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43605. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43606. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43607. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43608. * @param onSuccess a callback with the scene when import succeeds
  43609. * @param onProgress a callback with a progress event for each file being loaded
  43610. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43611. */
  43612. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  43613. /**
  43614. * Import animations from a file into a scene
  43615. * @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)
  43616. * @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)
  43617. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43618. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43619. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43620. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43621. * @param onSuccess a callback with the scene when import succeeds
  43622. * @param onProgress a callback with a progress event for each file being loaded
  43623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43624. * @returns the updated scene with imported animations
  43625. */
  43626. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  43627. }
  43628. }
  43629. declare module BABYLON {
  43630. /**
  43631. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43632. */
  43633. export type MotionControllerHandness = "none" | "left" | "right";
  43634. /**
  43635. * The type of components available in motion controllers.
  43636. * This is not the name of the component.
  43637. */
  43638. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43639. /**
  43640. * The state of a controller component
  43641. */
  43642. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43643. /**
  43644. * The schema of motion controller layout.
  43645. * No object will be initialized using this interface
  43646. * This is used just to define the profile.
  43647. */
  43648. export interface IMotionControllerLayout {
  43649. /**
  43650. * Path to load the assets. Usually relative to the base path
  43651. */
  43652. assetPath: string;
  43653. /**
  43654. * Available components (unsorted)
  43655. */
  43656. components: {
  43657. /**
  43658. * A map of component Ids
  43659. */
  43660. [componentId: string]: {
  43661. /**
  43662. * The type of input the component outputs
  43663. */
  43664. type: MotionControllerComponentType;
  43665. /**
  43666. * The indices of this component in the gamepad object
  43667. */
  43668. gamepadIndices: {
  43669. /**
  43670. * Index of button
  43671. */
  43672. button?: number;
  43673. /**
  43674. * If available, index of x-axis
  43675. */
  43676. xAxis?: number;
  43677. /**
  43678. * If available, index of y-axis
  43679. */
  43680. yAxis?: number;
  43681. };
  43682. /**
  43683. * The mesh's root node name
  43684. */
  43685. rootNodeName: string;
  43686. /**
  43687. * Animation definitions for this model
  43688. */
  43689. visualResponses: {
  43690. [stateKey: string]: {
  43691. /**
  43692. * What property will be animated
  43693. */
  43694. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43695. /**
  43696. * What states influence this visual response
  43697. */
  43698. states: MotionControllerComponentStateType[];
  43699. /**
  43700. * Type of animation - movement or visibility
  43701. */
  43702. valueNodeProperty: "transform" | "visibility";
  43703. /**
  43704. * Base node name to move. Its position will be calculated according to the min and max nodes
  43705. */
  43706. valueNodeName?: string;
  43707. /**
  43708. * Minimum movement node
  43709. */
  43710. minNodeName?: string;
  43711. /**
  43712. * Max movement node
  43713. */
  43714. maxNodeName?: string;
  43715. };
  43716. };
  43717. /**
  43718. * If touch enabled, what is the name of node to display user feedback
  43719. */
  43720. touchPointNodeName?: string;
  43721. };
  43722. };
  43723. /**
  43724. * Is it xr standard mapping or not
  43725. */
  43726. gamepadMapping: "" | "xr-standard";
  43727. /**
  43728. * Base root node of this entire model
  43729. */
  43730. rootNodeName: string;
  43731. /**
  43732. * Defines the main button component id
  43733. */
  43734. selectComponentId: string;
  43735. }
  43736. /**
  43737. * A definition for the layout map in the input profile
  43738. */
  43739. export interface IMotionControllerLayoutMap {
  43740. /**
  43741. * Layouts with handness type as a key
  43742. */
  43743. [handness: string]: IMotionControllerLayout;
  43744. }
  43745. /**
  43746. * The XR Input profile schema
  43747. * Profiles can be found here:
  43748. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43749. */
  43750. export interface IMotionControllerProfile {
  43751. /**
  43752. * fallback profiles for this profileId
  43753. */
  43754. fallbackProfileIds: string[];
  43755. /**
  43756. * The layout map, with handness as key
  43757. */
  43758. layouts: IMotionControllerLayoutMap;
  43759. /**
  43760. * The id of this profile
  43761. * correlates to the profile(s) in the xrInput.profiles array
  43762. */
  43763. profileId: string;
  43764. }
  43765. /**
  43766. * A helper-interface for the 3 meshes needed for controller button animation
  43767. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43768. */
  43769. export interface IMotionControllerButtonMeshMap {
  43770. /**
  43771. * the mesh that defines the pressed value mesh position.
  43772. * This is used to find the max-position of this button
  43773. */
  43774. pressedMesh: AbstractMesh;
  43775. /**
  43776. * the mesh that defines the unpressed value mesh position.
  43777. * This is used to find the min (or initial) position of this button
  43778. */
  43779. unpressedMesh: AbstractMesh;
  43780. /**
  43781. * The mesh that will be changed when value changes
  43782. */
  43783. valueMesh: AbstractMesh;
  43784. }
  43785. /**
  43786. * A helper-interface for the 3 meshes needed for controller axis animation.
  43787. * This will be expanded when touchpad animations are fully supported
  43788. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43789. */
  43790. export interface IMotionControllerMeshMap {
  43791. /**
  43792. * the mesh that defines the maximum value mesh position.
  43793. */
  43794. maxMesh?: AbstractMesh;
  43795. /**
  43796. * the mesh that defines the minimum value mesh position.
  43797. */
  43798. minMesh?: AbstractMesh;
  43799. /**
  43800. * The mesh that will be changed when axis value changes
  43801. */
  43802. valueMesh: AbstractMesh;
  43803. }
  43804. /**
  43805. * The elements needed for change-detection of the gamepad objects in motion controllers
  43806. */
  43807. export interface IMinimalMotionControllerObject {
  43808. /**
  43809. * Available axes of this controller
  43810. */
  43811. axes: number[];
  43812. /**
  43813. * An array of available buttons
  43814. */
  43815. buttons: Array<{
  43816. /**
  43817. * Value of the button/trigger
  43818. */
  43819. value: number;
  43820. /**
  43821. * If the button/trigger is currently touched
  43822. */
  43823. touched: boolean;
  43824. /**
  43825. * If the button/trigger is currently pressed
  43826. */
  43827. pressed: boolean;
  43828. }>;
  43829. }
  43830. /**
  43831. * An Abstract Motion controller
  43832. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43833. * Each component has an observable to check for changes in value and state
  43834. */
  43835. export abstract class WebXRAbstractMotionController implements IDisposable {
  43836. protected scene: Scene;
  43837. protected layout: IMotionControllerLayout;
  43838. /**
  43839. * The gamepad object correlating to this controller
  43840. */
  43841. gamepadObject: IMinimalMotionControllerObject;
  43842. /**
  43843. * handness (left/right/none) of this controller
  43844. */
  43845. handness: MotionControllerHandness;
  43846. private _initComponent;
  43847. private _modelReady;
  43848. /**
  43849. * A map of components (WebXRControllerComponent) in this motion controller
  43850. * Components have a ComponentType and can also have both button and axis definitions
  43851. */
  43852. readonly components: {
  43853. [id: string]: WebXRControllerComponent;
  43854. };
  43855. /**
  43856. * Disable the model's animation. Can be set at any time.
  43857. */
  43858. disableAnimation: boolean;
  43859. /**
  43860. * Observers registered here will be triggered when the model of this controller is done loading
  43861. */
  43862. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43863. /**
  43864. * The profile id of this motion controller
  43865. */
  43866. abstract profileId: string;
  43867. /**
  43868. * The root mesh of the model. It is null if the model was not yet initialized
  43869. */
  43870. rootMesh: Nullable<AbstractMesh>;
  43871. /**
  43872. * constructs a new abstract motion controller
  43873. * @param scene the scene to which the model of the controller will be added
  43874. * @param layout The profile layout to load
  43875. * @param gamepadObject The gamepad object correlating to this controller
  43876. * @param handness handness (left/right/none) of this controller
  43877. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43878. */
  43879. constructor(scene: Scene, layout: IMotionControllerLayout,
  43880. /**
  43881. * The gamepad object correlating to this controller
  43882. */
  43883. gamepadObject: IMinimalMotionControllerObject,
  43884. /**
  43885. * handness (left/right/none) of this controller
  43886. */
  43887. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43888. /**
  43889. * Dispose this controller, the model mesh and all its components
  43890. */
  43891. dispose(): void;
  43892. /**
  43893. * Returns all components of specific type
  43894. * @param type the type to search for
  43895. * @return an array of components with this type
  43896. */
  43897. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43898. /**
  43899. * get a component based an its component id as defined in layout.components
  43900. * @param id the id of the component
  43901. * @returns the component correlates to the id or undefined if not found
  43902. */
  43903. getComponent(id: string): WebXRControllerComponent;
  43904. /**
  43905. * Get the list of components available in this motion controller
  43906. * @returns an array of strings correlating to available components
  43907. */
  43908. getComponentIds(): string[];
  43909. /**
  43910. * Get the first component of specific type
  43911. * @param type type of component to find
  43912. * @return a controller component or null if not found
  43913. */
  43914. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43915. /**
  43916. * Get the main (Select) component of this controller as defined in the layout
  43917. * @returns the main component of this controller
  43918. */
  43919. getMainComponent(): WebXRControllerComponent;
  43920. /**
  43921. * Loads the model correlating to this controller
  43922. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43923. * @returns A promise fulfilled with the result of the model loading
  43924. */
  43925. loadModel(): Promise<boolean>;
  43926. /**
  43927. * Update this model using the current XRFrame
  43928. * @param xrFrame the current xr frame to use and update the model
  43929. */
  43930. updateFromXRFrame(xrFrame: XRFrame): void;
  43931. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43932. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43933. /**
  43934. * Moves the axis on the controller mesh based on its current state
  43935. * @param axis the index of the axis
  43936. * @param axisValue the value of the axis which determines the meshes new position
  43937. * @hidden
  43938. */
  43939. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43940. /**
  43941. * Update the model itself with the current frame data
  43942. * @param xrFrame the frame to use for updating the model mesh
  43943. */
  43944. protected updateModel(xrFrame: XRFrame): void;
  43945. /**
  43946. * Get the filename and path for this controller's model
  43947. * @returns a map of filename and path
  43948. */
  43949. protected abstract _getFilenameAndPath(): {
  43950. filename: string;
  43951. path: string;
  43952. };
  43953. /**
  43954. * This function is called before the mesh is loaded. It checks for loading constraints.
  43955. * For example, this function can check if the GLB loader is available
  43956. * If this function returns false, the generic controller will be loaded instead
  43957. * @returns Is the client ready to load the mesh
  43958. */
  43959. protected abstract _getModelLoadingConstraints(): boolean;
  43960. /**
  43961. * This function will be called after the model was successfully loaded and can be used
  43962. * for mesh transformations before it is available for the user
  43963. * @param meshes the loaded meshes
  43964. */
  43965. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43966. /**
  43967. * Set the root mesh for this controller. Important for the WebXR controller class
  43968. * @param meshes the loaded meshes
  43969. */
  43970. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43971. /**
  43972. * A function executed each frame that updates the mesh (if needed)
  43973. * @param xrFrame the current xrFrame
  43974. */
  43975. protected abstract _updateModel(xrFrame: XRFrame): void;
  43976. private _getGenericFilenameAndPath;
  43977. private _getGenericParentMesh;
  43978. }
  43979. }
  43980. declare module BABYLON {
  43981. /**
  43982. * A generic trigger-only motion controller for WebXR
  43983. */
  43984. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43985. /**
  43986. * Static version of the profile id of this controller
  43987. */
  43988. static ProfileId: string;
  43989. profileId: string;
  43990. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43991. protected _getFilenameAndPath(): {
  43992. filename: string;
  43993. path: string;
  43994. };
  43995. protected _getModelLoadingConstraints(): boolean;
  43996. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43997. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43998. protected _updateModel(): void;
  43999. }
  44000. }
  44001. declare module BABYLON {
  44002. /**
  44003. * Class containing static functions to help procedurally build meshes
  44004. */
  44005. export class SphereBuilder {
  44006. /**
  44007. * Creates a sphere mesh
  44008. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44009. * * 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`)
  44010. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44011. * * 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
  44012. * * 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)
  44013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44014. * * 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
  44015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44016. * @param name defines the name of the mesh
  44017. * @param options defines the options used to create the mesh
  44018. * @param scene defines the hosting scene
  44019. * @returns the sphere mesh
  44020. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44021. */
  44022. static CreateSphere(name: string, options: {
  44023. segments?: number;
  44024. diameter?: number;
  44025. diameterX?: number;
  44026. diameterY?: number;
  44027. diameterZ?: number;
  44028. arc?: number;
  44029. slice?: number;
  44030. sideOrientation?: number;
  44031. frontUVs?: Vector4;
  44032. backUVs?: Vector4;
  44033. updatable?: boolean;
  44034. }, scene?: Nullable<Scene>): Mesh;
  44035. }
  44036. }
  44037. declare module BABYLON {
  44038. /**
  44039. * A profiled motion controller has its profile loaded from an online repository.
  44040. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44041. */
  44042. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44043. private _repositoryUrl;
  44044. private _buttonMeshMapping;
  44045. private _touchDots;
  44046. /**
  44047. * The profile ID of this controller. Will be populated when the controller initializes.
  44048. */
  44049. profileId: string;
  44050. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44051. dispose(): void;
  44052. protected _getFilenameAndPath(): {
  44053. filename: string;
  44054. path: string;
  44055. };
  44056. protected _getModelLoadingConstraints(): boolean;
  44057. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44058. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44059. protected _updateModel(_xrFrame: XRFrame): void;
  44060. }
  44061. }
  44062. declare module BABYLON {
  44063. /**
  44064. * A construction function type to create a new controller based on an xrInput object
  44065. */
  44066. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44067. /**
  44068. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44069. *
  44070. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44071. * it should be replaced with auto-loaded controllers.
  44072. *
  44073. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44074. */
  44075. export class WebXRMotionControllerManager {
  44076. private static _AvailableControllers;
  44077. private static _Fallbacks;
  44078. private static _ProfileLoadingPromises;
  44079. private static _ProfilesList;
  44080. /**
  44081. * The base URL of the online controller repository. Can be changed at any time.
  44082. */
  44083. static BaseRepositoryUrl: string;
  44084. /**
  44085. * Which repository gets priority - local or online
  44086. */
  44087. static PrioritizeOnlineRepository: boolean;
  44088. /**
  44089. * Use the online repository, or use only locally-defined controllers
  44090. */
  44091. static UseOnlineRepository: boolean;
  44092. /**
  44093. * Clear the cache used for profile loading and reload when requested again
  44094. */
  44095. static ClearProfilesCache(): void;
  44096. /**
  44097. * Register the default fallbacks.
  44098. * This function is called automatically when this file is imported.
  44099. */
  44100. static DefaultFallbacks(): void;
  44101. /**
  44102. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44103. * @param profileId the profile to which a fallback needs to be found
  44104. * @return an array with corresponding fallback profiles
  44105. */
  44106. static FindFallbackWithProfileId(profileId: string): string[];
  44107. /**
  44108. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44109. * The order of search:
  44110. *
  44111. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44112. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44113. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44114. * 4) return the generic trigger controller if none were found
  44115. *
  44116. * @param xrInput the xrInput to which a new controller is initialized
  44117. * @param scene the scene to which the model will be added
  44118. * @param forceProfile force a certain profile for this controller
  44119. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44120. */
  44121. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44122. /**
  44123. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44124. *
  44125. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44126. *
  44127. * @param type the profile type to register
  44128. * @param constructFunction the function to be called when loading this profile
  44129. */
  44130. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44131. /**
  44132. * Register a fallback to a specific profile.
  44133. * @param profileId the profileId that will receive the fallbacks
  44134. * @param fallbacks A list of fallback profiles
  44135. */
  44136. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44137. /**
  44138. * Will update the list of profiles available in the repository
  44139. * @return a promise that resolves to a map of profiles available online
  44140. */
  44141. static UpdateProfilesList(): Promise<{
  44142. [profile: string]: string;
  44143. }>;
  44144. private static _LoadProfileFromRepository;
  44145. private static _LoadProfilesFromAvailableControllers;
  44146. }
  44147. }
  44148. declare module BABYLON {
  44149. /**
  44150. * Configuration options for the WebXR controller creation
  44151. */
  44152. export interface IWebXRControllerOptions {
  44153. /**
  44154. * Should the controller mesh be animated when a user interacts with it
  44155. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44156. */
  44157. disableMotionControllerAnimation?: boolean;
  44158. /**
  44159. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44160. */
  44161. doNotLoadControllerMesh?: boolean;
  44162. /**
  44163. * Force a specific controller type for this controller.
  44164. * This can be used when creating your own profile or when testing different controllers
  44165. */
  44166. forceControllerProfile?: string;
  44167. }
  44168. /**
  44169. * Represents an XR controller
  44170. */
  44171. export class WebXRInputSource {
  44172. private _scene;
  44173. /** The underlying input source for the controller */
  44174. inputSource: XRInputSource;
  44175. private _options;
  44176. private _tmpQuaternion;
  44177. private _tmpVector;
  44178. private _uniqueId;
  44179. /**
  44180. * 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
  44181. */
  44182. grip?: AbstractMesh;
  44183. /**
  44184. * If available, this is the gamepad object related to this controller.
  44185. * Using this object it is possible to get click events and trackpad changes of the
  44186. * webxr controller that is currently being used.
  44187. */
  44188. motionController?: WebXRAbstractMotionController;
  44189. /**
  44190. * Event that fires when the controller is removed/disposed.
  44191. * The object provided as event data is this controller, after associated assets were disposed.
  44192. * uniqueId is still available.
  44193. */
  44194. onDisposeObservable: Observable<WebXRInputSource>;
  44195. /**
  44196. * Will be triggered when the mesh associated with the motion controller is done loading.
  44197. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44198. * A shortened version of controller -> motion controller -> on mesh loaded.
  44199. */
  44200. onMeshLoadedObservable: Observable<AbstractMesh>;
  44201. /**
  44202. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44203. */
  44204. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44205. /**
  44206. * Pointer which can be used to select objects or attach a visible laser to
  44207. */
  44208. pointer: AbstractMesh;
  44209. /**
  44210. * Creates the controller
  44211. * @see https://doc.babylonjs.com/how_to/webxr
  44212. * @param _scene the scene which the controller should be associated to
  44213. * @param inputSource the underlying input source for the controller
  44214. * @param _options options for this controller creation
  44215. */
  44216. constructor(_scene: Scene,
  44217. /** The underlying input source for the controller */
  44218. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44219. /**
  44220. * Get this controllers unique id
  44221. */
  44222. get uniqueId(): string;
  44223. /**
  44224. * Disposes of the object
  44225. */
  44226. dispose(): void;
  44227. /**
  44228. * Gets a world space ray coming from the pointer or grip
  44229. * @param result the resulting ray
  44230. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44231. */
  44232. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44233. /**
  44234. * Updates the controller pose based on the given XRFrame
  44235. * @param xrFrame xr frame to update the pose with
  44236. * @param referenceSpace reference space to use
  44237. */
  44238. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44239. }
  44240. }
  44241. declare module BABYLON {
  44242. /**
  44243. * The schema for initialization options of the XR Input class
  44244. */
  44245. export interface IWebXRInputOptions {
  44246. /**
  44247. * If set to true no model will be automatically loaded
  44248. */
  44249. doNotLoadControllerMeshes?: boolean;
  44250. /**
  44251. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44252. * If not found, the xr input profile data will be used.
  44253. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44254. */
  44255. forceInputProfile?: string;
  44256. /**
  44257. * Do not send a request to the controller repository to load the profile.
  44258. *
  44259. * Instead, use the controllers available in babylon itself.
  44260. */
  44261. disableOnlineControllerRepository?: boolean;
  44262. /**
  44263. * A custom URL for the controllers repository
  44264. */
  44265. customControllersRepositoryURL?: string;
  44266. /**
  44267. * Should the controller model's components not move according to the user input
  44268. */
  44269. disableControllerAnimation?: boolean;
  44270. }
  44271. /**
  44272. * XR input used to track XR inputs such as controllers/rays
  44273. */
  44274. export class WebXRInput implements IDisposable {
  44275. /**
  44276. * the xr session manager for this session
  44277. */
  44278. xrSessionManager: WebXRSessionManager;
  44279. /**
  44280. * the WebXR camera for this session. Mainly used for teleportation
  44281. */
  44282. xrCamera: WebXRCamera;
  44283. private readonly options;
  44284. /**
  44285. * XR controllers being tracked
  44286. */
  44287. controllers: Array<WebXRInputSource>;
  44288. private _frameObserver;
  44289. private _sessionEndedObserver;
  44290. private _sessionInitObserver;
  44291. /**
  44292. * Event when a controller has been connected/added
  44293. */
  44294. onControllerAddedObservable: Observable<WebXRInputSource>;
  44295. /**
  44296. * Event when a controller has been removed/disconnected
  44297. */
  44298. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44299. /**
  44300. * Initializes the WebXRInput
  44301. * @param xrSessionManager the xr session manager for this session
  44302. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44303. * @param options = initialization options for this xr input
  44304. */
  44305. constructor(
  44306. /**
  44307. * the xr session manager for this session
  44308. */
  44309. xrSessionManager: WebXRSessionManager,
  44310. /**
  44311. * the WebXR camera for this session. Mainly used for teleportation
  44312. */
  44313. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44314. private _onInputSourcesChange;
  44315. private _addAndRemoveControllers;
  44316. /**
  44317. * Disposes of the object
  44318. */
  44319. dispose(): void;
  44320. }
  44321. }
  44322. declare module BABYLON {
  44323. /**
  44324. * This is the base class for all WebXR features.
  44325. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44326. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44327. */
  44328. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44329. protected _xrSessionManager: WebXRSessionManager;
  44330. private _attached;
  44331. private _removeOnDetach;
  44332. /**
  44333. * Should auto-attach be disabled?
  44334. */
  44335. disableAutoAttach: boolean;
  44336. /**
  44337. * Construct a new (abstract) WebXR feature
  44338. * @param _xrSessionManager the xr session manager for this feature
  44339. */
  44340. constructor(_xrSessionManager: WebXRSessionManager);
  44341. /**
  44342. * Is this feature attached
  44343. */
  44344. get attached(): boolean;
  44345. /**
  44346. * attach this feature
  44347. *
  44348. * @param force should attachment be forced (even when already attached)
  44349. * @returns true if successful, false is failed or already attached
  44350. */
  44351. attach(force?: boolean): boolean;
  44352. /**
  44353. * detach this feature.
  44354. *
  44355. * @returns true if successful, false if failed or already detached
  44356. */
  44357. detach(): boolean;
  44358. /**
  44359. * Dispose this feature and all of the resources attached
  44360. */
  44361. dispose(): void;
  44362. /**
  44363. * This is used to register callbacks that will automatically be removed when detach is called.
  44364. * @param observable the observable to which the observer will be attached
  44365. * @param callback the callback to register
  44366. */
  44367. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44368. /**
  44369. * Code in this function will be executed on each xrFrame received from the browser.
  44370. * This function will not execute after the feature is detached.
  44371. * @param _xrFrame the current frame
  44372. */
  44373. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44374. }
  44375. }
  44376. declare module BABYLON {
  44377. /**
  44378. * Renders a layer on top of an existing scene
  44379. */
  44380. export class UtilityLayerRenderer implements IDisposable {
  44381. /** the original scene that will be rendered on top of */
  44382. originalScene: Scene;
  44383. private _pointerCaptures;
  44384. private _lastPointerEvents;
  44385. private static _DefaultUtilityLayer;
  44386. private static _DefaultKeepDepthUtilityLayer;
  44387. private _sharedGizmoLight;
  44388. private _renderCamera;
  44389. /**
  44390. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44391. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44392. * @returns the camera that is used when rendering the utility layer
  44393. */
  44394. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44395. /**
  44396. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44397. * @param cam the camera that should be used when rendering the utility layer
  44398. */
  44399. setRenderCamera(cam: Nullable<Camera>): void;
  44400. /**
  44401. * @hidden
  44402. * Light which used by gizmos to get light shading
  44403. */
  44404. _getSharedGizmoLight(): HemisphericLight;
  44405. /**
  44406. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44407. */
  44408. pickUtilitySceneFirst: boolean;
  44409. /**
  44410. * 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)
  44411. */
  44412. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44413. /**
  44414. * 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)
  44415. */
  44416. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44417. /**
  44418. * The scene that is rendered on top of the original scene
  44419. */
  44420. utilityLayerScene: Scene;
  44421. /**
  44422. * If the utility layer should automatically be rendered on top of existing scene
  44423. */
  44424. shouldRender: boolean;
  44425. /**
  44426. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44427. */
  44428. onlyCheckPointerDownEvents: boolean;
  44429. /**
  44430. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44431. */
  44432. processAllEvents: boolean;
  44433. /**
  44434. * Observable raised when the pointer move from the utility layer scene to the main scene
  44435. */
  44436. onPointerOutObservable: Observable<number>;
  44437. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44438. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44439. private _afterRenderObserver;
  44440. private _sceneDisposeObserver;
  44441. private _originalPointerObserver;
  44442. /**
  44443. * Instantiates a UtilityLayerRenderer
  44444. * @param originalScene the original scene that will be rendered on top of
  44445. * @param handleEvents boolean indicating if the utility layer should handle events
  44446. */
  44447. constructor(
  44448. /** the original scene that will be rendered on top of */
  44449. originalScene: Scene, handleEvents?: boolean);
  44450. private _notifyObservers;
  44451. /**
  44452. * Renders the utility layers scene on top of the original scene
  44453. */
  44454. render(): void;
  44455. /**
  44456. * Disposes of the renderer
  44457. */
  44458. dispose(): void;
  44459. private _updateCamera;
  44460. }
  44461. }
  44462. declare module BABYLON {
  44463. /**
  44464. * Options interface for the pointer selection module
  44465. */
  44466. export interface IWebXRControllerPointerSelectionOptions {
  44467. /**
  44468. * if provided, this scene will be used to render meshes.
  44469. */
  44470. customUtilityLayerScene?: Scene;
  44471. /**
  44472. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  44473. * If not disabled, the last picked point will be used to execute a pointer up event
  44474. * If disabled, pointer up event will be triggered right after the pointer down event.
  44475. * Used in screen and gaze target ray mode only
  44476. */
  44477. disablePointerUpOnTouchOut: boolean;
  44478. /**
  44479. * For gaze mode (time to select instead of press)
  44480. */
  44481. forceGazeMode: boolean;
  44482. /**
  44483. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  44484. * to start a new countdown to the pointer down event.
  44485. * Defaults to 1.
  44486. */
  44487. gazeModePointerMovedFactor?: number;
  44488. /**
  44489. * Different button type to use instead of the main component
  44490. */
  44491. overrideButtonId?: string;
  44492. /**
  44493. * use this rendering group id for the meshes (optional)
  44494. */
  44495. renderingGroupId?: number;
  44496. /**
  44497. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44498. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44499. * 3000 means 3 seconds between pointing at something and selecting it
  44500. */
  44501. timeToSelect?: number;
  44502. /**
  44503. * Should meshes created here be added to a utility layer or the main scene
  44504. */
  44505. useUtilityLayer?: boolean;
  44506. /**
  44507. * the xr input to use with this pointer selection
  44508. */
  44509. xrInput: WebXRInput;
  44510. }
  44511. /**
  44512. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44513. */
  44514. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44515. private readonly _options;
  44516. private static _idCounter;
  44517. private _attachController;
  44518. private _controllers;
  44519. private _scene;
  44520. private _tmpVectorForPickCompare;
  44521. /**
  44522. * The module's name
  44523. */
  44524. static readonly Name: string;
  44525. /**
  44526. * The (Babylon) version of this module.
  44527. * This is an integer representing the implementation version.
  44528. * This number does not correspond to the WebXR specs version
  44529. */
  44530. static readonly Version: number;
  44531. /**
  44532. * Disable lighting on the laser pointer (so it will always be visible)
  44533. */
  44534. disablePointerLighting: boolean;
  44535. /**
  44536. * Disable lighting on the selection mesh (so it will always be visible)
  44537. */
  44538. disableSelectionMeshLighting: boolean;
  44539. /**
  44540. * Should the laser pointer be displayed
  44541. */
  44542. displayLaserPointer: boolean;
  44543. /**
  44544. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44545. */
  44546. displaySelectionMesh: boolean;
  44547. /**
  44548. * This color will be set to the laser pointer when selection is triggered
  44549. */
  44550. laserPointerPickedColor: Color3;
  44551. /**
  44552. * Default color of the laser pointer
  44553. */
  44554. lasterPointerDefaultColor: Color3;
  44555. /**
  44556. * default color of the selection ring
  44557. */
  44558. selectionMeshDefaultColor: Color3;
  44559. /**
  44560. * This color will be applied to the selection ring when selection is triggered
  44561. */
  44562. selectionMeshPickedColor: Color3;
  44563. /**
  44564. * constructs a new background remover module
  44565. * @param _xrSessionManager the session manager for this module
  44566. * @param _options read-only options to be used in this module
  44567. */
  44568. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44569. /**
  44570. * attach this feature
  44571. * Will usually be called by the features manager
  44572. *
  44573. * @returns true if successful.
  44574. */
  44575. attach(): boolean;
  44576. /**
  44577. * detach this feature.
  44578. * Will usually be called by the features manager
  44579. *
  44580. * @returns true if successful.
  44581. */
  44582. detach(): boolean;
  44583. /**
  44584. * Will get the mesh under a specific pointer.
  44585. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44586. * @param controllerId the controllerId to check
  44587. * @returns The mesh under pointer or null if no mesh is under the pointer
  44588. */
  44589. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44590. /**
  44591. * Get the xr controller that correlates to the pointer id in the pointer event
  44592. *
  44593. * @param id the pointer id to search for
  44594. * @returns the controller that correlates to this id or null if not found
  44595. */
  44596. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44597. protected _onXRFrame(_xrFrame: XRFrame): void;
  44598. private _attachGazeMode;
  44599. private _attachScreenRayMode;
  44600. private _attachTrackedPointerRayMode;
  44601. private _convertNormalToDirectionOfRay;
  44602. private _detachController;
  44603. private _generateNewMeshPair;
  44604. private _pickingMoved;
  44605. private _updatePointerDistance;
  44606. }
  44607. }
  44608. declare module BABYLON {
  44609. /**
  44610. * Button which can be used to enter a different mode of XR
  44611. */
  44612. export class WebXREnterExitUIButton {
  44613. /** button element */
  44614. element: HTMLElement;
  44615. /** XR initialization options for the button */
  44616. sessionMode: XRSessionMode;
  44617. /** Reference space type */
  44618. referenceSpaceType: XRReferenceSpaceType;
  44619. /**
  44620. * Creates a WebXREnterExitUIButton
  44621. * @param element button element
  44622. * @param sessionMode XR initialization session mode
  44623. * @param referenceSpaceType the type of reference space to be used
  44624. */
  44625. constructor(
  44626. /** button element */
  44627. element: HTMLElement,
  44628. /** XR initialization options for the button */
  44629. sessionMode: XRSessionMode,
  44630. /** Reference space type */
  44631. referenceSpaceType: XRReferenceSpaceType);
  44632. /**
  44633. * Extendable function which can be used to update the button's visuals when the state changes
  44634. * @param activeButton the current active button in the UI
  44635. */
  44636. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44637. }
  44638. /**
  44639. * Options to create the webXR UI
  44640. */
  44641. export class WebXREnterExitUIOptions {
  44642. /**
  44643. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44644. */
  44645. customButtons?: Array<WebXREnterExitUIButton>;
  44646. /**
  44647. * A reference space type to use when creating the default button.
  44648. * Default is local-floor
  44649. */
  44650. referenceSpaceType?: XRReferenceSpaceType;
  44651. /**
  44652. * Context to enter xr with
  44653. */
  44654. renderTarget?: Nullable<WebXRRenderTarget>;
  44655. /**
  44656. * A session mode to use when creating the default button.
  44657. * Default is immersive-vr
  44658. */
  44659. sessionMode?: XRSessionMode;
  44660. }
  44661. /**
  44662. * UI to allow the user to enter/exit XR mode
  44663. */
  44664. export class WebXREnterExitUI implements IDisposable {
  44665. private scene;
  44666. /** version of the options passed to this UI */
  44667. options: WebXREnterExitUIOptions;
  44668. private _activeButton;
  44669. private _buttons;
  44670. private _overlay;
  44671. /**
  44672. * Fired every time the active button is changed.
  44673. *
  44674. * When xr is entered via a button that launches xr that button will be the callback parameter
  44675. *
  44676. * When exiting xr the callback parameter will be null)
  44677. */
  44678. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44679. /**
  44680. *
  44681. * @param scene babylon scene object to use
  44682. * @param options (read-only) version of the options passed to this UI
  44683. */
  44684. private constructor();
  44685. /**
  44686. * Creates UI to allow the user to enter/exit XR mode
  44687. * @param scene the scene to add the ui to
  44688. * @param helper the xr experience helper to enter/exit xr with
  44689. * @param options options to configure the UI
  44690. * @returns the created ui
  44691. */
  44692. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44693. /**
  44694. * Disposes of the XR UI component
  44695. */
  44696. dispose(): void;
  44697. private _updateButtons;
  44698. }
  44699. }
  44700. declare module BABYLON {
  44701. /**
  44702. * Class containing static functions to help procedurally build meshes
  44703. */
  44704. export class LinesBuilder {
  44705. /**
  44706. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44707. * * 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
  44708. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44709. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44710. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44711. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44712. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44713. * * 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
  44714. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44717. * @param name defines the name of the new line system
  44718. * @param options defines the options used to create the line system
  44719. * @param scene defines the hosting scene
  44720. * @returns a new line system mesh
  44721. */
  44722. static CreateLineSystem(name: string, options: {
  44723. lines: Vector3[][];
  44724. updatable?: boolean;
  44725. instance?: Nullable<LinesMesh>;
  44726. colors?: Nullable<Color4[][]>;
  44727. useVertexAlpha?: boolean;
  44728. }, scene: Nullable<Scene>): LinesMesh;
  44729. /**
  44730. * Creates a line mesh
  44731. * 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
  44732. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44733. * * The parameter `points` is an array successive Vector3
  44734. * * 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
  44735. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44736. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44737. * * When updating an instance, remember that only point positions can change, not the number of points
  44738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44740. * @param name defines the name of the new line system
  44741. * @param options defines the options used to create the line system
  44742. * @param scene defines the hosting scene
  44743. * @returns a new line mesh
  44744. */
  44745. static CreateLines(name: string, options: {
  44746. points: Vector3[];
  44747. updatable?: boolean;
  44748. instance?: Nullable<LinesMesh>;
  44749. colors?: Color4[];
  44750. useVertexAlpha?: boolean;
  44751. }, scene?: Nullable<Scene>): LinesMesh;
  44752. /**
  44753. * Creates a dashed line mesh
  44754. * * 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
  44755. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44756. * * The parameter `points` is an array successive Vector3
  44757. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44758. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44759. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44760. * * 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
  44761. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44762. * * When updating an instance, remember that only point positions can change, not the number of points
  44763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44764. * @param name defines the name of the mesh
  44765. * @param options defines the options used to create the mesh
  44766. * @param scene defines the hosting scene
  44767. * @returns the dashed line mesh
  44768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44769. */
  44770. static CreateDashedLines(name: string, options: {
  44771. points: Vector3[];
  44772. dashSize?: number;
  44773. gapSize?: number;
  44774. dashNb?: number;
  44775. updatable?: boolean;
  44776. instance?: LinesMesh;
  44777. useVertexAlpha?: boolean;
  44778. }, scene?: Nullable<Scene>): LinesMesh;
  44779. }
  44780. }
  44781. declare module BABYLON {
  44782. /**
  44783. * The options container for the teleportation module
  44784. */
  44785. export interface IWebXRTeleportationOptions {
  44786. /**
  44787. * if provided, this scene will be used to render meshes.
  44788. */
  44789. customUtilityLayerScene?: Scene;
  44790. /**
  44791. * Values to configure the default target mesh
  44792. */
  44793. defaultTargetMeshOptions?: {
  44794. /**
  44795. * Fill color of the teleportation area
  44796. */
  44797. teleportationFillColor?: string;
  44798. /**
  44799. * Border color for the teleportation area
  44800. */
  44801. teleportationBorderColor?: string;
  44802. /**
  44803. * Disable the mesh's animation sequence
  44804. */
  44805. disableAnimation?: boolean;
  44806. /**
  44807. * Disable lighting on the material or the ring and arrow
  44808. */
  44809. disableLighting?: boolean;
  44810. /**
  44811. * Override the default material of the torus and arrow
  44812. */
  44813. torusArrowMaterial?: Material;
  44814. };
  44815. /**
  44816. * A list of meshes to use as floor meshes.
  44817. * Meshes can be added and removed after initializing the feature using the
  44818. * addFloorMesh and removeFloorMesh functions
  44819. * If empty, rotation will still work
  44820. */
  44821. floorMeshes?: AbstractMesh[];
  44822. /**
  44823. * use this rendering group id for the meshes (optional)
  44824. */
  44825. renderingGroupId?: number;
  44826. /**
  44827. * Should teleportation move only to snap points
  44828. */
  44829. snapPointsOnly?: boolean;
  44830. /**
  44831. * An array of points to which the teleportation will snap to.
  44832. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44833. */
  44834. snapPositions?: Vector3[];
  44835. /**
  44836. * How close should the teleportation ray be in order to snap to position.
  44837. * Default to 0.8 units (meters)
  44838. */
  44839. snapToPositionRadius?: number;
  44840. /**
  44841. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44842. * If you want to support rotation, make sure your mesh has a direction indicator.
  44843. *
  44844. * When left untouched, the default mesh will be initialized.
  44845. */
  44846. teleportationTargetMesh?: AbstractMesh;
  44847. /**
  44848. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  44849. */
  44850. timeToTeleport?: number;
  44851. /**
  44852. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  44853. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  44854. */
  44855. useMainComponentOnly?: boolean;
  44856. /**
  44857. * Should meshes created here be added to a utility layer or the main scene
  44858. */
  44859. useUtilityLayer?: boolean;
  44860. /**
  44861. * Babylon XR Input class for controller
  44862. */
  44863. xrInput: WebXRInput;
  44864. }
  44865. /**
  44866. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  44867. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44868. * the input of the attached controllers.
  44869. */
  44870. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44871. private _options;
  44872. private _controllers;
  44873. private _currentTeleportationControllerId;
  44874. private _floorMeshes;
  44875. private _quadraticBezierCurve;
  44876. private _selectionFeature;
  44877. private _snapToPositions;
  44878. private _snappedToPoint;
  44879. private _teleportationRingMaterial?;
  44880. private _tmpRay;
  44881. private _tmpVector;
  44882. /**
  44883. * The module's name
  44884. */
  44885. static readonly Name: string;
  44886. /**
  44887. * The (Babylon) version of this module.
  44888. * This is an integer representing the implementation version.
  44889. * This number does not correspond to the webxr specs version
  44890. */
  44891. static readonly Version: number;
  44892. /**
  44893. * Is movement backwards enabled
  44894. */
  44895. backwardsMovementEnabled: boolean;
  44896. /**
  44897. * Distance to travel when moving backwards
  44898. */
  44899. backwardsTeleportationDistance: number;
  44900. /**
  44901. * The distance from the user to the inspection point in the direction of the controller
  44902. * A higher number will allow the user to move further
  44903. * defaults to 5 (meters, in xr units)
  44904. */
  44905. parabolicCheckRadius: number;
  44906. /**
  44907. * Should the module support parabolic ray on top of direct ray
  44908. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44909. * Very helpful when moving between floors / different heights
  44910. */
  44911. parabolicRayEnabled: boolean;
  44912. /**
  44913. * How much rotation should be applied when rotating right and left
  44914. */
  44915. rotationAngle: number;
  44916. /**
  44917. * Is rotation enabled when moving forward?
  44918. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44919. */
  44920. rotationEnabled: boolean;
  44921. /**
  44922. * constructs a new anchor system
  44923. * @param _xrSessionManager an instance of WebXRSessionManager
  44924. * @param _options configuration object for this feature
  44925. */
  44926. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44927. /**
  44928. * Get the snapPointsOnly flag
  44929. */
  44930. get snapPointsOnly(): boolean;
  44931. /**
  44932. * Sets the snapPointsOnly flag
  44933. * @param snapToPoints should teleportation be exclusively to snap points
  44934. */
  44935. set snapPointsOnly(snapToPoints: boolean);
  44936. /**
  44937. * Add a new mesh to the floor meshes array
  44938. * @param mesh the mesh to use as floor mesh
  44939. */
  44940. addFloorMesh(mesh: AbstractMesh): void;
  44941. /**
  44942. * Add a new snap-to point to fix teleportation to this position
  44943. * @param newSnapPoint The new Snap-To point
  44944. */
  44945. addSnapPoint(newSnapPoint: Vector3): void;
  44946. attach(): boolean;
  44947. detach(): boolean;
  44948. dispose(): void;
  44949. /**
  44950. * Remove a mesh from the floor meshes array
  44951. * @param mesh the mesh to remove
  44952. */
  44953. removeFloorMesh(mesh: AbstractMesh): void;
  44954. /**
  44955. * Remove a mesh from the floor meshes array using its name
  44956. * @param name the mesh name to remove
  44957. */
  44958. removeFloorMeshByName(name: string): void;
  44959. /**
  44960. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  44961. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  44962. * @returns was the point found and removed or not
  44963. */
  44964. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  44965. /**
  44966. * This function sets a selection feature that will be disabled when
  44967. * the forward ray is shown and will be reattached when hidden.
  44968. * This is used to remove the selection rays when moving.
  44969. * @param selectionFeature the feature to disable when forward movement is enabled
  44970. */
  44971. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44972. protected _onXRFrame(_xrFrame: XRFrame): void;
  44973. private _attachController;
  44974. private _createDefaultTargetMesh;
  44975. private _detachController;
  44976. private _findClosestSnapPointWithRadius;
  44977. private _setTargetMeshPosition;
  44978. private _setTargetMeshVisibility;
  44979. private _showParabolicPath;
  44980. private _teleportForward;
  44981. }
  44982. }
  44983. declare module BABYLON {
  44984. /**
  44985. * Options for the default xr helper
  44986. */
  44987. export class WebXRDefaultExperienceOptions {
  44988. /**
  44989. * Enable or disable default UI to enter XR
  44990. */
  44991. disableDefaultUI?: boolean;
  44992. /**
  44993. * Should teleportation not initialize. defaults to false.
  44994. */
  44995. disableTeleportation?: boolean;
  44996. /**
  44997. * Floor meshes that will be used for teleport
  44998. */
  44999. floorMeshes?: Array<AbstractMesh>;
  45000. /**
  45001. * If set to true, the first frame will not be used to reset position
  45002. * The first frame is mainly used when copying transformation from the old camera
  45003. * Mainly used in AR
  45004. */
  45005. ignoreNativeCameraTransformation?: boolean;
  45006. /**
  45007. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45008. */
  45009. inputOptions?: IWebXRInputOptions;
  45010. /**
  45011. * optional configuration for the output canvas
  45012. */
  45013. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45014. /**
  45015. * optional UI options. This can be used among other to change session mode and reference space type
  45016. */
  45017. uiOptions?: WebXREnterExitUIOptions;
  45018. /**
  45019. * When loading teleportation and pointer select, use stable versions instead of latest.
  45020. */
  45021. useStablePlugins?: boolean;
  45022. }
  45023. /**
  45024. * Default experience which provides a similar setup to the previous webVRExperience
  45025. */
  45026. export class WebXRDefaultExperience {
  45027. /**
  45028. * Base experience
  45029. */
  45030. baseExperience: WebXRExperienceHelper;
  45031. /**
  45032. * Enables ui for entering/exiting xr
  45033. */
  45034. enterExitUI: WebXREnterExitUI;
  45035. /**
  45036. * Input experience extension
  45037. */
  45038. input: WebXRInput;
  45039. /**
  45040. * Enables laser pointer and selection
  45041. */
  45042. pointerSelection: WebXRControllerPointerSelection;
  45043. /**
  45044. * Default target xr should render to
  45045. */
  45046. renderTarget: WebXRRenderTarget;
  45047. /**
  45048. * Enables teleportation
  45049. */
  45050. teleportation: WebXRMotionControllerTeleportation;
  45051. private constructor();
  45052. /**
  45053. * Creates the default xr experience
  45054. * @param scene scene
  45055. * @param options options for basic configuration
  45056. * @returns resulting WebXRDefaultExperience
  45057. */
  45058. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45059. /**
  45060. * DIsposes of the experience helper
  45061. */
  45062. dispose(): void;
  45063. }
  45064. }
  45065. declare module BABYLON {
  45066. /**
  45067. * Options to modify the vr teleportation behavior.
  45068. */
  45069. export interface VRTeleportationOptions {
  45070. /**
  45071. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45072. */
  45073. floorMeshName?: string;
  45074. /**
  45075. * A list of meshes to be used as the teleportation floor. (default: empty)
  45076. */
  45077. floorMeshes?: Mesh[];
  45078. /**
  45079. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45080. */
  45081. teleportationMode?: number;
  45082. /**
  45083. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45084. */
  45085. teleportationTime?: number;
  45086. /**
  45087. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45088. */
  45089. teleportationSpeed?: number;
  45090. /**
  45091. * The easing function used in the animation or null for Linear. (default CircleEase)
  45092. */
  45093. easingFunction?: EasingFunction;
  45094. }
  45095. /**
  45096. * Options to modify the vr experience helper's behavior.
  45097. */
  45098. export interface VRExperienceHelperOptions extends WebVROptions {
  45099. /**
  45100. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45101. */
  45102. createDeviceOrientationCamera?: boolean;
  45103. /**
  45104. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45105. */
  45106. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45107. /**
  45108. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45109. */
  45110. laserToggle?: boolean;
  45111. /**
  45112. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45113. */
  45114. floorMeshes?: Mesh[];
  45115. /**
  45116. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45117. */
  45118. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45119. /**
  45120. * Defines if WebXR should be used instead of WebVR (if available)
  45121. */
  45122. useXR?: boolean;
  45123. }
  45124. /**
  45125. * Event containing information after VR has been entered
  45126. */
  45127. export class OnAfterEnteringVRObservableEvent {
  45128. /**
  45129. * If entering vr was successful
  45130. */
  45131. success: boolean;
  45132. }
  45133. /**
  45134. * Helps to quickly add VR support to an existing scene.
  45135. * See http://doc.babylonjs.com/how_to/webvr_helper
  45136. */
  45137. export class VRExperienceHelper {
  45138. /** Options to modify the vr experience helper's behavior. */
  45139. webVROptions: VRExperienceHelperOptions;
  45140. private _scene;
  45141. private _position;
  45142. private _btnVR;
  45143. private _btnVRDisplayed;
  45144. private _webVRsupported;
  45145. private _webVRready;
  45146. private _webVRrequesting;
  45147. private _webVRpresenting;
  45148. private _hasEnteredVR;
  45149. private _fullscreenVRpresenting;
  45150. private _inputElement;
  45151. private _webVRCamera;
  45152. private _vrDeviceOrientationCamera;
  45153. private _deviceOrientationCamera;
  45154. private _existingCamera;
  45155. private _onKeyDown;
  45156. private _onVrDisplayPresentChange;
  45157. private _onVRDisplayChanged;
  45158. private _onVRRequestPresentStart;
  45159. private _onVRRequestPresentComplete;
  45160. /**
  45161. * 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)
  45162. */
  45163. enableGazeEvenWhenNoPointerLock: boolean;
  45164. /**
  45165. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45166. */
  45167. exitVROnDoubleTap: boolean;
  45168. /**
  45169. * Observable raised right before entering VR.
  45170. */
  45171. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45172. /**
  45173. * Observable raised when entering VR has completed.
  45174. */
  45175. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45176. /**
  45177. * Observable raised when exiting VR.
  45178. */
  45179. onExitingVRObservable: Observable<VRExperienceHelper>;
  45180. /**
  45181. * Observable raised when controller mesh is loaded.
  45182. */
  45183. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45184. /** Return this.onEnteringVRObservable
  45185. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45186. */
  45187. get onEnteringVR(): Observable<VRExperienceHelper>;
  45188. /** Return this.onExitingVRObservable
  45189. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45190. */
  45191. get onExitingVR(): Observable<VRExperienceHelper>;
  45192. /** Return this.onControllerMeshLoadedObservable
  45193. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45194. */
  45195. get onControllerMeshLoaded(): Observable<WebVRController>;
  45196. private _rayLength;
  45197. private _useCustomVRButton;
  45198. private _teleportationRequested;
  45199. private _teleportActive;
  45200. private _floorMeshName;
  45201. private _floorMeshesCollection;
  45202. private _teleportationMode;
  45203. private _teleportationTime;
  45204. private _teleportationSpeed;
  45205. private _teleportationEasing;
  45206. private _rotationAllowed;
  45207. private _teleportBackwardsVector;
  45208. private _teleportationTarget;
  45209. private _isDefaultTeleportationTarget;
  45210. private _postProcessMove;
  45211. private _teleportationFillColor;
  45212. private _teleportationBorderColor;
  45213. private _rotationAngle;
  45214. private _haloCenter;
  45215. private _cameraGazer;
  45216. private _padSensibilityUp;
  45217. private _padSensibilityDown;
  45218. private _leftController;
  45219. private _rightController;
  45220. private _gazeColor;
  45221. private _laserColor;
  45222. private _pickedLaserColor;
  45223. private _pickedGazeColor;
  45224. /**
  45225. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45226. */
  45227. onNewMeshSelected: Observable<AbstractMesh>;
  45228. /**
  45229. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45230. * This observable will provide the mesh and the controller used to select the mesh
  45231. */
  45232. onMeshSelectedWithController: Observable<{
  45233. mesh: AbstractMesh;
  45234. controller: WebVRController;
  45235. }>;
  45236. /**
  45237. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45238. */
  45239. onNewMeshPicked: Observable<PickingInfo>;
  45240. private _circleEase;
  45241. /**
  45242. * Observable raised before camera teleportation
  45243. */
  45244. onBeforeCameraTeleport: Observable<Vector3>;
  45245. /**
  45246. * Observable raised after camera teleportation
  45247. */
  45248. onAfterCameraTeleport: Observable<Vector3>;
  45249. /**
  45250. * Observable raised when current selected mesh gets unselected
  45251. */
  45252. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45253. private _raySelectionPredicate;
  45254. /**
  45255. * To be optionaly changed by user to define custom ray selection
  45256. */
  45257. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45258. /**
  45259. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45260. */
  45261. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45262. /**
  45263. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45264. */
  45265. teleportationEnabled: boolean;
  45266. private _defaultHeight;
  45267. private _teleportationInitialized;
  45268. private _interactionsEnabled;
  45269. private _interactionsRequested;
  45270. private _displayGaze;
  45271. private _displayLaserPointer;
  45272. /**
  45273. * The mesh used to display where the user is going to teleport.
  45274. */
  45275. get teleportationTarget(): Mesh;
  45276. /**
  45277. * Sets the mesh to be used to display where the user is going to teleport.
  45278. */
  45279. set teleportationTarget(value: Mesh);
  45280. /**
  45281. * 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
  45282. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45283. * See http://doc.babylonjs.com/resources/baking_transformations
  45284. */
  45285. get gazeTrackerMesh(): Mesh;
  45286. set gazeTrackerMesh(value: Mesh);
  45287. /**
  45288. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45289. */
  45290. updateGazeTrackerScale: boolean;
  45291. /**
  45292. * If the gaze trackers color should be updated when selecting meshes
  45293. */
  45294. updateGazeTrackerColor: boolean;
  45295. /**
  45296. * If the controller laser color should be updated when selecting meshes
  45297. */
  45298. updateControllerLaserColor: boolean;
  45299. /**
  45300. * The gaze tracking mesh corresponding to the left controller
  45301. */
  45302. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45303. /**
  45304. * The gaze tracking mesh corresponding to the right controller
  45305. */
  45306. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45307. /**
  45308. * If the ray of the gaze should be displayed.
  45309. */
  45310. get displayGaze(): boolean;
  45311. /**
  45312. * Sets if the ray of the gaze should be displayed.
  45313. */
  45314. set displayGaze(value: boolean);
  45315. /**
  45316. * If the ray of the LaserPointer should be displayed.
  45317. */
  45318. get displayLaserPointer(): boolean;
  45319. /**
  45320. * Sets if the ray of the LaserPointer should be displayed.
  45321. */
  45322. set displayLaserPointer(value: boolean);
  45323. /**
  45324. * The deviceOrientationCamera used as the camera when not in VR.
  45325. */
  45326. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45327. /**
  45328. * Based on the current WebVR support, returns the current VR camera used.
  45329. */
  45330. get currentVRCamera(): Nullable<Camera>;
  45331. /**
  45332. * The webVRCamera which is used when in VR.
  45333. */
  45334. get webVRCamera(): WebVRFreeCamera;
  45335. /**
  45336. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45337. */
  45338. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45339. /**
  45340. * The html button that is used to trigger entering into VR.
  45341. */
  45342. get vrButton(): Nullable<HTMLButtonElement>;
  45343. private get _teleportationRequestInitiated();
  45344. /**
  45345. * Defines whether or not Pointer lock should be requested when switching to
  45346. * full screen.
  45347. */
  45348. requestPointerLockOnFullScreen: boolean;
  45349. /**
  45350. * If asking to force XR, this will be populated with the default xr experience
  45351. */
  45352. xr: WebXRDefaultExperience;
  45353. /**
  45354. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45355. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45356. */
  45357. xrTestDone: boolean;
  45358. /**
  45359. * Instantiates a VRExperienceHelper.
  45360. * Helps to quickly add VR support to an existing scene.
  45361. * @param scene The scene the VRExperienceHelper belongs to.
  45362. * @param webVROptions Options to modify the vr experience helper's behavior.
  45363. */
  45364. constructor(scene: Scene,
  45365. /** Options to modify the vr experience helper's behavior. */
  45366. webVROptions?: VRExperienceHelperOptions);
  45367. private completeVRInit;
  45368. private _onDefaultMeshLoaded;
  45369. private _onResize;
  45370. private _onFullscreenChange;
  45371. /**
  45372. * Gets a value indicating if we are currently in VR mode.
  45373. */
  45374. get isInVRMode(): boolean;
  45375. private onVrDisplayPresentChange;
  45376. private onVRDisplayChanged;
  45377. private moveButtonToBottomRight;
  45378. private displayVRButton;
  45379. private updateButtonVisibility;
  45380. private _cachedAngularSensibility;
  45381. /**
  45382. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45383. * Otherwise, will use the fullscreen API.
  45384. */
  45385. enterVR(): void;
  45386. /**
  45387. * Attempt to exit VR, or fullscreen.
  45388. */
  45389. exitVR(): void;
  45390. /**
  45391. * The position of the vr experience helper.
  45392. */
  45393. get position(): Vector3;
  45394. /**
  45395. * Sets the position of the vr experience helper.
  45396. */
  45397. set position(value: Vector3);
  45398. /**
  45399. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45400. */
  45401. enableInteractions(): void;
  45402. private get _noControllerIsActive();
  45403. private beforeRender;
  45404. private _isTeleportationFloor;
  45405. /**
  45406. * Adds a floor mesh to be used for teleportation.
  45407. * @param floorMesh the mesh to be used for teleportation.
  45408. */
  45409. addFloorMesh(floorMesh: Mesh): void;
  45410. /**
  45411. * Removes a floor mesh from being used for teleportation.
  45412. * @param floorMesh the mesh to be removed.
  45413. */
  45414. removeFloorMesh(floorMesh: Mesh): void;
  45415. /**
  45416. * Enables interactions and teleportation using the VR controllers and gaze.
  45417. * @param vrTeleportationOptions options to modify teleportation behavior.
  45418. */
  45419. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45420. private _onNewGamepadConnected;
  45421. private _tryEnableInteractionOnController;
  45422. private _onNewGamepadDisconnected;
  45423. private _enableInteractionOnController;
  45424. private _checkTeleportWithRay;
  45425. private _checkRotate;
  45426. private _checkTeleportBackwards;
  45427. private _enableTeleportationOnController;
  45428. private _createTeleportationCircles;
  45429. private _displayTeleportationTarget;
  45430. private _hideTeleportationTarget;
  45431. private _rotateCamera;
  45432. private _moveTeleportationSelectorTo;
  45433. private _workingVector;
  45434. private _workingQuaternion;
  45435. private _workingMatrix;
  45436. /**
  45437. * Time Constant Teleportation Mode
  45438. */
  45439. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45440. /**
  45441. * Speed Constant Teleportation Mode
  45442. */
  45443. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45444. /**
  45445. * Teleports the users feet to the desired location
  45446. * @param location The location where the user's feet should be placed
  45447. */
  45448. teleportCamera(location: Vector3): void;
  45449. private _convertNormalToDirectionOfRay;
  45450. private _castRayAndSelectObject;
  45451. private _notifySelectedMeshUnselected;
  45452. /**
  45453. * Permanently set new colors for the laser pointer
  45454. * @param color the new laser color
  45455. * @param pickedColor the new laser color when picked mesh detected
  45456. */
  45457. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45458. /**
  45459. * Set lighting enabled / disabled on the laser pointer of both controllers
  45460. * @param enabled should the lighting be enabled on the laser pointer
  45461. */
  45462. setLaserLightingState(enabled?: boolean): void;
  45463. /**
  45464. * Permanently set new colors for the gaze pointer
  45465. * @param color the new gaze color
  45466. * @param pickedColor the new gaze color when picked mesh detected
  45467. */
  45468. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45469. /**
  45470. * Sets the color of the laser ray from the vr controllers.
  45471. * @param color new color for the ray.
  45472. */
  45473. changeLaserColor(color: Color3): void;
  45474. /**
  45475. * Sets the color of the ray from the vr headsets gaze.
  45476. * @param color new color for the ray.
  45477. */
  45478. changeGazeColor(color: Color3): void;
  45479. /**
  45480. * Exits VR and disposes of the vr experience helper
  45481. */
  45482. dispose(): void;
  45483. /**
  45484. * Gets the name of the VRExperienceHelper class
  45485. * @returns "VRExperienceHelper"
  45486. */
  45487. getClassName(): string;
  45488. }
  45489. }
  45490. declare module BABYLON {
  45491. /**
  45492. * Contains an array of blocks representing the octree
  45493. */
  45494. export interface IOctreeContainer<T> {
  45495. /**
  45496. * Blocks within the octree
  45497. */
  45498. blocks: Array<OctreeBlock<T>>;
  45499. }
  45500. /**
  45501. * Class used to store a cell in an octree
  45502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45503. */
  45504. export class OctreeBlock<T> {
  45505. /**
  45506. * Gets the content of the current block
  45507. */
  45508. entries: T[];
  45509. /**
  45510. * Gets the list of block children
  45511. */
  45512. blocks: Array<OctreeBlock<T>>;
  45513. private _depth;
  45514. private _maxDepth;
  45515. private _capacity;
  45516. private _minPoint;
  45517. private _maxPoint;
  45518. private _boundingVectors;
  45519. private _creationFunc;
  45520. /**
  45521. * Creates a new block
  45522. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45523. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45524. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45525. * @param depth defines the current depth of this block in the octree
  45526. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45527. * @param creationFunc defines a callback to call when an element is added to the block
  45528. */
  45529. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45530. /**
  45531. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45532. */
  45533. get capacity(): number;
  45534. /**
  45535. * Gets the minimum vector (in world space) of the block's bounding box
  45536. */
  45537. get minPoint(): Vector3;
  45538. /**
  45539. * Gets the maximum vector (in world space) of the block's bounding box
  45540. */
  45541. get maxPoint(): Vector3;
  45542. /**
  45543. * Add a new element to this block
  45544. * @param entry defines the element to add
  45545. */
  45546. addEntry(entry: T): void;
  45547. /**
  45548. * Remove an element from this block
  45549. * @param entry defines the element to remove
  45550. */
  45551. removeEntry(entry: T): void;
  45552. /**
  45553. * Add an array of elements to this block
  45554. * @param entries defines the array of elements to add
  45555. */
  45556. addEntries(entries: T[]): void;
  45557. /**
  45558. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45559. * @param frustumPlanes defines the frustum planes to test
  45560. * @param selection defines the array to store current content if selection is positive
  45561. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45562. */
  45563. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45564. /**
  45565. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45566. * @param sphereCenter defines the bounding sphere center
  45567. * @param sphereRadius defines the bounding sphere radius
  45568. * @param selection defines the array to store current content if selection is positive
  45569. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45570. */
  45571. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45572. /**
  45573. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45574. * @param ray defines the ray to test with
  45575. * @param selection defines the array to store current content if selection is positive
  45576. */
  45577. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45578. /**
  45579. * Subdivide the content into child blocks (this block will then be empty)
  45580. */
  45581. createInnerBlocks(): void;
  45582. /**
  45583. * @hidden
  45584. */
  45585. 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;
  45586. }
  45587. }
  45588. declare module BABYLON {
  45589. /**
  45590. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45591. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45592. */
  45593. export class Octree<T> {
  45594. /** 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.) */
  45595. maxDepth: number;
  45596. /**
  45597. * Blocks within the octree containing objects
  45598. */
  45599. blocks: Array<OctreeBlock<T>>;
  45600. /**
  45601. * Content stored in the octree
  45602. */
  45603. dynamicContent: T[];
  45604. private _maxBlockCapacity;
  45605. private _selectionContent;
  45606. private _creationFunc;
  45607. /**
  45608. * Creates a octree
  45609. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45610. * @param creationFunc function to be used to instatiate the octree
  45611. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45612. * @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.)
  45613. */
  45614. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45615. /** 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.) */
  45616. maxDepth?: number);
  45617. /**
  45618. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45619. * @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);
  45620. * @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);
  45621. * @param entries meshes to be added to the octree blocks
  45622. */
  45623. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45624. /**
  45625. * Adds a mesh to the octree
  45626. * @param entry Mesh to add to the octree
  45627. */
  45628. addMesh(entry: T): void;
  45629. /**
  45630. * Remove an element from the octree
  45631. * @param entry defines the element to remove
  45632. */
  45633. removeMesh(entry: T): void;
  45634. /**
  45635. * Selects an array of meshes within the frustum
  45636. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45637. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45638. * @returns array of meshes within the frustum
  45639. */
  45640. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45641. /**
  45642. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45643. * @param sphereCenter defines the bounding sphere center
  45644. * @param sphereRadius defines the bounding sphere radius
  45645. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45646. * @returns an array of objects that intersect the sphere
  45647. */
  45648. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45649. /**
  45650. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45651. * @param ray defines the ray to test with
  45652. * @returns array of intersected objects
  45653. */
  45654. intersectsRay(ray: Ray): SmartArray<T>;
  45655. /**
  45656. * Adds a mesh into the octree block if it intersects the block
  45657. */
  45658. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45659. /**
  45660. * Adds a submesh into the octree block if it intersects the block
  45661. */
  45662. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45663. }
  45664. }
  45665. declare module BABYLON {
  45666. interface Scene {
  45667. /**
  45668. * @hidden
  45669. * Backing Filed
  45670. */
  45671. _selectionOctree: Octree<AbstractMesh>;
  45672. /**
  45673. * Gets the octree used to boost mesh selection (picking)
  45674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45675. */
  45676. selectionOctree: Octree<AbstractMesh>;
  45677. /**
  45678. * Creates or updates the octree used to boost selection (picking)
  45679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45680. * @param maxCapacity defines the maximum capacity per leaf
  45681. * @param maxDepth defines the maximum depth of the octree
  45682. * @returns an octree of AbstractMesh
  45683. */
  45684. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45685. }
  45686. interface AbstractMesh {
  45687. /**
  45688. * @hidden
  45689. * Backing Field
  45690. */
  45691. _submeshesOctree: Octree<SubMesh>;
  45692. /**
  45693. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45694. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45695. * @param maxCapacity defines the maximum size of each block (64 by default)
  45696. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45697. * @returns the new octree
  45698. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45700. */
  45701. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45702. }
  45703. /**
  45704. * Defines the octree scene component responsible to manage any octrees
  45705. * in a given scene.
  45706. */
  45707. export class OctreeSceneComponent {
  45708. /**
  45709. * The component name help to identify the component in the list of scene components.
  45710. */
  45711. readonly name: string;
  45712. /**
  45713. * The scene the component belongs to.
  45714. */
  45715. scene: Scene;
  45716. /**
  45717. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45718. */
  45719. readonly checksIsEnabled: boolean;
  45720. /**
  45721. * Creates a new instance of the component for the given scene
  45722. * @param scene Defines the scene to register the component in
  45723. */
  45724. constructor(scene: Scene);
  45725. /**
  45726. * Registers the component in a given scene
  45727. */
  45728. register(): void;
  45729. /**
  45730. * Return the list of active meshes
  45731. * @returns the list of active meshes
  45732. */
  45733. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45734. /**
  45735. * Return the list of active sub meshes
  45736. * @param mesh The mesh to get the candidates sub meshes from
  45737. * @returns the list of active sub meshes
  45738. */
  45739. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45740. private _tempRay;
  45741. /**
  45742. * Return the list of sub meshes intersecting with a given local ray
  45743. * @param mesh defines the mesh to find the submesh for
  45744. * @param localRay defines the ray in local space
  45745. * @returns the list of intersecting sub meshes
  45746. */
  45747. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45748. /**
  45749. * Return the list of sub meshes colliding with a collider
  45750. * @param mesh defines the mesh to find the submesh for
  45751. * @param collider defines the collider to evaluate the collision against
  45752. * @returns the list of colliding sub meshes
  45753. */
  45754. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45755. /**
  45756. * Rebuilds the elements related to this component in case of
  45757. * context lost for instance.
  45758. */
  45759. rebuild(): void;
  45760. /**
  45761. * Disposes the component and the associated ressources.
  45762. */
  45763. dispose(): void;
  45764. }
  45765. }
  45766. declare module BABYLON {
  45767. /**
  45768. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45769. */
  45770. export class Gizmo implements IDisposable {
  45771. /** The utility layer the gizmo will be added to */
  45772. gizmoLayer: UtilityLayerRenderer;
  45773. /**
  45774. * The root mesh of the gizmo
  45775. */
  45776. _rootMesh: Mesh;
  45777. private _attachedMesh;
  45778. /**
  45779. * Ratio for the scale of the gizmo (Default: 1)
  45780. */
  45781. scaleRatio: number;
  45782. /**
  45783. * If a custom mesh has been set (Default: false)
  45784. */
  45785. protected _customMeshSet: boolean;
  45786. /**
  45787. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45788. * * When set, interactions will be enabled
  45789. */
  45790. get attachedMesh(): Nullable<AbstractMesh>;
  45791. set attachedMesh(value: Nullable<AbstractMesh>);
  45792. /**
  45793. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45794. * @param mesh The mesh to replace the default mesh of the gizmo
  45795. */
  45796. setCustomMesh(mesh: Mesh): void;
  45797. /**
  45798. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45799. */
  45800. updateGizmoRotationToMatchAttachedMesh: boolean;
  45801. /**
  45802. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45803. */
  45804. updateGizmoPositionToMatchAttachedMesh: boolean;
  45805. /**
  45806. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45807. */
  45808. updateScale: boolean;
  45809. protected _interactionsEnabled: boolean;
  45810. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45811. private _beforeRenderObserver;
  45812. private _tempVector;
  45813. /**
  45814. * Creates a gizmo
  45815. * @param gizmoLayer The utility layer the gizmo will be added to
  45816. */
  45817. constructor(
  45818. /** The utility layer the gizmo will be added to */
  45819. gizmoLayer?: UtilityLayerRenderer);
  45820. /**
  45821. * Updates the gizmo to match the attached mesh's position/rotation
  45822. */
  45823. protected _update(): void;
  45824. /**
  45825. * Disposes of the gizmo
  45826. */
  45827. dispose(): void;
  45828. }
  45829. }
  45830. declare module BABYLON {
  45831. /**
  45832. * Single plane drag gizmo
  45833. */
  45834. export class PlaneDragGizmo extends Gizmo {
  45835. /**
  45836. * Drag behavior responsible for the gizmos dragging interactions
  45837. */
  45838. dragBehavior: PointerDragBehavior;
  45839. private _pointerObserver;
  45840. /**
  45841. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45842. */
  45843. snapDistance: number;
  45844. /**
  45845. * Event that fires each time the gizmo snaps to a new location.
  45846. * * snapDistance is the the change in distance
  45847. */
  45848. onSnapObservable: Observable<{
  45849. snapDistance: number;
  45850. }>;
  45851. private _plane;
  45852. private _coloredMaterial;
  45853. private _hoverMaterial;
  45854. private _isEnabled;
  45855. private _parent;
  45856. /** @hidden */
  45857. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45858. /** @hidden */
  45859. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45860. /**
  45861. * Creates a PlaneDragGizmo
  45862. * @param gizmoLayer The utility layer the gizmo will be added to
  45863. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45864. * @param color The color of the gizmo
  45865. */
  45866. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45868. /**
  45869. * If the gizmo is enabled
  45870. */
  45871. set isEnabled(value: boolean);
  45872. get isEnabled(): boolean;
  45873. /**
  45874. * Disposes of the gizmo
  45875. */
  45876. dispose(): void;
  45877. }
  45878. }
  45879. declare module BABYLON {
  45880. /**
  45881. * Gizmo that enables dragging a mesh along 3 axis
  45882. */
  45883. export class PositionGizmo extends Gizmo {
  45884. /**
  45885. * Internal gizmo used for interactions on the x axis
  45886. */
  45887. xGizmo: AxisDragGizmo;
  45888. /**
  45889. * Internal gizmo used for interactions on the y axis
  45890. */
  45891. yGizmo: AxisDragGizmo;
  45892. /**
  45893. * Internal gizmo used for interactions on the z axis
  45894. */
  45895. zGizmo: AxisDragGizmo;
  45896. /**
  45897. * Internal gizmo used for interactions on the yz plane
  45898. */
  45899. xPlaneGizmo: PlaneDragGizmo;
  45900. /**
  45901. * Internal gizmo used for interactions on the xz plane
  45902. */
  45903. yPlaneGizmo: PlaneDragGizmo;
  45904. /**
  45905. * Internal gizmo used for interactions on the xy plane
  45906. */
  45907. zPlaneGizmo: PlaneDragGizmo;
  45908. /**
  45909. * private variables
  45910. */
  45911. private _meshAttached;
  45912. private _updateGizmoRotationToMatchAttachedMesh;
  45913. private _snapDistance;
  45914. private _scaleRatio;
  45915. /** Fires an event when any of it's sub gizmos are dragged */
  45916. onDragStartObservable: Observable<unknown>;
  45917. /** Fires an event when any of it's sub gizmos are released from dragging */
  45918. onDragEndObservable: Observable<unknown>;
  45919. /**
  45920. * If set to true, planar drag is enabled
  45921. */
  45922. private _planarGizmoEnabled;
  45923. get attachedMesh(): Nullable<AbstractMesh>;
  45924. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45925. /**
  45926. * Creates a PositionGizmo
  45927. * @param gizmoLayer The utility layer the gizmo will be added to
  45928. */
  45929. constructor(gizmoLayer?: UtilityLayerRenderer);
  45930. /**
  45931. * If the planar drag gizmo is enabled
  45932. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45933. */
  45934. set planarGizmoEnabled(value: boolean);
  45935. get planarGizmoEnabled(): boolean;
  45936. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45937. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45938. /**
  45939. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45940. */
  45941. set snapDistance(value: number);
  45942. get snapDistance(): number;
  45943. /**
  45944. * Ratio for the scale of the gizmo (Default: 1)
  45945. */
  45946. set scaleRatio(value: number);
  45947. get scaleRatio(): number;
  45948. /**
  45949. * Disposes of the gizmo
  45950. */
  45951. dispose(): void;
  45952. /**
  45953. * CustomMeshes are not supported by this gizmo
  45954. * @param mesh The mesh to replace the default mesh of the gizmo
  45955. */
  45956. setCustomMesh(mesh: Mesh): void;
  45957. }
  45958. }
  45959. declare module BABYLON {
  45960. /**
  45961. * Single axis drag gizmo
  45962. */
  45963. export class AxisDragGizmo extends Gizmo {
  45964. /**
  45965. * Drag behavior responsible for the gizmos dragging interactions
  45966. */
  45967. dragBehavior: PointerDragBehavior;
  45968. private _pointerObserver;
  45969. /**
  45970. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45971. */
  45972. snapDistance: number;
  45973. /**
  45974. * Event that fires each time the gizmo snaps to a new location.
  45975. * * snapDistance is the the change in distance
  45976. */
  45977. onSnapObservable: Observable<{
  45978. snapDistance: number;
  45979. }>;
  45980. private _isEnabled;
  45981. private _parent;
  45982. private _arrow;
  45983. private _coloredMaterial;
  45984. private _hoverMaterial;
  45985. /** @hidden */
  45986. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45987. /** @hidden */
  45988. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45989. /**
  45990. * Creates an AxisDragGizmo
  45991. * @param gizmoLayer The utility layer the gizmo will be added to
  45992. * @param dragAxis The axis which the gizmo will be able to drag on
  45993. * @param color The color of the gizmo
  45994. */
  45995. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45996. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45997. /**
  45998. * If the gizmo is enabled
  45999. */
  46000. set isEnabled(value: boolean);
  46001. get isEnabled(): boolean;
  46002. /**
  46003. * Disposes of the gizmo
  46004. */
  46005. dispose(): void;
  46006. }
  46007. }
  46008. declare module BABYLON.Debug {
  46009. /**
  46010. * The Axes viewer will show 3 axes in a specific point in space
  46011. */
  46012. export class AxesViewer {
  46013. private _xAxis;
  46014. private _yAxis;
  46015. private _zAxis;
  46016. private _scaleLinesFactor;
  46017. private _instanced;
  46018. /**
  46019. * Gets the hosting scene
  46020. */
  46021. scene: Scene;
  46022. /**
  46023. * Gets or sets a number used to scale line length
  46024. */
  46025. scaleLines: number;
  46026. /** Gets the node hierarchy used to render x-axis */
  46027. get xAxis(): TransformNode;
  46028. /** Gets the node hierarchy used to render y-axis */
  46029. get yAxis(): TransformNode;
  46030. /** Gets the node hierarchy used to render z-axis */
  46031. get zAxis(): TransformNode;
  46032. /**
  46033. * Creates a new AxesViewer
  46034. * @param scene defines the hosting scene
  46035. * @param scaleLines defines a number used to scale line length (1 by default)
  46036. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46037. * @param xAxis defines the node hierarchy used to render the x-axis
  46038. * @param yAxis defines the node hierarchy used to render the y-axis
  46039. * @param zAxis defines the node hierarchy used to render the z-axis
  46040. */
  46041. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46042. /**
  46043. * Force the viewer to update
  46044. * @param position defines the position of the viewer
  46045. * @param xaxis defines the x axis of the viewer
  46046. * @param yaxis defines the y axis of the viewer
  46047. * @param zaxis defines the z axis of the viewer
  46048. */
  46049. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46050. /**
  46051. * Creates an instance of this axes viewer.
  46052. * @returns a new axes viewer with instanced meshes
  46053. */
  46054. createInstance(): AxesViewer;
  46055. /** Releases resources */
  46056. dispose(): void;
  46057. private static _SetRenderingGroupId;
  46058. }
  46059. }
  46060. declare module BABYLON.Debug {
  46061. /**
  46062. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46063. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46064. */
  46065. export class BoneAxesViewer extends AxesViewer {
  46066. /**
  46067. * Gets or sets the target mesh where to display the axes viewer
  46068. */
  46069. mesh: Nullable<Mesh>;
  46070. /**
  46071. * Gets or sets the target bone where to display the axes viewer
  46072. */
  46073. bone: Nullable<Bone>;
  46074. /** Gets current position */
  46075. pos: Vector3;
  46076. /** Gets direction of X axis */
  46077. xaxis: Vector3;
  46078. /** Gets direction of Y axis */
  46079. yaxis: Vector3;
  46080. /** Gets direction of Z axis */
  46081. zaxis: Vector3;
  46082. /**
  46083. * Creates a new BoneAxesViewer
  46084. * @param scene defines the hosting scene
  46085. * @param bone defines the target bone
  46086. * @param mesh defines the target mesh
  46087. * @param scaleLines defines a scaling factor for line length (1 by default)
  46088. */
  46089. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46090. /**
  46091. * Force the viewer to update
  46092. */
  46093. update(): void;
  46094. /** Releases resources */
  46095. dispose(): void;
  46096. }
  46097. }
  46098. declare module BABYLON {
  46099. /**
  46100. * Interface used to define scene explorer extensibility option
  46101. */
  46102. export interface IExplorerExtensibilityOption {
  46103. /**
  46104. * Define the option label
  46105. */
  46106. label: string;
  46107. /**
  46108. * Defines the action to execute on click
  46109. */
  46110. action: (entity: any) => void;
  46111. }
  46112. /**
  46113. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46114. */
  46115. export interface IExplorerExtensibilityGroup {
  46116. /**
  46117. * Defines a predicate to test if a given type mut be extended
  46118. */
  46119. predicate: (entity: any) => boolean;
  46120. /**
  46121. * Gets the list of options added to a type
  46122. */
  46123. entries: IExplorerExtensibilityOption[];
  46124. }
  46125. /**
  46126. * Interface used to define the options to use to create the Inspector
  46127. */
  46128. export interface IInspectorOptions {
  46129. /**
  46130. * Display in overlay mode (default: false)
  46131. */
  46132. overlay?: boolean;
  46133. /**
  46134. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46135. */
  46136. globalRoot?: HTMLElement;
  46137. /**
  46138. * Display the Scene explorer
  46139. */
  46140. showExplorer?: boolean;
  46141. /**
  46142. * Display the property inspector
  46143. */
  46144. showInspector?: boolean;
  46145. /**
  46146. * Display in embed mode (both panes on the right)
  46147. */
  46148. embedMode?: boolean;
  46149. /**
  46150. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46151. */
  46152. handleResize?: boolean;
  46153. /**
  46154. * Allow the panes to popup (default: true)
  46155. */
  46156. enablePopup?: boolean;
  46157. /**
  46158. * Allow the panes to be closed by users (default: true)
  46159. */
  46160. enableClose?: boolean;
  46161. /**
  46162. * Optional list of extensibility entries
  46163. */
  46164. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46165. /**
  46166. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46167. */
  46168. inspectorURL?: string;
  46169. /**
  46170. * Optional initial tab (default to DebugLayerTab.Properties)
  46171. */
  46172. initialTab?: DebugLayerTab;
  46173. }
  46174. interface Scene {
  46175. /**
  46176. * @hidden
  46177. * Backing field
  46178. */
  46179. _debugLayer: DebugLayer;
  46180. /**
  46181. * Gets the debug layer (aka Inspector) associated with the scene
  46182. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46183. */
  46184. debugLayer: DebugLayer;
  46185. }
  46186. /**
  46187. * Enum of inspector action tab
  46188. */
  46189. export enum DebugLayerTab {
  46190. /**
  46191. * Properties tag (default)
  46192. */
  46193. Properties = 0,
  46194. /**
  46195. * Debug tab
  46196. */
  46197. Debug = 1,
  46198. /**
  46199. * Statistics tab
  46200. */
  46201. Statistics = 2,
  46202. /**
  46203. * Tools tab
  46204. */
  46205. Tools = 3,
  46206. /**
  46207. * Settings tab
  46208. */
  46209. Settings = 4
  46210. }
  46211. /**
  46212. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46213. * what is happening in your scene
  46214. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46215. */
  46216. export class DebugLayer {
  46217. /**
  46218. * Define the url to get the inspector script from.
  46219. * By default it uses the babylonjs CDN.
  46220. * @ignoreNaming
  46221. */
  46222. static InspectorURL: string;
  46223. private _scene;
  46224. private BJSINSPECTOR;
  46225. private _onPropertyChangedObservable?;
  46226. /**
  46227. * Observable triggered when a property is changed through the inspector.
  46228. */
  46229. get onPropertyChangedObservable(): any;
  46230. /**
  46231. * Instantiates a new debug layer.
  46232. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46233. * what is happening in your scene
  46234. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46235. * @param scene Defines the scene to inspect
  46236. */
  46237. constructor(scene: Scene);
  46238. /** Creates the inspector window. */
  46239. private _createInspector;
  46240. /**
  46241. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46242. * @param entity defines the entity to select
  46243. * @param lineContainerTitle defines the specific block to highlight
  46244. */
  46245. select(entity: any, lineContainerTitle?: string): void;
  46246. /** Get the inspector from bundle or global */
  46247. private _getGlobalInspector;
  46248. /**
  46249. * Get if the inspector is visible or not.
  46250. * @returns true if visible otherwise, false
  46251. */
  46252. isVisible(): boolean;
  46253. /**
  46254. * Hide the inspector and close its window.
  46255. */
  46256. hide(): void;
  46257. /**
  46258. * Launch the debugLayer.
  46259. * @param config Define the configuration of the inspector
  46260. * @return a promise fulfilled when the debug layer is visible
  46261. */
  46262. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46263. }
  46264. }
  46265. declare module BABYLON {
  46266. /**
  46267. * Class containing static functions to help procedurally build meshes
  46268. */
  46269. export class BoxBuilder {
  46270. /**
  46271. * Creates a box mesh
  46272. * * The parameter `size` sets the size (float) of each box side (default 1)
  46273. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46274. * * 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)
  46275. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46277. * * 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
  46278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46279. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46280. * @param name defines the name of the mesh
  46281. * @param options defines the options used to create the mesh
  46282. * @param scene defines the hosting scene
  46283. * @returns the box mesh
  46284. */
  46285. static CreateBox(name: string, options: {
  46286. size?: number;
  46287. width?: number;
  46288. height?: number;
  46289. depth?: number;
  46290. faceUV?: Vector4[];
  46291. faceColors?: Color4[];
  46292. sideOrientation?: number;
  46293. frontUVs?: Vector4;
  46294. backUVs?: Vector4;
  46295. wrap?: boolean;
  46296. topBaseAt?: number;
  46297. bottomBaseAt?: number;
  46298. updatable?: boolean;
  46299. }, scene?: Nullable<Scene>): Mesh;
  46300. }
  46301. }
  46302. declare module BABYLON.Debug {
  46303. /**
  46304. * Used to show the physics impostor around the specific mesh
  46305. */
  46306. export class PhysicsViewer {
  46307. /** @hidden */
  46308. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46309. /** @hidden */
  46310. protected _meshes: Array<Nullable<AbstractMesh>>;
  46311. /** @hidden */
  46312. protected _scene: Nullable<Scene>;
  46313. /** @hidden */
  46314. protected _numMeshes: number;
  46315. /** @hidden */
  46316. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46317. private _renderFunction;
  46318. private _utilityLayer;
  46319. private _debugBoxMesh;
  46320. private _debugSphereMesh;
  46321. private _debugCylinderMesh;
  46322. private _debugMaterial;
  46323. private _debugMeshMeshes;
  46324. /**
  46325. * Creates a new PhysicsViewer
  46326. * @param scene defines the hosting scene
  46327. */
  46328. constructor(scene: Scene);
  46329. /** @hidden */
  46330. protected _updateDebugMeshes(): void;
  46331. /**
  46332. * Renders a specified physic impostor
  46333. * @param impostor defines the impostor to render
  46334. * @param targetMesh defines the mesh represented by the impostor
  46335. * @returns the new debug mesh used to render the impostor
  46336. */
  46337. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46338. /**
  46339. * Hides a specified physic impostor
  46340. * @param impostor defines the impostor to hide
  46341. */
  46342. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46343. private _getDebugMaterial;
  46344. private _getDebugBoxMesh;
  46345. private _getDebugSphereMesh;
  46346. private _getDebugCylinderMesh;
  46347. private _getDebugMeshMesh;
  46348. private _getDebugMesh;
  46349. /** Releases all resources */
  46350. dispose(): void;
  46351. }
  46352. }
  46353. declare module BABYLON {
  46354. /**
  46355. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46356. * in order to better appreciate the issue one might have.
  46357. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46358. */
  46359. export class RayHelper {
  46360. /**
  46361. * Defines the ray we are currently tryin to visualize.
  46362. */
  46363. ray: Nullable<Ray>;
  46364. private _renderPoints;
  46365. private _renderLine;
  46366. private _renderFunction;
  46367. private _scene;
  46368. private _updateToMeshFunction;
  46369. private _attachedToMesh;
  46370. private _meshSpaceDirection;
  46371. private _meshSpaceOrigin;
  46372. /**
  46373. * Helper function to create a colored helper in a scene in one line.
  46374. * @param ray Defines the ray we are currently tryin to visualize
  46375. * @param scene Defines the scene the ray is used in
  46376. * @param color Defines the color we want to see the ray in
  46377. * @returns The newly created ray helper.
  46378. */
  46379. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46380. /**
  46381. * Instantiate a new ray helper.
  46382. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46383. * in order to better appreciate the issue one might have.
  46384. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46385. * @param ray Defines the ray we are currently tryin to visualize
  46386. */
  46387. constructor(ray: Ray);
  46388. /**
  46389. * Shows the ray we are willing to debug.
  46390. * @param scene Defines the scene the ray needs to be rendered in
  46391. * @param color Defines the color the ray needs to be rendered in
  46392. */
  46393. show(scene: Scene, color?: Color3): void;
  46394. /**
  46395. * Hides the ray we are debugging.
  46396. */
  46397. hide(): void;
  46398. private _render;
  46399. /**
  46400. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46401. * @param mesh Defines the mesh we want the helper attached to
  46402. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46403. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46404. * @param length Defines the length of the ray
  46405. */
  46406. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46407. /**
  46408. * Detach the ray helper from the mesh it has previously been attached to.
  46409. */
  46410. detachFromMesh(): void;
  46411. private _updateToMesh;
  46412. /**
  46413. * Dispose the helper and release its associated resources.
  46414. */
  46415. dispose(): void;
  46416. }
  46417. }
  46418. declare module BABYLON.Debug {
  46419. /**
  46420. * Class used to render a debug view of a given skeleton
  46421. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46422. */
  46423. export class SkeletonViewer {
  46424. /** defines the skeleton to render */
  46425. skeleton: Skeleton;
  46426. /** defines the mesh attached to the skeleton */
  46427. mesh: AbstractMesh;
  46428. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46429. autoUpdateBonesMatrices: boolean;
  46430. /** defines the rendering group id to use with the viewer */
  46431. renderingGroupId: number;
  46432. /** Gets or sets the color used to render the skeleton */
  46433. color: Color3;
  46434. private _scene;
  46435. private _debugLines;
  46436. private _debugMesh;
  46437. private _isEnabled;
  46438. private _renderFunction;
  46439. private _utilityLayer;
  46440. /**
  46441. * Returns the mesh used to render the bones
  46442. */
  46443. get debugMesh(): Nullable<LinesMesh>;
  46444. /**
  46445. * Creates a new SkeletonViewer
  46446. * @param skeleton defines the skeleton to render
  46447. * @param mesh defines the mesh attached to the skeleton
  46448. * @param scene defines the hosting scene
  46449. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46450. * @param renderingGroupId defines the rendering group id to use with the viewer
  46451. */
  46452. constructor(
  46453. /** defines the skeleton to render */
  46454. skeleton: Skeleton,
  46455. /** defines the mesh attached to the skeleton */
  46456. mesh: AbstractMesh, scene: Scene,
  46457. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46458. autoUpdateBonesMatrices?: boolean,
  46459. /** defines the rendering group id to use with the viewer */
  46460. renderingGroupId?: number);
  46461. /** Gets or sets a boolean indicating if the viewer is enabled */
  46462. set isEnabled(value: boolean);
  46463. get isEnabled(): boolean;
  46464. private _getBonePosition;
  46465. private _getLinesForBonesWithLength;
  46466. private _getLinesForBonesNoLength;
  46467. /** Update the viewer to sync with current skeleton state */
  46468. update(): void;
  46469. /** Release associated resources */
  46470. dispose(): void;
  46471. }
  46472. }
  46473. declare module BABYLON {
  46474. /**
  46475. * Options to create the null engine
  46476. */
  46477. export class NullEngineOptions {
  46478. /**
  46479. * Render width (Default: 512)
  46480. */
  46481. renderWidth: number;
  46482. /**
  46483. * Render height (Default: 256)
  46484. */
  46485. renderHeight: number;
  46486. /**
  46487. * Texture size (Default: 512)
  46488. */
  46489. textureSize: number;
  46490. /**
  46491. * If delta time between frames should be constant
  46492. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46493. */
  46494. deterministicLockstep: boolean;
  46495. /**
  46496. * Maximum about of steps between frames (Default: 4)
  46497. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46498. */
  46499. lockstepMaxSteps: number;
  46500. }
  46501. /**
  46502. * The null engine class provides support for headless version of babylon.js.
  46503. * This can be used in server side scenario or for testing purposes
  46504. */
  46505. export class NullEngine extends Engine {
  46506. private _options;
  46507. /**
  46508. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46509. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46510. * @returns true if engine is in deterministic lock step mode
  46511. */
  46512. isDeterministicLockStep(): boolean;
  46513. /**
  46514. * Gets the max steps when engine is running in deterministic lock step
  46515. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46516. * @returns the max steps
  46517. */
  46518. getLockstepMaxSteps(): number;
  46519. /**
  46520. * Gets the current hardware scaling level.
  46521. * By default the hardware scaling level is computed from the window device ratio.
  46522. * 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.
  46523. * @returns a number indicating the current hardware scaling level
  46524. */
  46525. getHardwareScalingLevel(): number;
  46526. constructor(options?: NullEngineOptions);
  46527. /**
  46528. * Creates a vertex buffer
  46529. * @param vertices the data for the vertex buffer
  46530. * @returns the new WebGL static buffer
  46531. */
  46532. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46533. /**
  46534. * Creates a new index buffer
  46535. * @param indices defines the content of the index buffer
  46536. * @param updatable defines if the index buffer must be updatable
  46537. * @returns a new webGL buffer
  46538. */
  46539. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46540. /**
  46541. * Clear the current render buffer or the current render target (if any is set up)
  46542. * @param color defines the color to use
  46543. * @param backBuffer defines if the back buffer must be cleared
  46544. * @param depth defines if the depth buffer must be cleared
  46545. * @param stencil defines if the stencil buffer must be cleared
  46546. */
  46547. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46548. /**
  46549. * Gets the current render width
  46550. * @param useScreen defines if screen size must be used (or the current render target if any)
  46551. * @returns a number defining the current render width
  46552. */
  46553. getRenderWidth(useScreen?: boolean): number;
  46554. /**
  46555. * Gets the current render height
  46556. * @param useScreen defines if screen size must be used (or the current render target if any)
  46557. * @returns a number defining the current render height
  46558. */
  46559. getRenderHeight(useScreen?: boolean): number;
  46560. /**
  46561. * Set the WebGL's viewport
  46562. * @param viewport defines the viewport element to be used
  46563. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46564. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46565. */
  46566. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46567. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46568. /**
  46569. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46570. * @param pipelineContext defines the pipeline context to use
  46571. * @param uniformsNames defines the list of uniform names
  46572. * @returns an array of webGL uniform locations
  46573. */
  46574. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46575. /**
  46576. * Gets the lsit of active attributes for a given webGL program
  46577. * @param pipelineContext defines the pipeline context to use
  46578. * @param attributesNames defines the list of attribute names to get
  46579. * @returns an array of indices indicating the offset of each attribute
  46580. */
  46581. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46582. /**
  46583. * Binds an effect to the webGL context
  46584. * @param effect defines the effect to bind
  46585. */
  46586. bindSamplers(effect: Effect): void;
  46587. /**
  46588. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46589. * @param effect defines the effect to activate
  46590. */
  46591. enableEffect(effect: Effect): void;
  46592. /**
  46593. * Set various states to the webGL context
  46594. * @param culling defines backface culling state
  46595. * @param zOffset defines the value to apply to zOffset (0 by default)
  46596. * @param force defines if states must be applied even if cache is up to date
  46597. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46598. */
  46599. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46600. /**
  46601. * Set the value of an uniform to an array of int32
  46602. * @param uniform defines the webGL uniform location where to store the value
  46603. * @param array defines the array of int32 to store
  46604. */
  46605. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46606. /**
  46607. * Set the value of an uniform to an array of int32 (stored as vec2)
  46608. * @param uniform defines the webGL uniform location where to store the value
  46609. * @param array defines the array of int32 to store
  46610. */
  46611. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46612. /**
  46613. * Set the value of an uniform to an array of int32 (stored as vec3)
  46614. * @param uniform defines the webGL uniform location where to store the value
  46615. * @param array defines the array of int32 to store
  46616. */
  46617. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46618. /**
  46619. * Set the value of an uniform to an array of int32 (stored as vec4)
  46620. * @param uniform defines the webGL uniform location where to store the value
  46621. * @param array defines the array of int32 to store
  46622. */
  46623. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46624. /**
  46625. * Set the value of an uniform to an array of float32
  46626. * @param uniform defines the webGL uniform location where to store the value
  46627. * @param array defines the array of float32 to store
  46628. */
  46629. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46630. /**
  46631. * Set the value of an uniform to an array of float32 (stored as vec2)
  46632. * @param uniform defines the webGL uniform location where to store the value
  46633. * @param array defines the array of float32 to store
  46634. */
  46635. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46636. /**
  46637. * Set the value of an uniform to an array of float32 (stored as vec3)
  46638. * @param uniform defines the webGL uniform location where to store the value
  46639. * @param array defines the array of float32 to store
  46640. */
  46641. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46642. /**
  46643. * Set the value of an uniform to an array of float32 (stored as vec4)
  46644. * @param uniform defines the webGL uniform location where to store the value
  46645. * @param array defines the array of float32 to store
  46646. */
  46647. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46648. /**
  46649. * Set the value of an uniform to an array of number
  46650. * @param uniform defines the webGL uniform location where to store the value
  46651. * @param array defines the array of number to store
  46652. */
  46653. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46654. /**
  46655. * Set the value of an uniform to an array of number (stored as vec2)
  46656. * @param uniform defines the webGL uniform location where to store the value
  46657. * @param array defines the array of number to store
  46658. */
  46659. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46660. /**
  46661. * Set the value of an uniform to an array of number (stored as vec3)
  46662. * @param uniform defines the webGL uniform location where to store the value
  46663. * @param array defines the array of number to store
  46664. */
  46665. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46666. /**
  46667. * Set the value of an uniform to an array of number (stored as vec4)
  46668. * @param uniform defines the webGL uniform location where to store the value
  46669. * @param array defines the array of number to store
  46670. */
  46671. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46672. /**
  46673. * Set the value of an uniform to an array of float32 (stored as matrices)
  46674. * @param uniform defines the webGL uniform location where to store the value
  46675. * @param matrices defines the array of float32 to store
  46676. */
  46677. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46678. /**
  46679. * Set the value of an uniform to a matrix (3x3)
  46680. * @param uniform defines the webGL uniform location where to store the value
  46681. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46682. */
  46683. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46684. /**
  46685. * Set the value of an uniform to a matrix (2x2)
  46686. * @param uniform defines the webGL uniform location where to store the value
  46687. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46688. */
  46689. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46690. /**
  46691. * Set the value of an uniform to a number (float)
  46692. * @param uniform defines the webGL uniform location where to store the value
  46693. * @param value defines the float number to store
  46694. */
  46695. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46696. /**
  46697. * Set the value of an uniform to a vec2
  46698. * @param uniform defines the webGL uniform location where to store the value
  46699. * @param x defines the 1st component of the value
  46700. * @param y defines the 2nd component of the value
  46701. */
  46702. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46703. /**
  46704. * Set the value of an uniform to a vec3
  46705. * @param uniform defines the webGL uniform location where to store the value
  46706. * @param x defines the 1st component of the value
  46707. * @param y defines the 2nd component of the value
  46708. * @param z defines the 3rd component of the value
  46709. */
  46710. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46711. /**
  46712. * Set the value of an uniform to a boolean
  46713. * @param uniform defines the webGL uniform location where to store the value
  46714. * @param bool defines the boolean to store
  46715. */
  46716. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46717. /**
  46718. * Set the value of an uniform to a vec4
  46719. * @param uniform defines the webGL uniform location where to store the value
  46720. * @param x defines the 1st component of the value
  46721. * @param y defines the 2nd component of the value
  46722. * @param z defines the 3rd component of the value
  46723. * @param w defines the 4th component of the value
  46724. */
  46725. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46726. /**
  46727. * Sets the current alpha mode
  46728. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46729. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46730. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46731. */
  46732. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46733. /**
  46734. * Bind webGl buffers directly to the webGL context
  46735. * @param vertexBuffers defines the vertex buffer to bind
  46736. * @param indexBuffer defines the index buffer to bind
  46737. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46738. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46739. * @param effect defines the effect associated with the vertex buffer
  46740. */
  46741. bindBuffers(vertexBuffers: {
  46742. [key: string]: VertexBuffer;
  46743. }, indexBuffer: DataBuffer, effect: Effect): void;
  46744. /**
  46745. * Force the entire cache to be cleared
  46746. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46747. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46748. */
  46749. wipeCaches(bruteForce?: boolean): void;
  46750. /**
  46751. * Send a draw order
  46752. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46753. * @param indexStart defines the starting index
  46754. * @param indexCount defines the number of index to draw
  46755. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46756. */
  46757. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46758. /**
  46759. * Draw a list of indexed primitives
  46760. * @param fillMode defines the primitive to use
  46761. * @param indexStart defines the starting index
  46762. * @param indexCount defines the number of index to draw
  46763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46764. */
  46765. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46766. /**
  46767. * Draw a list of unindexed primitives
  46768. * @param fillMode defines the primitive to use
  46769. * @param verticesStart defines the index of first vertex to draw
  46770. * @param verticesCount defines the count of vertices to draw
  46771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46772. */
  46773. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46774. /** @hidden */
  46775. _createTexture(): WebGLTexture;
  46776. /** @hidden */
  46777. _releaseTexture(texture: InternalTexture): void;
  46778. /**
  46779. * Usually called from Texture.ts.
  46780. * Passed information to create a WebGLTexture
  46781. * @param urlArg defines a value which contains one of the following:
  46782. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46783. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46784. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46785. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46786. * @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)
  46787. * @param scene needed for loading to the correct scene
  46788. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46789. * @param onLoad optional callback to be called upon successful completion
  46790. * @param onError optional callback to be called upon failure
  46791. * @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
  46792. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46793. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46794. * @param forcedExtension defines the extension to use to pick the right loader
  46795. * @param mimeType defines an optional mime type
  46796. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46797. */
  46798. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  46799. /**
  46800. * Creates a new render target texture
  46801. * @param size defines the size of the texture
  46802. * @param options defines the options used to create the texture
  46803. * @returns a new render target texture stored in an InternalTexture
  46804. */
  46805. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46806. /**
  46807. * Update the sampling mode of a given texture
  46808. * @param samplingMode defines the required sampling mode
  46809. * @param texture defines the texture to update
  46810. */
  46811. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46812. /**
  46813. * Binds the frame buffer to the specified texture.
  46814. * @param texture The texture to render to or null for the default canvas
  46815. * @param faceIndex The face of the texture to render to in case of cube texture
  46816. * @param requiredWidth The width of the target to render to
  46817. * @param requiredHeight The height of the target to render to
  46818. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46819. * @param lodLevel defines le lod level to bind to the frame buffer
  46820. */
  46821. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46822. /**
  46823. * Unbind the current render target texture from the webGL context
  46824. * @param texture defines the render target texture to unbind
  46825. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46826. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46827. */
  46828. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46829. /**
  46830. * Creates a dynamic vertex buffer
  46831. * @param vertices the data for the dynamic vertex buffer
  46832. * @returns the new WebGL dynamic buffer
  46833. */
  46834. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46835. /**
  46836. * Update the content of a dynamic texture
  46837. * @param texture defines the texture to update
  46838. * @param canvas defines the canvas containing the source
  46839. * @param invertY defines if data must be stored with Y axis inverted
  46840. * @param premulAlpha defines if alpha is stored as premultiplied
  46841. * @param format defines the format of the data
  46842. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46843. */
  46844. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46845. /**
  46846. * Gets a boolean indicating if all created effects are ready
  46847. * @returns true if all effects are ready
  46848. */
  46849. areAllEffectsReady(): boolean;
  46850. /**
  46851. * @hidden
  46852. * Get the current error code of the webGL context
  46853. * @returns the error code
  46854. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46855. */
  46856. getError(): number;
  46857. /** @hidden */
  46858. _getUnpackAlignement(): number;
  46859. /** @hidden */
  46860. _unpackFlipY(value: boolean): void;
  46861. /**
  46862. * Update a dynamic index buffer
  46863. * @param indexBuffer defines the target index buffer
  46864. * @param indices defines the data to update
  46865. * @param offset defines the offset in the target index buffer where update should start
  46866. */
  46867. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46868. /**
  46869. * Updates a dynamic vertex buffer.
  46870. * @param vertexBuffer the vertex buffer to update
  46871. * @param vertices the data used to update the vertex buffer
  46872. * @param byteOffset the byte offset of the data (optional)
  46873. * @param byteLength the byte length of the data (optional)
  46874. */
  46875. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46876. /** @hidden */
  46877. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46878. /** @hidden */
  46879. _bindTexture(channel: number, texture: InternalTexture): void;
  46880. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46881. /**
  46882. * 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
  46883. */
  46884. releaseEffects(): void;
  46885. displayLoadingUI(): void;
  46886. hideLoadingUI(): void;
  46887. /** @hidden */
  46888. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46889. /** @hidden */
  46890. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46891. /** @hidden */
  46892. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46893. /** @hidden */
  46894. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46895. }
  46896. }
  46897. declare module BABYLON {
  46898. /**
  46899. * @hidden
  46900. **/
  46901. export class _TimeToken {
  46902. _startTimeQuery: Nullable<WebGLQuery>;
  46903. _endTimeQuery: Nullable<WebGLQuery>;
  46904. _timeElapsedQuery: Nullable<WebGLQuery>;
  46905. _timeElapsedQueryEnded: boolean;
  46906. }
  46907. }
  46908. declare module BABYLON {
  46909. /** @hidden */
  46910. export class _OcclusionDataStorage {
  46911. /** @hidden */
  46912. occlusionInternalRetryCounter: number;
  46913. /** @hidden */
  46914. isOcclusionQueryInProgress: boolean;
  46915. /** @hidden */
  46916. isOccluded: boolean;
  46917. /** @hidden */
  46918. occlusionRetryCount: number;
  46919. /** @hidden */
  46920. occlusionType: number;
  46921. /** @hidden */
  46922. occlusionQueryAlgorithmType: number;
  46923. }
  46924. interface Engine {
  46925. /**
  46926. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46927. * @return the new query
  46928. */
  46929. createQuery(): WebGLQuery;
  46930. /**
  46931. * Delete and release a webGL query
  46932. * @param query defines the query to delete
  46933. * @return the current engine
  46934. */
  46935. deleteQuery(query: WebGLQuery): Engine;
  46936. /**
  46937. * Check if a given query has resolved and got its value
  46938. * @param query defines the query to check
  46939. * @returns true if the query got its value
  46940. */
  46941. isQueryResultAvailable(query: WebGLQuery): boolean;
  46942. /**
  46943. * Gets the value of a given query
  46944. * @param query defines the query to check
  46945. * @returns the value of the query
  46946. */
  46947. getQueryResult(query: WebGLQuery): number;
  46948. /**
  46949. * Initiates an occlusion query
  46950. * @param algorithmType defines the algorithm to use
  46951. * @param query defines the query to use
  46952. * @returns the current engine
  46953. * @see http://doc.babylonjs.com/features/occlusionquery
  46954. */
  46955. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46956. /**
  46957. * Ends an occlusion query
  46958. * @see http://doc.babylonjs.com/features/occlusionquery
  46959. * @param algorithmType defines the algorithm to use
  46960. * @returns the current engine
  46961. */
  46962. endOcclusionQuery(algorithmType: number): Engine;
  46963. /**
  46964. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46965. * Please note that only one query can be issued at a time
  46966. * @returns a time token used to track the time span
  46967. */
  46968. startTimeQuery(): Nullable<_TimeToken>;
  46969. /**
  46970. * Ends a time query
  46971. * @param token defines the token used to measure the time span
  46972. * @returns the time spent (in ns)
  46973. */
  46974. endTimeQuery(token: _TimeToken): int;
  46975. /** @hidden */
  46976. _currentNonTimestampToken: Nullable<_TimeToken>;
  46977. /** @hidden */
  46978. _createTimeQuery(): WebGLQuery;
  46979. /** @hidden */
  46980. _deleteTimeQuery(query: WebGLQuery): void;
  46981. /** @hidden */
  46982. _getGlAlgorithmType(algorithmType: number): number;
  46983. /** @hidden */
  46984. _getTimeQueryResult(query: WebGLQuery): any;
  46985. /** @hidden */
  46986. _getTimeQueryAvailability(query: WebGLQuery): any;
  46987. }
  46988. interface AbstractMesh {
  46989. /**
  46990. * Backing filed
  46991. * @hidden
  46992. */
  46993. __occlusionDataStorage: _OcclusionDataStorage;
  46994. /**
  46995. * Access property
  46996. * @hidden
  46997. */
  46998. _occlusionDataStorage: _OcclusionDataStorage;
  46999. /**
  47000. * 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.
  47001. * The default value is -1 which means don't break the query and wait till the result
  47002. * @see http://doc.babylonjs.com/features/occlusionquery
  47003. */
  47004. occlusionRetryCount: number;
  47005. /**
  47006. * 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:
  47007. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47008. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47009. * * 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.
  47010. * @see http://doc.babylonjs.com/features/occlusionquery
  47011. */
  47012. occlusionType: number;
  47013. /**
  47014. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47015. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47016. * * 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.
  47017. * @see http://doc.babylonjs.com/features/occlusionquery
  47018. */
  47019. occlusionQueryAlgorithmType: number;
  47020. /**
  47021. * 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
  47022. * @see http://doc.babylonjs.com/features/occlusionquery
  47023. */
  47024. isOccluded: boolean;
  47025. /**
  47026. * Flag to check the progress status of the query
  47027. * @see http://doc.babylonjs.com/features/occlusionquery
  47028. */
  47029. isOcclusionQueryInProgress: boolean;
  47030. }
  47031. }
  47032. declare module BABYLON {
  47033. /** @hidden */
  47034. export var _forceTransformFeedbackToBundle: boolean;
  47035. interface Engine {
  47036. /**
  47037. * Creates a webGL transform feedback object
  47038. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47039. * @returns the webGL transform feedback object
  47040. */
  47041. createTransformFeedback(): WebGLTransformFeedback;
  47042. /**
  47043. * Delete a webGL transform feedback object
  47044. * @param value defines the webGL transform feedback object to delete
  47045. */
  47046. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47047. /**
  47048. * Bind a webGL transform feedback object to the webgl context
  47049. * @param value defines the webGL transform feedback object to bind
  47050. */
  47051. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47052. /**
  47053. * Begins a transform feedback operation
  47054. * @param usePoints defines if points or triangles must be used
  47055. */
  47056. beginTransformFeedback(usePoints: boolean): void;
  47057. /**
  47058. * Ends a transform feedback operation
  47059. */
  47060. endTransformFeedback(): void;
  47061. /**
  47062. * Specify the varyings to use with transform feedback
  47063. * @param program defines the associated webGL program
  47064. * @param value defines the list of strings representing the varying names
  47065. */
  47066. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47067. /**
  47068. * Bind a webGL buffer for a transform feedback operation
  47069. * @param value defines the webGL buffer to bind
  47070. */
  47071. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47072. }
  47073. }
  47074. declare module BABYLON {
  47075. /**
  47076. * Creation options of the multi render target texture.
  47077. */
  47078. export interface IMultiRenderTargetOptions {
  47079. /**
  47080. * Define if the texture needs to create mip maps after render.
  47081. */
  47082. generateMipMaps?: boolean;
  47083. /**
  47084. * Define the types of all the draw buffers we want to create
  47085. */
  47086. types?: number[];
  47087. /**
  47088. * Define the sampling modes of all the draw buffers we want to create
  47089. */
  47090. samplingModes?: number[];
  47091. /**
  47092. * Define if a depth buffer is required
  47093. */
  47094. generateDepthBuffer?: boolean;
  47095. /**
  47096. * Define if a stencil buffer is required
  47097. */
  47098. generateStencilBuffer?: boolean;
  47099. /**
  47100. * Define if a depth texture is required instead of a depth buffer
  47101. */
  47102. generateDepthTexture?: boolean;
  47103. /**
  47104. * Define the number of desired draw buffers
  47105. */
  47106. textureCount?: number;
  47107. /**
  47108. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47109. */
  47110. doNotChangeAspectRatio?: boolean;
  47111. /**
  47112. * Define the default type of the buffers we are creating
  47113. */
  47114. defaultType?: number;
  47115. }
  47116. /**
  47117. * A multi render target, like a render target provides the ability to render to a texture.
  47118. * Unlike the render target, it can render to several draw buffers in one draw.
  47119. * This is specially interesting in deferred rendering or for any effects requiring more than
  47120. * just one color from a single pass.
  47121. */
  47122. export class MultiRenderTarget extends RenderTargetTexture {
  47123. private _internalTextures;
  47124. private _textures;
  47125. private _multiRenderTargetOptions;
  47126. /**
  47127. * Get if draw buffers are currently supported by the used hardware and browser.
  47128. */
  47129. get isSupported(): boolean;
  47130. /**
  47131. * Get the list of textures generated by the multi render target.
  47132. */
  47133. get textures(): Texture[];
  47134. /**
  47135. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47136. */
  47137. get depthTexture(): Texture;
  47138. /**
  47139. * Set the wrapping mode on U of all the textures we are rendering to.
  47140. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47141. */
  47142. set wrapU(wrap: number);
  47143. /**
  47144. * Set the wrapping mode on V of all the textures we are rendering to.
  47145. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47146. */
  47147. set wrapV(wrap: number);
  47148. /**
  47149. * Instantiate a new multi render target texture.
  47150. * A multi render target, like a render target provides the ability to render to a texture.
  47151. * Unlike the render target, it can render to several draw buffers in one draw.
  47152. * This is specially interesting in deferred rendering or for any effects requiring more than
  47153. * just one color from a single pass.
  47154. * @param name Define the name of the texture
  47155. * @param size Define the size of the buffers to render to
  47156. * @param count Define the number of target we are rendering into
  47157. * @param scene Define the scene the texture belongs to
  47158. * @param options Define the options used to create the multi render target
  47159. */
  47160. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47161. /** @hidden */
  47162. _rebuild(): void;
  47163. private _createInternalTextures;
  47164. private _createTextures;
  47165. /**
  47166. * Define the number of samples used if MSAA is enabled.
  47167. */
  47168. get samples(): number;
  47169. set samples(value: number);
  47170. /**
  47171. * Resize all the textures in the multi render target.
  47172. * Be carrefull as it will recreate all the data in the new texture.
  47173. * @param size Define the new size
  47174. */
  47175. resize(size: any): void;
  47176. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47177. /**
  47178. * Dispose the render targets and their associated resources
  47179. */
  47180. dispose(): void;
  47181. /**
  47182. * Release all the underlying texture used as draw buffers.
  47183. */
  47184. releaseInternalTextures(): void;
  47185. }
  47186. }
  47187. declare module BABYLON {
  47188. interface ThinEngine {
  47189. /**
  47190. * Unbind a list of render target textures from the webGL context
  47191. * This is used only when drawBuffer extension or webGL2 are active
  47192. * @param textures defines the render target textures to unbind
  47193. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47194. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47195. */
  47196. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47197. /**
  47198. * Create a multi render target texture
  47199. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47200. * @param size defines the size of the texture
  47201. * @param options defines the creation options
  47202. * @returns the cube texture as an InternalTexture
  47203. */
  47204. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47205. /**
  47206. * Update the sample count for a given multiple render target texture
  47207. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47208. * @param textures defines the textures to update
  47209. * @param samples defines the sample count to set
  47210. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47211. */
  47212. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47213. }
  47214. }
  47215. declare module BABYLON {
  47216. /**
  47217. * Class used to define an additional view for the engine
  47218. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47219. */
  47220. export class EngineView {
  47221. /** Defines the canvas where to render the view */
  47222. target: HTMLCanvasElement;
  47223. /** Defines an optional camera used to render the view (will use active camera else) */
  47224. camera?: Camera;
  47225. }
  47226. interface Engine {
  47227. /**
  47228. * Gets or sets the HTML element to use for attaching events
  47229. */
  47230. inputElement: Nullable<HTMLElement>;
  47231. /**
  47232. * Gets the current engine view
  47233. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47234. */
  47235. activeView: Nullable<EngineView>;
  47236. /** Gets or sets the list of views */
  47237. views: EngineView[];
  47238. /**
  47239. * Register a new child canvas
  47240. * @param canvas defines the canvas to register
  47241. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47242. * @returns the associated view
  47243. */
  47244. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47245. /**
  47246. * Remove a registered child canvas
  47247. * @param canvas defines the canvas to remove
  47248. * @returns the current engine
  47249. */
  47250. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47251. }
  47252. }
  47253. declare module BABYLON {
  47254. /**
  47255. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47256. */
  47257. export interface CubeMapInfo {
  47258. /**
  47259. * The pixel array for the front face.
  47260. * This is stored in format, left to right, up to down format.
  47261. */
  47262. front: Nullable<ArrayBufferView>;
  47263. /**
  47264. * The pixel array for the back face.
  47265. * This is stored in format, left to right, up to down format.
  47266. */
  47267. back: Nullable<ArrayBufferView>;
  47268. /**
  47269. * The pixel array for the left face.
  47270. * This is stored in format, left to right, up to down format.
  47271. */
  47272. left: Nullable<ArrayBufferView>;
  47273. /**
  47274. * The pixel array for the right face.
  47275. * This is stored in format, left to right, up to down format.
  47276. */
  47277. right: Nullable<ArrayBufferView>;
  47278. /**
  47279. * The pixel array for the up face.
  47280. * This is stored in format, left to right, up to down format.
  47281. */
  47282. up: Nullable<ArrayBufferView>;
  47283. /**
  47284. * The pixel array for the down face.
  47285. * This is stored in format, left to right, up to down format.
  47286. */
  47287. down: Nullable<ArrayBufferView>;
  47288. /**
  47289. * The size of the cubemap stored.
  47290. *
  47291. * Each faces will be size * size pixels.
  47292. */
  47293. size: number;
  47294. /**
  47295. * The format of the texture.
  47296. *
  47297. * RGBA, RGB.
  47298. */
  47299. format: number;
  47300. /**
  47301. * The type of the texture data.
  47302. *
  47303. * UNSIGNED_INT, FLOAT.
  47304. */
  47305. type: number;
  47306. /**
  47307. * Specifies whether the texture is in gamma space.
  47308. */
  47309. gammaSpace: boolean;
  47310. }
  47311. /**
  47312. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47313. */
  47314. export class PanoramaToCubeMapTools {
  47315. private static FACE_FRONT;
  47316. private static FACE_BACK;
  47317. private static FACE_RIGHT;
  47318. private static FACE_LEFT;
  47319. private static FACE_DOWN;
  47320. private static FACE_UP;
  47321. /**
  47322. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47323. *
  47324. * @param float32Array The source data.
  47325. * @param inputWidth The width of the input panorama.
  47326. * @param inputHeight The height of the input panorama.
  47327. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47328. * @return The cubemap data
  47329. */
  47330. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47331. private static CreateCubemapTexture;
  47332. private static CalcProjectionSpherical;
  47333. }
  47334. }
  47335. declare module BABYLON {
  47336. /**
  47337. * Helper class dealing with the extraction of spherical polynomial dataArray
  47338. * from a cube map.
  47339. */
  47340. export class CubeMapToSphericalPolynomialTools {
  47341. private static FileFaces;
  47342. /**
  47343. * Converts a texture to the according Spherical Polynomial data.
  47344. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47345. *
  47346. * @param texture The texture to extract the information from.
  47347. * @return The Spherical Polynomial data.
  47348. */
  47349. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47350. /**
  47351. * Converts a cubemap to the according Spherical Polynomial data.
  47352. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47353. *
  47354. * @param cubeInfo The Cube map to extract the information from.
  47355. * @return The Spherical Polynomial data.
  47356. */
  47357. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47358. }
  47359. }
  47360. declare module BABYLON {
  47361. interface BaseTexture {
  47362. /**
  47363. * Get the polynomial representation of the texture data.
  47364. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47365. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47366. */
  47367. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47368. }
  47369. }
  47370. declare module BABYLON {
  47371. /** @hidden */
  47372. export var rgbdEncodePixelShader: {
  47373. name: string;
  47374. shader: string;
  47375. };
  47376. }
  47377. declare module BABYLON {
  47378. /** @hidden */
  47379. export var rgbdDecodePixelShader: {
  47380. name: string;
  47381. shader: string;
  47382. };
  47383. }
  47384. declare module BABYLON {
  47385. /**
  47386. * Raw texture data and descriptor sufficient for WebGL texture upload
  47387. */
  47388. export interface EnvironmentTextureInfo {
  47389. /**
  47390. * Version of the environment map
  47391. */
  47392. version: number;
  47393. /**
  47394. * Width of image
  47395. */
  47396. width: number;
  47397. /**
  47398. * Irradiance information stored in the file.
  47399. */
  47400. irradiance: any;
  47401. /**
  47402. * Specular information stored in the file.
  47403. */
  47404. specular: any;
  47405. }
  47406. /**
  47407. * Defines One Image in the file. It requires only the position in the file
  47408. * as well as the length.
  47409. */
  47410. interface BufferImageData {
  47411. /**
  47412. * Length of the image data.
  47413. */
  47414. length: number;
  47415. /**
  47416. * Position of the data from the null terminator delimiting the end of the JSON.
  47417. */
  47418. position: number;
  47419. }
  47420. /**
  47421. * Defines the specular data enclosed in the file.
  47422. * This corresponds to the version 1 of the data.
  47423. */
  47424. export interface EnvironmentTextureSpecularInfoV1 {
  47425. /**
  47426. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47427. */
  47428. specularDataPosition?: number;
  47429. /**
  47430. * This contains all the images data needed to reconstruct the cubemap.
  47431. */
  47432. mipmaps: Array<BufferImageData>;
  47433. /**
  47434. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47435. */
  47436. lodGenerationScale: number;
  47437. }
  47438. /**
  47439. * Sets of helpers addressing the serialization and deserialization of environment texture
  47440. * stored in a BabylonJS env file.
  47441. * Those files are usually stored as .env files.
  47442. */
  47443. export class EnvironmentTextureTools {
  47444. /**
  47445. * Magic number identifying the env file.
  47446. */
  47447. private static _MagicBytes;
  47448. /**
  47449. * Gets the environment info from an env file.
  47450. * @param data The array buffer containing the .env bytes.
  47451. * @returns the environment file info (the json header) if successfully parsed.
  47452. */
  47453. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47454. /**
  47455. * Creates an environment texture from a loaded cube texture.
  47456. * @param texture defines the cube texture to convert in env file
  47457. * @return a promise containing the environment data if succesfull.
  47458. */
  47459. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47460. /**
  47461. * Creates a JSON representation of the spherical data.
  47462. * @param texture defines the texture containing the polynomials
  47463. * @return the JSON representation of the spherical info
  47464. */
  47465. private static _CreateEnvTextureIrradiance;
  47466. /**
  47467. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47468. * @param data the image data
  47469. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47470. * @return the views described by info providing access to the underlying buffer
  47471. */
  47472. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47473. /**
  47474. * Uploads the texture info contained in the env file to the GPU.
  47475. * @param texture defines the internal texture to upload to
  47476. * @param data defines the data to load
  47477. * @param info defines the texture info retrieved through the GetEnvInfo method
  47478. * @returns a promise
  47479. */
  47480. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47481. private static _OnImageReadyAsync;
  47482. /**
  47483. * Uploads the levels of image data to the GPU.
  47484. * @param texture defines the internal texture to upload to
  47485. * @param imageData defines the array buffer views of image data [mipmap][face]
  47486. * @returns a promise
  47487. */
  47488. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47489. /**
  47490. * Uploads spherical polynomials information to the texture.
  47491. * @param texture defines the texture we are trying to upload the information to
  47492. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47493. */
  47494. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47495. /** @hidden */
  47496. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47497. }
  47498. }
  47499. declare module BABYLON {
  47500. /**
  47501. * Contains position and normal vectors for a vertex
  47502. */
  47503. export class PositionNormalVertex {
  47504. /** the position of the vertex (defaut: 0,0,0) */
  47505. position: Vector3;
  47506. /** the normal of the vertex (defaut: 0,1,0) */
  47507. normal: Vector3;
  47508. /**
  47509. * Creates a PositionNormalVertex
  47510. * @param position the position of the vertex (defaut: 0,0,0)
  47511. * @param normal the normal of the vertex (defaut: 0,1,0)
  47512. */
  47513. constructor(
  47514. /** the position of the vertex (defaut: 0,0,0) */
  47515. position?: Vector3,
  47516. /** the normal of the vertex (defaut: 0,1,0) */
  47517. normal?: Vector3);
  47518. /**
  47519. * Clones the PositionNormalVertex
  47520. * @returns the cloned PositionNormalVertex
  47521. */
  47522. clone(): PositionNormalVertex;
  47523. }
  47524. /**
  47525. * Contains position, normal and uv vectors for a vertex
  47526. */
  47527. export class PositionNormalTextureVertex {
  47528. /** the position of the vertex (defaut: 0,0,0) */
  47529. position: Vector3;
  47530. /** the normal of the vertex (defaut: 0,1,0) */
  47531. normal: Vector3;
  47532. /** the uv of the vertex (default: 0,0) */
  47533. uv: Vector2;
  47534. /**
  47535. * Creates a PositionNormalTextureVertex
  47536. * @param position the position of the vertex (defaut: 0,0,0)
  47537. * @param normal the normal of the vertex (defaut: 0,1,0)
  47538. * @param uv the uv of the vertex (default: 0,0)
  47539. */
  47540. constructor(
  47541. /** the position of the vertex (defaut: 0,0,0) */
  47542. position?: Vector3,
  47543. /** the normal of the vertex (defaut: 0,1,0) */
  47544. normal?: Vector3,
  47545. /** the uv of the vertex (default: 0,0) */
  47546. uv?: Vector2);
  47547. /**
  47548. * Clones the PositionNormalTextureVertex
  47549. * @returns the cloned PositionNormalTextureVertex
  47550. */
  47551. clone(): PositionNormalTextureVertex;
  47552. }
  47553. }
  47554. declare module BABYLON {
  47555. /** @hidden */
  47556. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47557. private _genericAttributeLocation;
  47558. private _varyingLocationCount;
  47559. private _varyingLocationMap;
  47560. private _replacements;
  47561. private _textureCount;
  47562. private _uniforms;
  47563. lineProcessor(line: string): string;
  47564. attributeProcessor(attribute: string): string;
  47565. varyingProcessor(varying: string, isFragment: boolean): string;
  47566. uniformProcessor(uniform: string): string;
  47567. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47568. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47569. }
  47570. }
  47571. declare module BABYLON {
  47572. /**
  47573. * Container for accessors for natively-stored mesh data buffers.
  47574. */
  47575. class NativeDataBuffer extends DataBuffer {
  47576. /**
  47577. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47578. */
  47579. nativeIndexBuffer?: any;
  47580. /**
  47581. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47582. */
  47583. nativeVertexBuffer?: any;
  47584. }
  47585. /** @hidden */
  47586. class NativeTexture extends InternalTexture {
  47587. getInternalTexture(): InternalTexture;
  47588. getViewCount(): number;
  47589. }
  47590. /** @hidden */
  47591. export class NativeEngine extends Engine {
  47592. private readonly _native;
  47593. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47594. private readonly INVALID_HANDLE;
  47595. getHardwareScalingLevel(): number;
  47596. constructor();
  47597. /**
  47598. * Can be used to override the current requestAnimationFrame requester.
  47599. * @hidden
  47600. */
  47601. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47602. /**
  47603. * Override default engine behavior.
  47604. * @param color
  47605. * @param backBuffer
  47606. * @param depth
  47607. * @param stencil
  47608. */
  47609. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47610. /**
  47611. * Gets host document
  47612. * @returns the host document object
  47613. */
  47614. getHostDocument(): Nullable<Document>;
  47615. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47616. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47617. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47618. recordVertexArrayObject(vertexBuffers: {
  47619. [key: string]: VertexBuffer;
  47620. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47621. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47622. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47623. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47624. /**
  47625. * Draw a list of indexed primitives
  47626. * @param fillMode defines the primitive to use
  47627. * @param indexStart defines the starting index
  47628. * @param indexCount defines the number of index to draw
  47629. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47630. */
  47631. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47632. /**
  47633. * Draw a list of unindexed primitives
  47634. * @param fillMode defines the primitive to use
  47635. * @param verticesStart defines the index of first vertex to draw
  47636. * @param verticesCount defines the count of vertices to draw
  47637. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47638. */
  47639. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47640. createPipelineContext(): IPipelineContext;
  47641. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47642. /** @hidden */
  47643. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47644. /** @hidden */
  47645. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47646. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47647. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47648. protected _setProgram(program: WebGLProgram): void;
  47649. _releaseEffect(effect: Effect): void;
  47650. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47651. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47652. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47653. bindSamplers(effect: Effect): void;
  47654. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47655. getRenderWidth(useScreen?: boolean): number;
  47656. getRenderHeight(useScreen?: boolean): number;
  47657. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47658. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47659. /**
  47660. * Set the z offset to apply to current rendering
  47661. * @param value defines the offset to apply
  47662. */
  47663. setZOffset(value: number): void;
  47664. /**
  47665. * Gets the current value of the zOffset
  47666. * @returns the current zOffset state
  47667. */
  47668. getZOffset(): number;
  47669. /**
  47670. * Enable or disable depth buffering
  47671. * @param enable defines the state to set
  47672. */
  47673. setDepthBuffer(enable: boolean): void;
  47674. /**
  47675. * Gets a boolean indicating if depth writing is enabled
  47676. * @returns the current depth writing state
  47677. */
  47678. getDepthWrite(): boolean;
  47679. /**
  47680. * Enable or disable depth writing
  47681. * @param enable defines the state to set
  47682. */
  47683. setDepthWrite(enable: boolean): void;
  47684. /**
  47685. * Enable or disable color writing
  47686. * @param enable defines the state to set
  47687. */
  47688. setColorWrite(enable: boolean): void;
  47689. /**
  47690. * Gets a boolean indicating if color writing is enabled
  47691. * @returns the current color writing state
  47692. */
  47693. getColorWrite(): boolean;
  47694. /**
  47695. * Sets alpha constants used by some alpha blending modes
  47696. * @param r defines the red component
  47697. * @param g defines the green component
  47698. * @param b defines the blue component
  47699. * @param a defines the alpha component
  47700. */
  47701. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47702. /**
  47703. * Sets the current alpha mode
  47704. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47705. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47706. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47707. */
  47708. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47709. /**
  47710. * Gets the current alpha mode
  47711. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47712. * @returns the current alpha mode
  47713. */
  47714. getAlphaMode(): number;
  47715. setInt(uniform: WebGLUniformLocation, int: number): void;
  47716. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47717. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47718. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47719. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47720. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47721. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47722. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47723. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47724. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47725. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47726. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47727. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47728. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47729. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47730. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47731. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47732. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47733. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47734. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47735. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47736. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47737. wipeCaches(bruteForce?: boolean): void;
  47738. _createTexture(): WebGLTexture;
  47739. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47740. /**
  47741. * Usually called from Texture.ts.
  47742. * Passed information to create a WebGLTexture
  47743. * @param urlArg defines a value which contains one of the following:
  47744. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47745. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47746. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47747. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47748. * @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)
  47749. * @param scene needed for loading to the correct scene
  47750. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47751. * @param onLoad optional callback to be called upon successful completion
  47752. * @param onError optional callback to be called upon failure
  47753. * @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
  47754. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47755. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47756. * @param forcedExtension defines the extension to use to pick the right loader
  47757. * @param mimeType defines an optional mime type
  47758. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47759. */
  47760. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  47761. /**
  47762. * Creates a cube texture
  47763. * @param rootUrl defines the url where the files to load is located
  47764. * @param scene defines the current scene
  47765. * @param files defines the list of files to load (1 per face)
  47766. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47767. * @param onLoad defines an optional callback raised when the texture is loaded
  47768. * @param onError defines an optional callback raised if there is an issue to load the texture
  47769. * @param format defines the format of the data
  47770. * @param forcedExtension defines the extension to use to pick the right loader
  47771. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47772. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47773. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47774. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47775. * @returns the cube texture as an InternalTexture
  47776. */
  47777. 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;
  47778. private _getSamplingFilter;
  47779. private static _GetNativeTextureFormat;
  47780. createRenderTargetTexture(size: number | {
  47781. width: number;
  47782. height: number;
  47783. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47784. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47785. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47786. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47787. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47788. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47789. /**
  47790. * Updates a dynamic vertex buffer.
  47791. * @param vertexBuffer the vertex buffer to update
  47792. * @param data the data used to update the vertex buffer
  47793. * @param byteOffset the byte offset of the data (optional)
  47794. * @param byteLength the byte length of the data (optional)
  47795. */
  47796. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47797. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47798. private _updateAnisotropicLevel;
  47799. private _getAddressMode;
  47800. /** @hidden */
  47801. _bindTexture(channel: number, texture: InternalTexture): void;
  47802. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47803. releaseEffects(): void;
  47804. /** @hidden */
  47805. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47806. /** @hidden */
  47807. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47808. /** @hidden */
  47809. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47810. /** @hidden */
  47811. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47812. }
  47813. }
  47814. declare module BABYLON {
  47815. /**
  47816. * Gather the list of clipboard event types as constants.
  47817. */
  47818. export class ClipboardEventTypes {
  47819. /**
  47820. * The clipboard event is fired when a copy command is active (pressed).
  47821. */
  47822. static readonly COPY: number;
  47823. /**
  47824. * The clipboard event is fired when a cut command is active (pressed).
  47825. */
  47826. static readonly CUT: number;
  47827. /**
  47828. * The clipboard event is fired when a paste command is active (pressed).
  47829. */
  47830. static readonly PASTE: number;
  47831. }
  47832. /**
  47833. * This class is used to store clipboard related info for the onClipboardObservable event.
  47834. */
  47835. export class ClipboardInfo {
  47836. /**
  47837. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47838. */
  47839. type: number;
  47840. /**
  47841. * Defines the related dom event
  47842. */
  47843. event: ClipboardEvent;
  47844. /**
  47845. *Creates an instance of ClipboardInfo.
  47846. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47847. * @param event Defines the related dom event
  47848. */
  47849. constructor(
  47850. /**
  47851. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47852. */
  47853. type: number,
  47854. /**
  47855. * Defines the related dom event
  47856. */
  47857. event: ClipboardEvent);
  47858. /**
  47859. * Get the clipboard event's type from the keycode.
  47860. * @param keyCode Defines the keyCode for the current keyboard event.
  47861. * @return {number}
  47862. */
  47863. static GetTypeFromCharacter(keyCode: number): number;
  47864. }
  47865. }
  47866. declare module BABYLON {
  47867. /**
  47868. * Google Daydream controller
  47869. */
  47870. export class DaydreamController extends WebVRController {
  47871. /**
  47872. * Base Url for the controller model.
  47873. */
  47874. static MODEL_BASE_URL: string;
  47875. /**
  47876. * File name for the controller model.
  47877. */
  47878. static MODEL_FILENAME: string;
  47879. /**
  47880. * Gamepad Id prefix used to identify Daydream Controller.
  47881. */
  47882. static readonly GAMEPAD_ID_PREFIX: string;
  47883. /**
  47884. * Creates a new DaydreamController from a gamepad
  47885. * @param vrGamepad the gamepad that the controller should be created from
  47886. */
  47887. constructor(vrGamepad: any);
  47888. /**
  47889. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47890. * @param scene scene in which to add meshes
  47891. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47892. */
  47893. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47894. /**
  47895. * Called once for each button that changed state since the last frame
  47896. * @param buttonIdx Which button index changed
  47897. * @param state New state of the button
  47898. * @param changes Which properties on the state changed since last frame
  47899. */
  47900. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47901. }
  47902. }
  47903. declare module BABYLON {
  47904. /**
  47905. * Gear VR Controller
  47906. */
  47907. export class GearVRController extends WebVRController {
  47908. /**
  47909. * Base Url for the controller model.
  47910. */
  47911. static MODEL_BASE_URL: string;
  47912. /**
  47913. * File name for the controller model.
  47914. */
  47915. static MODEL_FILENAME: string;
  47916. /**
  47917. * Gamepad Id prefix used to identify this controller.
  47918. */
  47919. static readonly GAMEPAD_ID_PREFIX: string;
  47920. private readonly _buttonIndexToObservableNameMap;
  47921. /**
  47922. * Creates a new GearVRController from a gamepad
  47923. * @param vrGamepad the gamepad that the controller should be created from
  47924. */
  47925. constructor(vrGamepad: any);
  47926. /**
  47927. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47928. * @param scene scene in which to add meshes
  47929. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47930. */
  47931. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47932. /**
  47933. * Called once for each button that changed state since the last frame
  47934. * @param buttonIdx Which button index changed
  47935. * @param state New state of the button
  47936. * @param changes Which properties on the state changed since last frame
  47937. */
  47938. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47939. }
  47940. }
  47941. declare module BABYLON {
  47942. /**
  47943. * Generic Controller
  47944. */
  47945. export class GenericController extends WebVRController {
  47946. /**
  47947. * Base Url for the controller model.
  47948. */
  47949. static readonly MODEL_BASE_URL: string;
  47950. /**
  47951. * File name for the controller model.
  47952. */
  47953. static readonly MODEL_FILENAME: string;
  47954. /**
  47955. * Creates a new GenericController from a gamepad
  47956. * @param vrGamepad the gamepad that the controller should be created from
  47957. */
  47958. constructor(vrGamepad: any);
  47959. /**
  47960. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47961. * @param scene scene in which to add meshes
  47962. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47963. */
  47964. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47965. /**
  47966. * Called once for each button that changed state since the last frame
  47967. * @param buttonIdx Which button index changed
  47968. * @param state New state of the button
  47969. * @param changes Which properties on the state changed since last frame
  47970. */
  47971. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47972. }
  47973. }
  47974. declare module BABYLON {
  47975. /**
  47976. * Oculus Touch Controller
  47977. */
  47978. export class OculusTouchController extends WebVRController {
  47979. /**
  47980. * Base Url for the controller model.
  47981. */
  47982. static MODEL_BASE_URL: string;
  47983. /**
  47984. * File name for the left controller model.
  47985. */
  47986. static MODEL_LEFT_FILENAME: string;
  47987. /**
  47988. * File name for the right controller model.
  47989. */
  47990. static MODEL_RIGHT_FILENAME: string;
  47991. /**
  47992. * Base Url for the Quest controller model.
  47993. */
  47994. static QUEST_MODEL_BASE_URL: string;
  47995. /**
  47996. * @hidden
  47997. * If the controllers are running on a device that needs the updated Quest controller models
  47998. */
  47999. static _IsQuest: boolean;
  48000. /**
  48001. * Fired when the secondary trigger on this controller is modified
  48002. */
  48003. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48004. /**
  48005. * Fired when the thumb rest on this controller is modified
  48006. */
  48007. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48008. /**
  48009. * Creates a new OculusTouchController from a gamepad
  48010. * @param vrGamepad the gamepad that the controller should be created from
  48011. */
  48012. constructor(vrGamepad: any);
  48013. /**
  48014. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48015. * @param scene scene in which to add meshes
  48016. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48017. */
  48018. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48019. /**
  48020. * Fired when the A button on this controller is modified
  48021. */
  48022. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48023. /**
  48024. * Fired when the B button on this controller is modified
  48025. */
  48026. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48027. /**
  48028. * Fired when the X button on this controller is modified
  48029. */
  48030. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48031. /**
  48032. * Fired when the Y button on this controller is modified
  48033. */
  48034. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48035. /**
  48036. * Called once for each button that changed state since the last frame
  48037. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48038. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48039. * 2) secondary trigger (same)
  48040. * 3) A (right) X (left), touch, pressed = value
  48041. * 4) B / Y
  48042. * 5) thumb rest
  48043. * @param buttonIdx Which button index changed
  48044. * @param state New state of the button
  48045. * @param changes Which properties on the state changed since last frame
  48046. */
  48047. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48048. }
  48049. }
  48050. declare module BABYLON {
  48051. /**
  48052. * Vive Controller
  48053. */
  48054. export class ViveController extends WebVRController {
  48055. /**
  48056. * Base Url for the controller model.
  48057. */
  48058. static MODEL_BASE_URL: string;
  48059. /**
  48060. * File name for the controller model.
  48061. */
  48062. static MODEL_FILENAME: string;
  48063. /**
  48064. * Creates a new ViveController from a gamepad
  48065. * @param vrGamepad the gamepad that the controller should be created from
  48066. */
  48067. constructor(vrGamepad: any);
  48068. /**
  48069. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48070. * @param scene scene in which to add meshes
  48071. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48072. */
  48073. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48074. /**
  48075. * Fired when the left button on this controller is modified
  48076. */
  48077. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48078. /**
  48079. * Fired when the right button on this controller is modified
  48080. */
  48081. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48082. /**
  48083. * Fired when the menu button on this controller is modified
  48084. */
  48085. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48086. /**
  48087. * Called once for each button that changed state since the last frame
  48088. * Vive mapping:
  48089. * 0: touchpad
  48090. * 1: trigger
  48091. * 2: left AND right buttons
  48092. * 3: menu button
  48093. * @param buttonIdx Which button index changed
  48094. * @param state New state of the button
  48095. * @param changes Which properties on the state changed since last frame
  48096. */
  48097. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48098. }
  48099. }
  48100. declare module BABYLON {
  48101. /**
  48102. * Defines the WindowsMotionController object that the state of the windows motion controller
  48103. */
  48104. export class WindowsMotionController extends WebVRController {
  48105. /**
  48106. * The base url used to load the left and right controller models
  48107. */
  48108. static MODEL_BASE_URL: string;
  48109. /**
  48110. * The name of the left controller model file
  48111. */
  48112. static MODEL_LEFT_FILENAME: string;
  48113. /**
  48114. * The name of the right controller model file
  48115. */
  48116. static MODEL_RIGHT_FILENAME: string;
  48117. /**
  48118. * The controller name prefix for this controller type
  48119. */
  48120. static readonly GAMEPAD_ID_PREFIX: string;
  48121. /**
  48122. * The controller id pattern for this controller type
  48123. */
  48124. private static readonly GAMEPAD_ID_PATTERN;
  48125. private _loadedMeshInfo;
  48126. protected readonly _mapping: {
  48127. buttons: string[];
  48128. buttonMeshNames: {
  48129. 'trigger': string;
  48130. 'menu': string;
  48131. 'grip': string;
  48132. 'thumbstick': string;
  48133. 'trackpad': string;
  48134. };
  48135. buttonObservableNames: {
  48136. 'trigger': string;
  48137. 'menu': string;
  48138. 'grip': string;
  48139. 'thumbstick': string;
  48140. 'trackpad': string;
  48141. };
  48142. axisMeshNames: string[];
  48143. pointingPoseMeshName: string;
  48144. };
  48145. /**
  48146. * Fired when the trackpad on this controller is clicked
  48147. */
  48148. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48149. /**
  48150. * Fired when the trackpad on this controller is modified
  48151. */
  48152. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48153. /**
  48154. * The current x and y values of this controller's trackpad
  48155. */
  48156. trackpad: StickValues;
  48157. /**
  48158. * Creates a new WindowsMotionController from a gamepad
  48159. * @param vrGamepad the gamepad that the controller should be created from
  48160. */
  48161. constructor(vrGamepad: any);
  48162. /**
  48163. * Fired when the trigger on this controller is modified
  48164. */
  48165. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48166. /**
  48167. * Fired when the menu button on this controller is modified
  48168. */
  48169. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48170. /**
  48171. * Fired when the grip button on this controller is modified
  48172. */
  48173. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48174. /**
  48175. * Fired when the thumbstick button on this controller is modified
  48176. */
  48177. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48178. /**
  48179. * Fired when the touchpad button on this controller is modified
  48180. */
  48181. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48182. /**
  48183. * Fired when the touchpad values on this controller are modified
  48184. */
  48185. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48186. protected _updateTrackpad(): void;
  48187. /**
  48188. * Called once per frame by the engine.
  48189. */
  48190. update(): void;
  48191. /**
  48192. * Called once for each button that changed state since the last frame
  48193. * @param buttonIdx Which button index changed
  48194. * @param state New state of the button
  48195. * @param changes Which properties on the state changed since last frame
  48196. */
  48197. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48198. /**
  48199. * Moves the buttons on the controller mesh based on their current state
  48200. * @param buttonName the name of the button to move
  48201. * @param buttonValue the value of the button which determines the buttons new position
  48202. */
  48203. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48204. /**
  48205. * Moves the axis on the controller mesh based on its current state
  48206. * @param axis the index of the axis
  48207. * @param axisValue the value of the axis which determines the meshes new position
  48208. * @hidden
  48209. */
  48210. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48211. /**
  48212. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48213. * @param scene scene in which to add meshes
  48214. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48215. */
  48216. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48217. /**
  48218. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48219. * can be transformed by button presses and axes values, based on this._mapping.
  48220. *
  48221. * @param scene scene in which the meshes exist
  48222. * @param meshes list of meshes that make up the controller model to process
  48223. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48224. */
  48225. private processModel;
  48226. private createMeshInfo;
  48227. /**
  48228. * Gets the ray of the controller in the direction the controller is pointing
  48229. * @param length the length the resulting ray should be
  48230. * @returns a ray in the direction the controller is pointing
  48231. */
  48232. getForwardRay(length?: number): Ray;
  48233. /**
  48234. * Disposes of the controller
  48235. */
  48236. dispose(): void;
  48237. }
  48238. /**
  48239. * This class represents a new windows motion controller in XR.
  48240. */
  48241. export class XRWindowsMotionController extends WindowsMotionController {
  48242. /**
  48243. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48244. */
  48245. protected readonly _mapping: {
  48246. buttons: string[];
  48247. buttonMeshNames: {
  48248. 'trigger': string;
  48249. 'menu': string;
  48250. 'grip': string;
  48251. 'thumbstick': string;
  48252. 'trackpad': string;
  48253. };
  48254. buttonObservableNames: {
  48255. 'trigger': string;
  48256. 'menu': string;
  48257. 'grip': string;
  48258. 'thumbstick': string;
  48259. 'trackpad': string;
  48260. };
  48261. axisMeshNames: string[];
  48262. pointingPoseMeshName: string;
  48263. };
  48264. /**
  48265. * Construct a new XR-Based windows motion controller
  48266. *
  48267. * @param gamepadInfo the gamepad object from the browser
  48268. */
  48269. constructor(gamepadInfo: any);
  48270. /**
  48271. * holds the thumbstick values (X,Y)
  48272. */
  48273. thumbstickValues: StickValues;
  48274. /**
  48275. * Fired when the thumbstick on this controller is clicked
  48276. */
  48277. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48278. /**
  48279. * Fired when the thumbstick on this controller is modified
  48280. */
  48281. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48282. /**
  48283. * Fired when the touchpad button on this controller is modified
  48284. */
  48285. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48286. /**
  48287. * Fired when the touchpad values on this controller are modified
  48288. */
  48289. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48290. /**
  48291. * Fired when the thumbstick button on this controller is modified
  48292. * here to prevent breaking changes
  48293. */
  48294. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48295. /**
  48296. * updating the thumbstick(!) and not the trackpad.
  48297. * This is named this way due to the difference between WebVR and XR and to avoid
  48298. * changing the parent class.
  48299. */
  48300. protected _updateTrackpad(): void;
  48301. /**
  48302. * Disposes the class with joy
  48303. */
  48304. dispose(): void;
  48305. }
  48306. }
  48307. declare module BABYLON {
  48308. /**
  48309. * Class containing static functions to help procedurally build meshes
  48310. */
  48311. export class PolyhedronBuilder {
  48312. /**
  48313. * Creates a polyhedron mesh
  48314. * * 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
  48315. * * The parameter `size` (positive float, default 1) sets the polygon size
  48316. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48317. * * 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`
  48318. * * 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
  48319. * * 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)`)
  48320. * * 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
  48321. * * 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
  48322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48323. * * 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
  48324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48325. * @param name defines the name of the mesh
  48326. * @param options defines the options used to create the mesh
  48327. * @param scene defines the hosting scene
  48328. * @returns the polyhedron mesh
  48329. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48330. */
  48331. static CreatePolyhedron(name: string, options: {
  48332. type?: number;
  48333. size?: number;
  48334. sizeX?: number;
  48335. sizeY?: number;
  48336. sizeZ?: number;
  48337. custom?: any;
  48338. faceUV?: Vector4[];
  48339. faceColors?: Color4[];
  48340. flat?: boolean;
  48341. updatable?: boolean;
  48342. sideOrientation?: number;
  48343. frontUVs?: Vector4;
  48344. backUVs?: Vector4;
  48345. }, scene?: Nullable<Scene>): Mesh;
  48346. }
  48347. }
  48348. declare module BABYLON {
  48349. /**
  48350. * Gizmo that enables scaling a mesh along 3 axis
  48351. */
  48352. export class ScaleGizmo extends Gizmo {
  48353. /**
  48354. * Internal gizmo used for interactions on the x axis
  48355. */
  48356. xGizmo: AxisScaleGizmo;
  48357. /**
  48358. * Internal gizmo used for interactions on the y axis
  48359. */
  48360. yGizmo: AxisScaleGizmo;
  48361. /**
  48362. * Internal gizmo used for interactions on the z axis
  48363. */
  48364. zGizmo: AxisScaleGizmo;
  48365. /**
  48366. * Internal gizmo used to scale all axis equally
  48367. */
  48368. uniformScaleGizmo: AxisScaleGizmo;
  48369. private _meshAttached;
  48370. private _updateGizmoRotationToMatchAttachedMesh;
  48371. private _snapDistance;
  48372. private _scaleRatio;
  48373. private _uniformScalingMesh;
  48374. private _octahedron;
  48375. private _sensitivity;
  48376. /** Fires an event when any of it's sub gizmos are dragged */
  48377. onDragStartObservable: Observable<unknown>;
  48378. /** Fires an event when any of it's sub gizmos are released from dragging */
  48379. onDragEndObservable: Observable<unknown>;
  48380. get attachedMesh(): Nullable<AbstractMesh>;
  48381. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48382. /**
  48383. * Creates a ScaleGizmo
  48384. * @param gizmoLayer The utility layer the gizmo will be added to
  48385. */
  48386. constructor(gizmoLayer?: UtilityLayerRenderer);
  48387. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48388. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48389. /**
  48390. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48391. */
  48392. set snapDistance(value: number);
  48393. get snapDistance(): number;
  48394. /**
  48395. * Ratio for the scale of the gizmo (Default: 1)
  48396. */
  48397. set scaleRatio(value: number);
  48398. get scaleRatio(): number;
  48399. /**
  48400. * Sensitivity factor for dragging (Default: 1)
  48401. */
  48402. set sensitivity(value: number);
  48403. get sensitivity(): number;
  48404. /**
  48405. * Disposes of the gizmo
  48406. */
  48407. dispose(): void;
  48408. }
  48409. }
  48410. declare module BABYLON {
  48411. /**
  48412. * Single axis scale gizmo
  48413. */
  48414. export class AxisScaleGizmo extends Gizmo {
  48415. /**
  48416. * Drag behavior responsible for the gizmos dragging interactions
  48417. */
  48418. dragBehavior: PointerDragBehavior;
  48419. private _pointerObserver;
  48420. /**
  48421. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48422. */
  48423. snapDistance: number;
  48424. /**
  48425. * Event that fires each time the gizmo snaps to a new location.
  48426. * * snapDistance is the the change in distance
  48427. */
  48428. onSnapObservable: Observable<{
  48429. snapDistance: number;
  48430. }>;
  48431. /**
  48432. * If the scaling operation should be done on all axis (default: false)
  48433. */
  48434. uniformScaling: boolean;
  48435. /**
  48436. * Custom sensitivity value for the drag strength
  48437. */
  48438. sensitivity: number;
  48439. private _isEnabled;
  48440. private _parent;
  48441. private _arrow;
  48442. private _coloredMaterial;
  48443. private _hoverMaterial;
  48444. /**
  48445. * Creates an AxisScaleGizmo
  48446. * @param gizmoLayer The utility layer the gizmo will be added to
  48447. * @param dragAxis The axis which the gizmo will be able to scale on
  48448. * @param color The color of the gizmo
  48449. */
  48450. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48451. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48452. /**
  48453. * If the gizmo is enabled
  48454. */
  48455. set isEnabled(value: boolean);
  48456. get isEnabled(): boolean;
  48457. /**
  48458. * Disposes of the gizmo
  48459. */
  48460. dispose(): void;
  48461. /**
  48462. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48463. * @param mesh The mesh to replace the default mesh of the gizmo
  48464. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48465. */
  48466. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /**
  48471. * Bounding box gizmo
  48472. */
  48473. export class BoundingBoxGizmo extends Gizmo {
  48474. private _lineBoundingBox;
  48475. private _rotateSpheresParent;
  48476. private _scaleBoxesParent;
  48477. private _boundingDimensions;
  48478. private _renderObserver;
  48479. private _pointerObserver;
  48480. private _scaleDragSpeed;
  48481. private _tmpQuaternion;
  48482. private _tmpVector;
  48483. private _tmpRotationMatrix;
  48484. /**
  48485. * 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)
  48486. */
  48487. ignoreChildren: boolean;
  48488. /**
  48489. * 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)
  48490. */
  48491. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48492. /**
  48493. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48494. */
  48495. rotationSphereSize: number;
  48496. /**
  48497. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48498. */
  48499. scaleBoxSize: number;
  48500. /**
  48501. * 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)
  48502. */
  48503. fixedDragMeshScreenSize: boolean;
  48504. /**
  48505. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48506. */
  48507. fixedDragMeshScreenSizeDistanceFactor: number;
  48508. /**
  48509. * Fired when a rotation sphere or scale box is dragged
  48510. */
  48511. onDragStartObservable: Observable<{}>;
  48512. /**
  48513. * Fired when a scale box is dragged
  48514. */
  48515. onScaleBoxDragObservable: Observable<{}>;
  48516. /**
  48517. * Fired when a scale box drag is ended
  48518. */
  48519. onScaleBoxDragEndObservable: Observable<{}>;
  48520. /**
  48521. * Fired when a rotation sphere is dragged
  48522. */
  48523. onRotationSphereDragObservable: Observable<{}>;
  48524. /**
  48525. * Fired when a rotation sphere drag is ended
  48526. */
  48527. onRotationSphereDragEndObservable: Observable<{}>;
  48528. /**
  48529. * 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)
  48530. */
  48531. scalePivot: Nullable<Vector3>;
  48532. /**
  48533. * Mesh used as a pivot to rotate the attached mesh
  48534. */
  48535. private _anchorMesh;
  48536. private _existingMeshScale;
  48537. private _dragMesh;
  48538. private pointerDragBehavior;
  48539. private coloredMaterial;
  48540. private hoverColoredMaterial;
  48541. /**
  48542. * Sets the color of the bounding box gizmo
  48543. * @param color the color to set
  48544. */
  48545. setColor(color: Color3): void;
  48546. /**
  48547. * Creates an BoundingBoxGizmo
  48548. * @param gizmoLayer The utility layer the gizmo will be added to
  48549. * @param color The color of the gizmo
  48550. */
  48551. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48552. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48553. private _selectNode;
  48554. /**
  48555. * Updates the bounding box information for the Gizmo
  48556. */
  48557. updateBoundingBox(): void;
  48558. private _updateRotationSpheres;
  48559. private _updateScaleBoxes;
  48560. /**
  48561. * Enables rotation on the specified axis and disables rotation on the others
  48562. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48563. */
  48564. setEnabledRotationAxis(axis: string): void;
  48565. /**
  48566. * Enables/disables scaling
  48567. * @param enable if scaling should be enabled
  48568. */
  48569. setEnabledScaling(enable: boolean): void;
  48570. private _updateDummy;
  48571. /**
  48572. * Enables a pointer drag behavior on the bounding box of the gizmo
  48573. */
  48574. enableDragBehavior(): void;
  48575. /**
  48576. * Disposes of the gizmo
  48577. */
  48578. dispose(): void;
  48579. /**
  48580. * 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)
  48581. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48582. * @returns the bounding box mesh with the passed in mesh as a child
  48583. */
  48584. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48585. /**
  48586. * CustomMeshes are not supported by this gizmo
  48587. * @param mesh The mesh to replace the default mesh of the gizmo
  48588. */
  48589. setCustomMesh(mesh: Mesh): void;
  48590. }
  48591. }
  48592. declare module BABYLON {
  48593. /**
  48594. * Single plane rotation gizmo
  48595. */
  48596. export class PlaneRotationGizmo extends Gizmo {
  48597. /**
  48598. * Drag behavior responsible for the gizmos dragging interactions
  48599. */
  48600. dragBehavior: PointerDragBehavior;
  48601. private _pointerObserver;
  48602. /**
  48603. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48604. */
  48605. snapDistance: number;
  48606. /**
  48607. * Event that fires each time the gizmo snaps to a new location.
  48608. * * snapDistance is the the change in distance
  48609. */
  48610. onSnapObservable: Observable<{
  48611. snapDistance: number;
  48612. }>;
  48613. private _isEnabled;
  48614. private _parent;
  48615. /**
  48616. * Creates a PlaneRotationGizmo
  48617. * @param gizmoLayer The utility layer the gizmo will be added to
  48618. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48619. * @param color The color of the gizmo
  48620. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48621. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48622. */
  48623. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48624. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48625. /**
  48626. * If the gizmo is enabled
  48627. */
  48628. set isEnabled(value: boolean);
  48629. get isEnabled(): boolean;
  48630. /**
  48631. * Disposes of the gizmo
  48632. */
  48633. dispose(): void;
  48634. }
  48635. }
  48636. declare module BABYLON {
  48637. /**
  48638. * Gizmo that enables rotating a mesh along 3 axis
  48639. */
  48640. export class RotationGizmo extends Gizmo {
  48641. /**
  48642. * Internal gizmo used for interactions on the x axis
  48643. */
  48644. xGizmo: PlaneRotationGizmo;
  48645. /**
  48646. * Internal gizmo used for interactions on the y axis
  48647. */
  48648. yGizmo: PlaneRotationGizmo;
  48649. /**
  48650. * Internal gizmo used for interactions on the z axis
  48651. */
  48652. zGizmo: PlaneRotationGizmo;
  48653. /** Fires an event when any of it's sub gizmos are dragged */
  48654. onDragStartObservable: Observable<unknown>;
  48655. /** Fires an event when any of it's sub gizmos are released from dragging */
  48656. onDragEndObservable: Observable<unknown>;
  48657. private _meshAttached;
  48658. get attachedMesh(): Nullable<AbstractMesh>;
  48659. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48660. /**
  48661. * Creates a RotationGizmo
  48662. * @param gizmoLayer The utility layer the gizmo will be added to
  48663. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48664. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48665. */
  48666. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48667. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48668. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48669. /**
  48670. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48671. */
  48672. set snapDistance(value: number);
  48673. get snapDistance(): number;
  48674. /**
  48675. * Ratio for the scale of the gizmo (Default: 1)
  48676. */
  48677. set scaleRatio(value: number);
  48678. get scaleRatio(): number;
  48679. /**
  48680. * Disposes of the gizmo
  48681. */
  48682. dispose(): void;
  48683. /**
  48684. * CustomMeshes are not supported by this gizmo
  48685. * @param mesh The mesh to replace the default mesh of the gizmo
  48686. */
  48687. setCustomMesh(mesh: Mesh): void;
  48688. }
  48689. }
  48690. declare module BABYLON {
  48691. /**
  48692. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48693. */
  48694. export class GizmoManager implements IDisposable {
  48695. private scene;
  48696. /**
  48697. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48698. */
  48699. gizmos: {
  48700. positionGizmo: Nullable<PositionGizmo>;
  48701. rotationGizmo: Nullable<RotationGizmo>;
  48702. scaleGizmo: Nullable<ScaleGizmo>;
  48703. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48704. };
  48705. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48706. clearGizmoOnEmptyPointerEvent: boolean;
  48707. /** Fires an event when the manager is attached to a mesh */
  48708. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48709. private _gizmosEnabled;
  48710. private _pointerObserver;
  48711. private _attachedMesh;
  48712. private _boundingBoxColor;
  48713. private _defaultUtilityLayer;
  48714. private _defaultKeepDepthUtilityLayer;
  48715. /**
  48716. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48717. */
  48718. boundingBoxDragBehavior: SixDofDragBehavior;
  48719. /**
  48720. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48721. */
  48722. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48723. /**
  48724. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48725. */
  48726. usePointerToAttachGizmos: boolean;
  48727. /**
  48728. * Utility layer that the bounding box gizmo belongs to
  48729. */
  48730. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48731. /**
  48732. * Utility layer that all gizmos besides bounding box belong to
  48733. */
  48734. get utilityLayer(): UtilityLayerRenderer;
  48735. /**
  48736. * Instatiates a gizmo manager
  48737. * @param scene the scene to overlay the gizmos on top of
  48738. */
  48739. constructor(scene: Scene);
  48740. /**
  48741. * Attaches a set of gizmos to the specified mesh
  48742. * @param mesh The mesh the gizmo's should be attached to
  48743. */
  48744. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48745. /**
  48746. * If the position gizmo is enabled
  48747. */
  48748. set positionGizmoEnabled(value: boolean);
  48749. get positionGizmoEnabled(): boolean;
  48750. /**
  48751. * If the rotation gizmo is enabled
  48752. */
  48753. set rotationGizmoEnabled(value: boolean);
  48754. get rotationGizmoEnabled(): boolean;
  48755. /**
  48756. * If the scale gizmo is enabled
  48757. */
  48758. set scaleGizmoEnabled(value: boolean);
  48759. get scaleGizmoEnabled(): boolean;
  48760. /**
  48761. * If the boundingBox gizmo is enabled
  48762. */
  48763. set boundingBoxGizmoEnabled(value: boolean);
  48764. get boundingBoxGizmoEnabled(): boolean;
  48765. /**
  48766. * Disposes of the gizmo manager
  48767. */
  48768. dispose(): void;
  48769. }
  48770. }
  48771. declare module BABYLON {
  48772. /**
  48773. * A directional light is defined by a direction (what a surprise!).
  48774. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48775. * 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.
  48776. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48777. */
  48778. export class DirectionalLight extends ShadowLight {
  48779. private _shadowFrustumSize;
  48780. /**
  48781. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48782. */
  48783. get shadowFrustumSize(): number;
  48784. /**
  48785. * Specifies a fix frustum size for the shadow generation.
  48786. */
  48787. set shadowFrustumSize(value: number);
  48788. private _shadowOrthoScale;
  48789. /**
  48790. * Gets the shadow projection scale against the optimal computed one.
  48791. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48792. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48793. */
  48794. get shadowOrthoScale(): number;
  48795. /**
  48796. * Sets the shadow projection scale against the optimal computed one.
  48797. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48798. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48799. */
  48800. set shadowOrthoScale(value: number);
  48801. /**
  48802. * Automatically compute the projection matrix to best fit (including all the casters)
  48803. * on each frame.
  48804. */
  48805. autoUpdateExtends: boolean;
  48806. /**
  48807. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48808. * on each frame. autoUpdateExtends must be set to true for this to work
  48809. */
  48810. autoCalcShadowZBounds: boolean;
  48811. private _orthoLeft;
  48812. private _orthoRight;
  48813. private _orthoTop;
  48814. private _orthoBottom;
  48815. /**
  48816. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48817. * The directional light is emitted from everywhere in the given direction.
  48818. * It can cast shadows.
  48819. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48820. * @param name The friendly name of the light
  48821. * @param direction The direction of the light
  48822. * @param scene The scene the light belongs to
  48823. */
  48824. constructor(name: string, direction: Vector3, scene: Scene);
  48825. /**
  48826. * Returns the string "DirectionalLight".
  48827. * @return The class name
  48828. */
  48829. getClassName(): string;
  48830. /**
  48831. * Returns the integer 1.
  48832. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48833. */
  48834. getTypeID(): number;
  48835. /**
  48836. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48837. * Returns the DirectionalLight Shadow projection matrix.
  48838. */
  48839. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48840. /**
  48841. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48842. * Returns the DirectionalLight Shadow projection matrix.
  48843. */
  48844. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48845. /**
  48846. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48847. * Returns the DirectionalLight Shadow projection matrix.
  48848. */
  48849. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48850. protected _buildUniformLayout(): void;
  48851. /**
  48852. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48853. * @param effect The effect to update
  48854. * @param lightIndex The index of the light in the effect to update
  48855. * @returns The directional light
  48856. */
  48857. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48858. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48859. /**
  48860. * Gets the minZ used for shadow according to both the scene and the light.
  48861. *
  48862. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48863. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48864. * @param activeCamera The camera we are returning the min for
  48865. * @returns the depth min z
  48866. */
  48867. getDepthMinZ(activeCamera: Camera): number;
  48868. /**
  48869. * Gets the maxZ used for shadow according to both the scene and the light.
  48870. *
  48871. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48872. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48873. * @param activeCamera The camera we are returning the max for
  48874. * @returns the depth max z
  48875. */
  48876. getDepthMaxZ(activeCamera: Camera): number;
  48877. /**
  48878. * Prepares the list of defines specific to the light type.
  48879. * @param defines the list of defines
  48880. * @param lightIndex defines the index of the light for the effect
  48881. */
  48882. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48883. }
  48884. }
  48885. declare module BABYLON {
  48886. /**
  48887. * Class containing static functions to help procedurally build meshes
  48888. */
  48889. export class HemisphereBuilder {
  48890. /**
  48891. * Creates a hemisphere mesh
  48892. * @param name defines the name of the mesh
  48893. * @param options defines the options used to create the mesh
  48894. * @param scene defines the hosting scene
  48895. * @returns the hemisphere mesh
  48896. */
  48897. static CreateHemisphere(name: string, options: {
  48898. segments?: number;
  48899. diameter?: number;
  48900. sideOrientation?: number;
  48901. }, scene: any): Mesh;
  48902. }
  48903. }
  48904. declare module BABYLON {
  48905. /**
  48906. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48907. * These values define a cone of light starting from the position, emitting toward the direction.
  48908. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48909. * and the exponent defines the speed of the decay of the light with distance (reach).
  48910. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48911. */
  48912. export class SpotLight extends ShadowLight {
  48913. private _angle;
  48914. private _innerAngle;
  48915. private _cosHalfAngle;
  48916. private _lightAngleScale;
  48917. private _lightAngleOffset;
  48918. /**
  48919. * Gets the cone angle of the spot light in Radians.
  48920. */
  48921. get angle(): number;
  48922. /**
  48923. * Sets the cone angle of the spot light in Radians.
  48924. */
  48925. set angle(value: number);
  48926. /**
  48927. * Only used in gltf falloff mode, this defines the angle where
  48928. * the directional falloff will start before cutting at angle which could be seen
  48929. * as outer angle.
  48930. */
  48931. get innerAngle(): number;
  48932. /**
  48933. * Only used in gltf falloff mode, this defines the angle where
  48934. * the directional falloff will start before cutting at angle which could be seen
  48935. * as outer angle.
  48936. */
  48937. set innerAngle(value: number);
  48938. private _shadowAngleScale;
  48939. /**
  48940. * Allows scaling the angle of the light for shadow generation only.
  48941. */
  48942. get shadowAngleScale(): number;
  48943. /**
  48944. * Allows scaling the angle of the light for shadow generation only.
  48945. */
  48946. set shadowAngleScale(value: number);
  48947. /**
  48948. * The light decay speed with the distance from the emission spot.
  48949. */
  48950. exponent: number;
  48951. private _projectionTextureMatrix;
  48952. /**
  48953. * Allows reading the projecton texture
  48954. */
  48955. get projectionTextureMatrix(): Matrix;
  48956. protected _projectionTextureLightNear: number;
  48957. /**
  48958. * Gets the near clip of the Spotlight for texture projection.
  48959. */
  48960. get projectionTextureLightNear(): number;
  48961. /**
  48962. * Sets the near clip of the Spotlight for texture projection.
  48963. */
  48964. set projectionTextureLightNear(value: number);
  48965. protected _projectionTextureLightFar: number;
  48966. /**
  48967. * Gets the far clip of the Spotlight for texture projection.
  48968. */
  48969. get projectionTextureLightFar(): number;
  48970. /**
  48971. * Sets the far clip of the Spotlight for texture projection.
  48972. */
  48973. set projectionTextureLightFar(value: number);
  48974. protected _projectionTextureUpDirection: Vector3;
  48975. /**
  48976. * Gets the Up vector of the Spotlight for texture projection.
  48977. */
  48978. get projectionTextureUpDirection(): Vector3;
  48979. /**
  48980. * Sets the Up vector of the Spotlight for texture projection.
  48981. */
  48982. set projectionTextureUpDirection(value: Vector3);
  48983. private _projectionTexture;
  48984. /**
  48985. * Gets the projection texture of the light.
  48986. */
  48987. get projectionTexture(): Nullable<BaseTexture>;
  48988. /**
  48989. * Sets the projection texture of the light.
  48990. */
  48991. set projectionTexture(value: Nullable<BaseTexture>);
  48992. private _projectionTextureViewLightDirty;
  48993. private _projectionTextureProjectionLightDirty;
  48994. private _projectionTextureDirty;
  48995. private _projectionTextureViewTargetVector;
  48996. private _projectionTextureViewLightMatrix;
  48997. private _projectionTextureProjectionLightMatrix;
  48998. private _projectionTextureScalingMatrix;
  48999. /**
  49000. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49001. * It can cast shadows.
  49002. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49003. * @param name The light friendly name
  49004. * @param position The position of the spot light in the scene
  49005. * @param direction The direction of the light in the scene
  49006. * @param angle The cone angle of the light in Radians
  49007. * @param exponent The light decay speed with the distance from the emission spot
  49008. * @param scene The scene the lights belongs to
  49009. */
  49010. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49011. /**
  49012. * Returns the string "SpotLight".
  49013. * @returns the class name
  49014. */
  49015. getClassName(): string;
  49016. /**
  49017. * Returns the integer 2.
  49018. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49019. */
  49020. getTypeID(): number;
  49021. /**
  49022. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49023. */
  49024. protected _setDirection(value: Vector3): void;
  49025. /**
  49026. * Overrides the position setter to recompute the projection texture view light Matrix.
  49027. */
  49028. protected _setPosition(value: Vector3): void;
  49029. /**
  49030. * 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.
  49031. * Returns the SpotLight.
  49032. */
  49033. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49034. protected _computeProjectionTextureViewLightMatrix(): void;
  49035. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49036. /**
  49037. * Main function for light texture projection matrix computing.
  49038. */
  49039. protected _computeProjectionTextureMatrix(): void;
  49040. protected _buildUniformLayout(): void;
  49041. private _computeAngleValues;
  49042. /**
  49043. * Sets the passed Effect "effect" with the Light textures.
  49044. * @param effect The effect to update
  49045. * @param lightIndex The index of the light in the effect to update
  49046. * @returns The light
  49047. */
  49048. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49049. /**
  49050. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49051. * @param effect The effect to update
  49052. * @param lightIndex The index of the light in the effect to update
  49053. * @returns The spot light
  49054. */
  49055. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49056. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49057. /**
  49058. * Disposes the light and the associated resources.
  49059. */
  49060. dispose(): void;
  49061. /**
  49062. * Prepares the list of defines specific to the light type.
  49063. * @param defines the list of defines
  49064. * @param lightIndex defines the index of the light for the effect
  49065. */
  49066. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49067. }
  49068. }
  49069. declare module BABYLON {
  49070. /**
  49071. * Gizmo that enables viewing a light
  49072. */
  49073. export class LightGizmo extends Gizmo {
  49074. private _lightMesh;
  49075. private _material;
  49076. private _cachedPosition;
  49077. private _cachedForward;
  49078. private _attachedMeshParent;
  49079. /**
  49080. * Creates a LightGizmo
  49081. * @param gizmoLayer The utility layer the gizmo will be added to
  49082. */
  49083. constructor(gizmoLayer?: UtilityLayerRenderer);
  49084. private _light;
  49085. /**
  49086. * The light that the gizmo is attached to
  49087. */
  49088. set light(light: Nullable<Light>);
  49089. get light(): Nullable<Light>;
  49090. /**
  49091. * Gets the material used to render the light gizmo
  49092. */
  49093. get material(): StandardMaterial;
  49094. /**
  49095. * @hidden
  49096. * Updates the gizmo to match the attached mesh's position/rotation
  49097. */
  49098. protected _update(): void;
  49099. private static _Scale;
  49100. /**
  49101. * Creates the lines for a light mesh
  49102. */
  49103. private static _CreateLightLines;
  49104. /**
  49105. * Disposes of the light gizmo
  49106. */
  49107. dispose(): void;
  49108. private static _CreateHemisphericLightMesh;
  49109. private static _CreatePointLightMesh;
  49110. private static _CreateSpotLightMesh;
  49111. private static _CreateDirectionalLightMesh;
  49112. }
  49113. }
  49114. declare module BABYLON {
  49115. /** @hidden */
  49116. export var backgroundFragmentDeclaration: {
  49117. name: string;
  49118. shader: string;
  49119. };
  49120. }
  49121. declare module BABYLON {
  49122. /** @hidden */
  49123. export var backgroundUboDeclaration: {
  49124. name: string;
  49125. shader: string;
  49126. };
  49127. }
  49128. declare module BABYLON {
  49129. /** @hidden */
  49130. export var backgroundPixelShader: {
  49131. name: string;
  49132. shader: string;
  49133. };
  49134. }
  49135. declare module BABYLON {
  49136. /** @hidden */
  49137. export var backgroundVertexDeclaration: {
  49138. name: string;
  49139. shader: string;
  49140. };
  49141. }
  49142. declare module BABYLON {
  49143. /** @hidden */
  49144. export var backgroundVertexShader: {
  49145. name: string;
  49146. shader: string;
  49147. };
  49148. }
  49149. declare module BABYLON {
  49150. /**
  49151. * Background material used to create an efficient environement around your scene.
  49152. */
  49153. export class BackgroundMaterial extends PushMaterial {
  49154. /**
  49155. * Standard reflectance value at parallel view angle.
  49156. */
  49157. static StandardReflectance0: number;
  49158. /**
  49159. * Standard reflectance value at grazing angle.
  49160. */
  49161. static StandardReflectance90: number;
  49162. protected _primaryColor: Color3;
  49163. /**
  49164. * Key light Color (multiply against the environement texture)
  49165. */
  49166. primaryColor: Color3;
  49167. protected __perceptualColor: Nullable<Color3>;
  49168. /**
  49169. * Experimental Internal Use Only.
  49170. *
  49171. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49172. * This acts as a helper to set the primary color to a more "human friendly" value.
  49173. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49174. * output color as close as possible from the chosen value.
  49175. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49176. * part of lighting setup.)
  49177. */
  49178. get _perceptualColor(): Nullable<Color3>;
  49179. set _perceptualColor(value: Nullable<Color3>);
  49180. protected _primaryColorShadowLevel: float;
  49181. /**
  49182. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49183. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49184. */
  49185. get primaryColorShadowLevel(): float;
  49186. set primaryColorShadowLevel(value: float);
  49187. protected _primaryColorHighlightLevel: float;
  49188. /**
  49189. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49190. * The primary color is used at the level chosen to define what the white area would look.
  49191. */
  49192. get primaryColorHighlightLevel(): float;
  49193. set primaryColorHighlightLevel(value: float);
  49194. protected _reflectionTexture: Nullable<BaseTexture>;
  49195. /**
  49196. * Reflection Texture used in the material.
  49197. * Should be author in a specific way for the best result (refer to the documentation).
  49198. */
  49199. reflectionTexture: Nullable<BaseTexture>;
  49200. protected _reflectionBlur: float;
  49201. /**
  49202. * Reflection Texture level of blur.
  49203. *
  49204. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49205. * texture twice.
  49206. */
  49207. reflectionBlur: float;
  49208. protected _diffuseTexture: Nullable<BaseTexture>;
  49209. /**
  49210. * Diffuse Texture used in the material.
  49211. * Should be author in a specific way for the best result (refer to the documentation).
  49212. */
  49213. diffuseTexture: Nullable<BaseTexture>;
  49214. protected _shadowLights: Nullable<IShadowLight[]>;
  49215. /**
  49216. * Specify the list of lights casting shadow on the material.
  49217. * All scene shadow lights will be included if null.
  49218. */
  49219. shadowLights: Nullable<IShadowLight[]>;
  49220. protected _shadowLevel: float;
  49221. /**
  49222. * Helps adjusting the shadow to a softer level if required.
  49223. * 0 means black shadows and 1 means no shadows.
  49224. */
  49225. shadowLevel: float;
  49226. protected _sceneCenter: Vector3;
  49227. /**
  49228. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49229. * It is usually zero but might be interesting to modify according to your setup.
  49230. */
  49231. sceneCenter: Vector3;
  49232. protected _opacityFresnel: boolean;
  49233. /**
  49234. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49235. * This helps ensuring a nice transition when the camera goes under the ground.
  49236. */
  49237. opacityFresnel: boolean;
  49238. protected _reflectionFresnel: boolean;
  49239. /**
  49240. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49241. * This helps adding a mirror texture on the ground.
  49242. */
  49243. reflectionFresnel: boolean;
  49244. protected _reflectionFalloffDistance: number;
  49245. /**
  49246. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49247. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49248. */
  49249. reflectionFalloffDistance: number;
  49250. protected _reflectionAmount: number;
  49251. /**
  49252. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49253. */
  49254. reflectionAmount: number;
  49255. protected _reflectionReflectance0: number;
  49256. /**
  49257. * This specifies the weight of the reflection at grazing angle.
  49258. */
  49259. reflectionReflectance0: number;
  49260. protected _reflectionReflectance90: number;
  49261. /**
  49262. * This specifies the weight of the reflection at a perpendicular point of view.
  49263. */
  49264. reflectionReflectance90: number;
  49265. /**
  49266. * Sets the reflection reflectance fresnel values according to the default standard
  49267. * empirically know to work well :-)
  49268. */
  49269. set reflectionStandardFresnelWeight(value: number);
  49270. protected _useRGBColor: boolean;
  49271. /**
  49272. * Helps to directly use the maps channels instead of their level.
  49273. */
  49274. useRGBColor: boolean;
  49275. protected _enableNoise: boolean;
  49276. /**
  49277. * This helps reducing the banding effect that could occur on the background.
  49278. */
  49279. enableNoise: boolean;
  49280. /**
  49281. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49282. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49283. * Recommended to be keep at 1.0 except for special cases.
  49284. */
  49285. get fovMultiplier(): number;
  49286. set fovMultiplier(value: number);
  49287. private _fovMultiplier;
  49288. /**
  49289. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49290. */
  49291. useEquirectangularFOV: boolean;
  49292. private _maxSimultaneousLights;
  49293. /**
  49294. * Number of Simultaneous lights allowed on the material.
  49295. */
  49296. maxSimultaneousLights: int;
  49297. /**
  49298. * Default configuration related to image processing available in the Background Material.
  49299. */
  49300. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49301. /**
  49302. * Keep track of the image processing observer to allow dispose and replace.
  49303. */
  49304. private _imageProcessingObserver;
  49305. /**
  49306. * Attaches a new image processing configuration to the PBR Material.
  49307. * @param configuration (if null the scene configuration will be use)
  49308. */
  49309. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49310. /**
  49311. * Gets the image processing configuration used either in this material.
  49312. */
  49313. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49314. /**
  49315. * Sets the Default image processing configuration used either in the this material.
  49316. *
  49317. * If sets to null, the scene one is in use.
  49318. */
  49319. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49320. /**
  49321. * Gets wether the color curves effect is enabled.
  49322. */
  49323. get cameraColorCurvesEnabled(): boolean;
  49324. /**
  49325. * Sets wether the color curves effect is enabled.
  49326. */
  49327. set cameraColorCurvesEnabled(value: boolean);
  49328. /**
  49329. * Gets wether the color grading effect is enabled.
  49330. */
  49331. get cameraColorGradingEnabled(): boolean;
  49332. /**
  49333. * Gets wether the color grading effect is enabled.
  49334. */
  49335. set cameraColorGradingEnabled(value: boolean);
  49336. /**
  49337. * Gets wether tonemapping is enabled or not.
  49338. */
  49339. get cameraToneMappingEnabled(): boolean;
  49340. /**
  49341. * Sets wether tonemapping is enabled or not
  49342. */
  49343. set cameraToneMappingEnabled(value: boolean);
  49344. /**
  49345. * The camera exposure used on this material.
  49346. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49347. * This corresponds to a photographic exposure.
  49348. */
  49349. get cameraExposure(): float;
  49350. /**
  49351. * The camera exposure used on this material.
  49352. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49353. * This corresponds to a photographic exposure.
  49354. */
  49355. set cameraExposure(value: float);
  49356. /**
  49357. * Gets The camera contrast used on this material.
  49358. */
  49359. get cameraContrast(): float;
  49360. /**
  49361. * Sets The camera contrast used on this material.
  49362. */
  49363. set cameraContrast(value: float);
  49364. /**
  49365. * Gets the Color Grading 2D Lookup Texture.
  49366. */
  49367. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49368. /**
  49369. * Sets the Color Grading 2D Lookup Texture.
  49370. */
  49371. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49372. /**
  49373. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49374. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49375. * 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;
  49376. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49377. */
  49378. get cameraColorCurves(): Nullable<ColorCurves>;
  49379. /**
  49380. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49381. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49382. * 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;
  49383. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49384. */
  49385. set cameraColorCurves(value: Nullable<ColorCurves>);
  49386. /**
  49387. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49388. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49389. */
  49390. switchToBGR: boolean;
  49391. private _renderTargets;
  49392. private _reflectionControls;
  49393. private _white;
  49394. private _primaryShadowColor;
  49395. private _primaryHighlightColor;
  49396. /**
  49397. * Instantiates a Background Material in the given scene
  49398. * @param name The friendly name of the material
  49399. * @param scene The scene to add the material to
  49400. */
  49401. constructor(name: string, scene: Scene);
  49402. /**
  49403. * Gets a boolean indicating that current material needs to register RTT
  49404. */
  49405. get hasRenderTargetTextures(): boolean;
  49406. /**
  49407. * The entire material has been created in order to prevent overdraw.
  49408. * @returns false
  49409. */
  49410. needAlphaTesting(): boolean;
  49411. /**
  49412. * The entire material has been created in order to prevent overdraw.
  49413. * @returns true if blending is enable
  49414. */
  49415. needAlphaBlending(): boolean;
  49416. /**
  49417. * Checks wether the material is ready to be rendered for a given mesh.
  49418. * @param mesh The mesh to render
  49419. * @param subMesh The submesh to check against
  49420. * @param useInstances Specify wether or not the material is used with instances
  49421. * @returns true if all the dependencies are ready (Textures, Effects...)
  49422. */
  49423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49424. /**
  49425. * Compute the primary color according to the chosen perceptual color.
  49426. */
  49427. private _computePrimaryColorFromPerceptualColor;
  49428. /**
  49429. * Compute the highlights and shadow colors according to their chosen levels.
  49430. */
  49431. private _computePrimaryColors;
  49432. /**
  49433. * Build the uniform buffer used in the material.
  49434. */
  49435. buildUniformLayout(): void;
  49436. /**
  49437. * Unbind the material.
  49438. */
  49439. unbind(): void;
  49440. /**
  49441. * Bind only the world matrix to the material.
  49442. * @param world The world matrix to bind.
  49443. */
  49444. bindOnlyWorldMatrix(world: Matrix): void;
  49445. /**
  49446. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49447. * @param world The world matrix to bind.
  49448. * @param subMesh The submesh to bind for.
  49449. */
  49450. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49451. /**
  49452. * Checks to see if a texture is used in the material.
  49453. * @param texture - Base texture to use.
  49454. * @returns - Boolean specifying if a texture is used in the material.
  49455. */
  49456. hasTexture(texture: BaseTexture): boolean;
  49457. /**
  49458. * Dispose the material.
  49459. * @param forceDisposeEffect Force disposal of the associated effect.
  49460. * @param forceDisposeTextures Force disposal of the associated textures.
  49461. */
  49462. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49463. /**
  49464. * Clones the material.
  49465. * @param name The cloned name.
  49466. * @returns The cloned material.
  49467. */
  49468. clone(name: string): BackgroundMaterial;
  49469. /**
  49470. * Serializes the current material to its JSON representation.
  49471. * @returns The JSON representation.
  49472. */
  49473. serialize(): any;
  49474. /**
  49475. * Gets the class name of the material
  49476. * @returns "BackgroundMaterial"
  49477. */
  49478. getClassName(): string;
  49479. /**
  49480. * Parse a JSON input to create back a background material.
  49481. * @param source The JSON data to parse
  49482. * @param scene The scene to create the parsed material in
  49483. * @param rootUrl The root url of the assets the material depends upon
  49484. * @returns the instantiated BackgroundMaterial.
  49485. */
  49486. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49487. }
  49488. }
  49489. declare module BABYLON {
  49490. /**
  49491. * Represents the different options available during the creation of
  49492. * a Environment helper.
  49493. *
  49494. * This can control the default ground, skybox and image processing setup of your scene.
  49495. */
  49496. export interface IEnvironmentHelperOptions {
  49497. /**
  49498. * Specifies whether or not to create a ground.
  49499. * True by default.
  49500. */
  49501. createGround: boolean;
  49502. /**
  49503. * Specifies the ground size.
  49504. * 15 by default.
  49505. */
  49506. groundSize: number;
  49507. /**
  49508. * The texture used on the ground for the main color.
  49509. * Comes from the BabylonJS CDN by default.
  49510. *
  49511. * Remarks: Can be either a texture or a url.
  49512. */
  49513. groundTexture: string | BaseTexture;
  49514. /**
  49515. * The color mixed in the ground texture by default.
  49516. * BabylonJS clearColor by default.
  49517. */
  49518. groundColor: Color3;
  49519. /**
  49520. * Specifies the ground opacity.
  49521. * 1 by default.
  49522. */
  49523. groundOpacity: number;
  49524. /**
  49525. * Enables the ground to receive shadows.
  49526. * True by default.
  49527. */
  49528. enableGroundShadow: boolean;
  49529. /**
  49530. * Helps preventing the shadow to be fully black on the ground.
  49531. * 0.5 by default.
  49532. */
  49533. groundShadowLevel: number;
  49534. /**
  49535. * Creates a mirror texture attach to the ground.
  49536. * false by default.
  49537. */
  49538. enableGroundMirror: boolean;
  49539. /**
  49540. * Specifies the ground mirror size ratio.
  49541. * 0.3 by default as the default kernel is 64.
  49542. */
  49543. groundMirrorSizeRatio: number;
  49544. /**
  49545. * Specifies the ground mirror blur kernel size.
  49546. * 64 by default.
  49547. */
  49548. groundMirrorBlurKernel: number;
  49549. /**
  49550. * Specifies the ground mirror visibility amount.
  49551. * 1 by default
  49552. */
  49553. groundMirrorAmount: number;
  49554. /**
  49555. * Specifies the ground mirror reflectance weight.
  49556. * This uses the standard weight of the background material to setup the fresnel effect
  49557. * of the mirror.
  49558. * 1 by default.
  49559. */
  49560. groundMirrorFresnelWeight: number;
  49561. /**
  49562. * Specifies the ground mirror Falloff distance.
  49563. * This can helps reducing the size of the reflection.
  49564. * 0 by Default.
  49565. */
  49566. groundMirrorFallOffDistance: number;
  49567. /**
  49568. * Specifies the ground mirror texture type.
  49569. * Unsigned Int by Default.
  49570. */
  49571. groundMirrorTextureType: number;
  49572. /**
  49573. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49574. * the shown objects.
  49575. */
  49576. groundYBias: number;
  49577. /**
  49578. * Specifies whether or not to create a skybox.
  49579. * True by default.
  49580. */
  49581. createSkybox: boolean;
  49582. /**
  49583. * Specifies the skybox size.
  49584. * 20 by default.
  49585. */
  49586. skyboxSize: number;
  49587. /**
  49588. * The texture used on the skybox for the main color.
  49589. * Comes from the BabylonJS CDN by default.
  49590. *
  49591. * Remarks: Can be either a texture or a url.
  49592. */
  49593. skyboxTexture: string | BaseTexture;
  49594. /**
  49595. * The color mixed in the skybox texture by default.
  49596. * BabylonJS clearColor by default.
  49597. */
  49598. skyboxColor: Color3;
  49599. /**
  49600. * The background rotation around the Y axis of the scene.
  49601. * This helps aligning the key lights of your scene with the background.
  49602. * 0 by default.
  49603. */
  49604. backgroundYRotation: number;
  49605. /**
  49606. * Compute automatically the size of the elements to best fit with the scene.
  49607. */
  49608. sizeAuto: boolean;
  49609. /**
  49610. * Default position of the rootMesh if autoSize is not true.
  49611. */
  49612. rootPosition: Vector3;
  49613. /**
  49614. * Sets up the image processing in the scene.
  49615. * true by default.
  49616. */
  49617. setupImageProcessing: boolean;
  49618. /**
  49619. * The texture used as your environment texture in the scene.
  49620. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49621. *
  49622. * Remarks: Can be either a texture or a url.
  49623. */
  49624. environmentTexture: string | BaseTexture;
  49625. /**
  49626. * The value of the exposure to apply to the scene.
  49627. * 0.6 by default if setupImageProcessing is true.
  49628. */
  49629. cameraExposure: number;
  49630. /**
  49631. * The value of the contrast to apply to the scene.
  49632. * 1.6 by default if setupImageProcessing is true.
  49633. */
  49634. cameraContrast: number;
  49635. /**
  49636. * Specifies whether or not tonemapping should be enabled in the scene.
  49637. * true by default if setupImageProcessing is true.
  49638. */
  49639. toneMappingEnabled: boolean;
  49640. }
  49641. /**
  49642. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49643. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49644. * It also helps with the default setup of your imageProcessing configuration.
  49645. */
  49646. export class EnvironmentHelper {
  49647. /**
  49648. * Default ground texture URL.
  49649. */
  49650. private static _groundTextureCDNUrl;
  49651. /**
  49652. * Default skybox texture URL.
  49653. */
  49654. private static _skyboxTextureCDNUrl;
  49655. /**
  49656. * Default environment texture URL.
  49657. */
  49658. private static _environmentTextureCDNUrl;
  49659. /**
  49660. * Creates the default options for the helper.
  49661. */
  49662. private static _getDefaultOptions;
  49663. private _rootMesh;
  49664. /**
  49665. * Gets the root mesh created by the helper.
  49666. */
  49667. get rootMesh(): Mesh;
  49668. private _skybox;
  49669. /**
  49670. * Gets the skybox created by the helper.
  49671. */
  49672. get skybox(): Nullable<Mesh>;
  49673. private _skyboxTexture;
  49674. /**
  49675. * Gets the skybox texture created by the helper.
  49676. */
  49677. get skyboxTexture(): Nullable<BaseTexture>;
  49678. private _skyboxMaterial;
  49679. /**
  49680. * Gets the skybox material created by the helper.
  49681. */
  49682. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49683. private _ground;
  49684. /**
  49685. * Gets the ground mesh created by the helper.
  49686. */
  49687. get ground(): Nullable<Mesh>;
  49688. private _groundTexture;
  49689. /**
  49690. * Gets the ground texture created by the helper.
  49691. */
  49692. get groundTexture(): Nullable<BaseTexture>;
  49693. private _groundMirror;
  49694. /**
  49695. * Gets the ground mirror created by the helper.
  49696. */
  49697. get groundMirror(): Nullable<MirrorTexture>;
  49698. /**
  49699. * Gets the ground mirror render list to helps pushing the meshes
  49700. * you wish in the ground reflection.
  49701. */
  49702. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49703. private _groundMaterial;
  49704. /**
  49705. * Gets the ground material created by the helper.
  49706. */
  49707. get groundMaterial(): Nullable<BackgroundMaterial>;
  49708. /**
  49709. * Stores the creation options.
  49710. */
  49711. private readonly _scene;
  49712. private _options;
  49713. /**
  49714. * This observable will be notified with any error during the creation of the environment,
  49715. * mainly texture creation errors.
  49716. */
  49717. onErrorObservable: Observable<{
  49718. message?: string;
  49719. exception?: any;
  49720. }>;
  49721. /**
  49722. * constructor
  49723. * @param options Defines the options we want to customize the helper
  49724. * @param scene The scene to add the material to
  49725. */
  49726. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49727. /**
  49728. * Updates the background according to the new options
  49729. * @param options
  49730. */
  49731. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49732. /**
  49733. * Sets the primary color of all the available elements.
  49734. * @param color the main color to affect to the ground and the background
  49735. */
  49736. setMainColor(color: Color3): void;
  49737. /**
  49738. * Setup the image processing according to the specified options.
  49739. */
  49740. private _setupImageProcessing;
  49741. /**
  49742. * Setup the environment texture according to the specified options.
  49743. */
  49744. private _setupEnvironmentTexture;
  49745. /**
  49746. * Setup the background according to the specified options.
  49747. */
  49748. private _setupBackground;
  49749. /**
  49750. * Get the scene sizes according to the setup.
  49751. */
  49752. private _getSceneSize;
  49753. /**
  49754. * Setup the ground according to the specified options.
  49755. */
  49756. private _setupGround;
  49757. /**
  49758. * Setup the ground material according to the specified options.
  49759. */
  49760. private _setupGroundMaterial;
  49761. /**
  49762. * Setup the ground diffuse texture according to the specified options.
  49763. */
  49764. private _setupGroundDiffuseTexture;
  49765. /**
  49766. * Setup the ground mirror texture according to the specified options.
  49767. */
  49768. private _setupGroundMirrorTexture;
  49769. /**
  49770. * Setup the ground to receive the mirror texture.
  49771. */
  49772. private _setupMirrorInGroundMaterial;
  49773. /**
  49774. * Setup the skybox according to the specified options.
  49775. */
  49776. private _setupSkybox;
  49777. /**
  49778. * Setup the skybox material according to the specified options.
  49779. */
  49780. private _setupSkyboxMaterial;
  49781. /**
  49782. * Setup the skybox reflection texture according to the specified options.
  49783. */
  49784. private _setupSkyboxReflectionTexture;
  49785. private _errorHandler;
  49786. /**
  49787. * Dispose all the elements created by the Helper.
  49788. */
  49789. dispose(): void;
  49790. }
  49791. }
  49792. declare module BABYLON {
  49793. /**
  49794. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49795. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49796. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49797. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49798. */
  49799. export class PhotoDome extends TransformNode {
  49800. /**
  49801. * Define the image as a Monoscopic panoramic 360 image.
  49802. */
  49803. static readonly MODE_MONOSCOPIC: number;
  49804. /**
  49805. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49806. */
  49807. static readonly MODE_TOPBOTTOM: number;
  49808. /**
  49809. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49810. */
  49811. static readonly MODE_SIDEBYSIDE: number;
  49812. private _useDirectMapping;
  49813. /**
  49814. * The texture being displayed on the sphere
  49815. */
  49816. protected _photoTexture: Texture;
  49817. /**
  49818. * Gets or sets the texture being displayed on the sphere
  49819. */
  49820. get photoTexture(): Texture;
  49821. set photoTexture(value: Texture);
  49822. /**
  49823. * Observable raised when an error occured while loading the 360 image
  49824. */
  49825. onLoadErrorObservable: Observable<string>;
  49826. /**
  49827. * The skybox material
  49828. */
  49829. protected _material: BackgroundMaterial;
  49830. /**
  49831. * The surface used for the skybox
  49832. */
  49833. protected _mesh: Mesh;
  49834. /**
  49835. * Gets the mesh used for the skybox.
  49836. */
  49837. get mesh(): Mesh;
  49838. /**
  49839. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49840. * Also see the options.resolution property.
  49841. */
  49842. get fovMultiplier(): number;
  49843. set fovMultiplier(value: number);
  49844. private _imageMode;
  49845. /**
  49846. * Gets or set the current video mode for the video. It can be:
  49847. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49848. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49849. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49850. */
  49851. get imageMode(): number;
  49852. set imageMode(value: number);
  49853. /**
  49854. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49855. * @param name Element's name, child elements will append suffixes for their own names.
  49856. * @param urlsOfPhoto defines the url of the photo to display
  49857. * @param options defines an object containing optional or exposed sub element properties
  49858. * @param onError defines a callback called when an error occured while loading the texture
  49859. */
  49860. constructor(name: string, urlOfPhoto: string, options: {
  49861. resolution?: number;
  49862. size?: number;
  49863. useDirectMapping?: boolean;
  49864. faceForward?: boolean;
  49865. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49866. private _onBeforeCameraRenderObserver;
  49867. private _changeImageMode;
  49868. /**
  49869. * Releases resources associated with this node.
  49870. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49871. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49872. */
  49873. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49874. }
  49875. }
  49876. declare module BABYLON {
  49877. /**
  49878. * Class used to host RGBD texture specific utilities
  49879. */
  49880. export class RGBDTextureTools {
  49881. /**
  49882. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49883. * @param texture the texture to expand.
  49884. */
  49885. static ExpandRGBDTexture(texture: Texture): void;
  49886. }
  49887. }
  49888. declare module BABYLON {
  49889. /**
  49890. * Class used to host texture specific utilities
  49891. */
  49892. export class BRDFTextureTools {
  49893. /**
  49894. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49895. * @param scene defines the hosting scene
  49896. * @returns the environment BRDF texture
  49897. */
  49898. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49899. private static _environmentBRDFBase64Texture;
  49900. }
  49901. }
  49902. declare module BABYLON {
  49903. /**
  49904. * @hidden
  49905. */
  49906. export interface IMaterialClearCoatDefines {
  49907. CLEARCOAT: boolean;
  49908. CLEARCOAT_DEFAULTIOR: boolean;
  49909. CLEARCOAT_TEXTURE: boolean;
  49910. CLEARCOAT_TEXTUREDIRECTUV: number;
  49911. CLEARCOAT_BUMP: boolean;
  49912. CLEARCOAT_BUMPDIRECTUV: number;
  49913. CLEARCOAT_TINT: boolean;
  49914. CLEARCOAT_TINT_TEXTURE: boolean;
  49915. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49916. /** @hidden */
  49917. _areTexturesDirty: boolean;
  49918. }
  49919. /**
  49920. * Define the code related to the clear coat parameters of the pbr material.
  49921. */
  49922. export class PBRClearCoatConfiguration {
  49923. /**
  49924. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49925. * The default fits with a polyurethane material.
  49926. */
  49927. private static readonly _DefaultIndexOfRefraction;
  49928. private _isEnabled;
  49929. /**
  49930. * Defines if the clear coat is enabled in the material.
  49931. */
  49932. isEnabled: boolean;
  49933. /**
  49934. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49935. */
  49936. intensity: number;
  49937. /**
  49938. * Defines the clear coat layer roughness.
  49939. */
  49940. roughness: number;
  49941. private _indexOfRefraction;
  49942. /**
  49943. * Defines the index of refraction of the clear coat.
  49944. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49945. * The default fits with a polyurethane material.
  49946. * Changing the default value is more performance intensive.
  49947. */
  49948. indexOfRefraction: number;
  49949. private _texture;
  49950. /**
  49951. * Stores the clear coat values in a texture.
  49952. */
  49953. texture: Nullable<BaseTexture>;
  49954. private _bumpTexture;
  49955. /**
  49956. * Define the clear coat specific bump texture.
  49957. */
  49958. bumpTexture: Nullable<BaseTexture>;
  49959. private _isTintEnabled;
  49960. /**
  49961. * Defines if the clear coat tint is enabled in the material.
  49962. */
  49963. isTintEnabled: boolean;
  49964. /**
  49965. * Defines the clear coat tint of the material.
  49966. * This is only use if tint is enabled
  49967. */
  49968. tintColor: Color3;
  49969. /**
  49970. * Defines the distance at which the tint color should be found in the
  49971. * clear coat media.
  49972. * This is only use if tint is enabled
  49973. */
  49974. tintColorAtDistance: number;
  49975. /**
  49976. * Defines the clear coat layer thickness.
  49977. * This is only use if tint is enabled
  49978. */
  49979. tintThickness: number;
  49980. private _tintTexture;
  49981. /**
  49982. * Stores the clear tint values in a texture.
  49983. * rgb is tint
  49984. * a is a thickness factor
  49985. */
  49986. tintTexture: Nullable<BaseTexture>;
  49987. /** @hidden */
  49988. private _internalMarkAllSubMeshesAsTexturesDirty;
  49989. /** @hidden */
  49990. _markAllSubMeshesAsTexturesDirty(): void;
  49991. /**
  49992. * Instantiate a new istance of clear coat configuration.
  49993. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49994. */
  49995. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49996. /**
  49997. * Gets wehter the submesh is ready to be used or not.
  49998. * @param defines the list of "defines" to update.
  49999. * @param scene defines the scene the material belongs to.
  50000. * @param engine defines the engine the material belongs to.
  50001. * @param disableBumpMap defines wether the material disables bump or not.
  50002. * @returns - boolean indicating that the submesh is ready or not.
  50003. */
  50004. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50005. /**
  50006. * Checks to see if a texture is used in the material.
  50007. * @param defines the list of "defines" to update.
  50008. * @param scene defines the scene to the material belongs to.
  50009. */
  50010. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50011. /**
  50012. * Binds the material data.
  50013. * @param uniformBuffer defines the Uniform buffer to fill in.
  50014. * @param scene defines the scene the material belongs to.
  50015. * @param engine defines the engine the material belongs to.
  50016. * @param disableBumpMap defines wether the material disables bump or not.
  50017. * @param isFrozen defines wether the material is frozen or not.
  50018. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50019. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50020. */
  50021. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50022. /**
  50023. * Checks to see if a texture is used in the material.
  50024. * @param texture - Base texture to use.
  50025. * @returns - Boolean specifying if a texture is used in the material.
  50026. */
  50027. hasTexture(texture: BaseTexture): boolean;
  50028. /**
  50029. * Returns an array of the actively used textures.
  50030. * @param activeTextures Array of BaseTextures
  50031. */
  50032. getActiveTextures(activeTextures: BaseTexture[]): void;
  50033. /**
  50034. * Returns the animatable textures.
  50035. * @param animatables Array of animatable textures.
  50036. */
  50037. getAnimatables(animatables: IAnimatable[]): void;
  50038. /**
  50039. * Disposes the resources of the material.
  50040. * @param forceDisposeTextures - Forces the disposal of all textures.
  50041. */
  50042. dispose(forceDisposeTextures?: boolean): void;
  50043. /**
  50044. * Get the current class name of the texture useful for serialization or dynamic coding.
  50045. * @returns "PBRClearCoatConfiguration"
  50046. */
  50047. getClassName(): string;
  50048. /**
  50049. * Add fallbacks to the effect fallbacks list.
  50050. * @param defines defines the Base texture to use.
  50051. * @param fallbacks defines the current fallback list.
  50052. * @param currentRank defines the current fallback rank.
  50053. * @returns the new fallback rank.
  50054. */
  50055. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50056. /**
  50057. * Add the required uniforms to the current list.
  50058. * @param uniforms defines the current uniform list.
  50059. */
  50060. static AddUniforms(uniforms: string[]): void;
  50061. /**
  50062. * Add the required samplers to the current list.
  50063. * @param samplers defines the current sampler list.
  50064. */
  50065. static AddSamplers(samplers: string[]): void;
  50066. /**
  50067. * Add the required uniforms to the current buffer.
  50068. * @param uniformBuffer defines the current uniform buffer.
  50069. */
  50070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50071. /**
  50072. * Makes a duplicate of the current configuration into another one.
  50073. * @param clearCoatConfiguration define the config where to copy the info
  50074. */
  50075. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50076. /**
  50077. * Serializes this clear coat configuration.
  50078. * @returns - An object with the serialized config.
  50079. */
  50080. serialize(): any;
  50081. /**
  50082. * Parses a anisotropy Configuration from a serialized object.
  50083. * @param source - Serialized object.
  50084. * @param scene Defines the scene we are parsing for
  50085. * @param rootUrl Defines the rootUrl to load from
  50086. */
  50087. parse(source: any, scene: Scene, rootUrl: string): void;
  50088. }
  50089. }
  50090. declare module BABYLON {
  50091. /**
  50092. * @hidden
  50093. */
  50094. export interface IMaterialAnisotropicDefines {
  50095. ANISOTROPIC: boolean;
  50096. ANISOTROPIC_TEXTURE: boolean;
  50097. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50098. MAINUV1: boolean;
  50099. _areTexturesDirty: boolean;
  50100. _needUVs: boolean;
  50101. }
  50102. /**
  50103. * Define the code related to the anisotropic parameters of the pbr material.
  50104. */
  50105. export class PBRAnisotropicConfiguration {
  50106. private _isEnabled;
  50107. /**
  50108. * Defines if the anisotropy is enabled in the material.
  50109. */
  50110. isEnabled: boolean;
  50111. /**
  50112. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50113. */
  50114. intensity: number;
  50115. /**
  50116. * Defines if the effect is along the tangents, bitangents or in between.
  50117. * By default, the effect is "strectching" the highlights along the tangents.
  50118. */
  50119. direction: Vector2;
  50120. private _texture;
  50121. /**
  50122. * Stores the anisotropy values in a texture.
  50123. * rg is direction (like normal from -1 to 1)
  50124. * b is a intensity
  50125. */
  50126. texture: Nullable<BaseTexture>;
  50127. /** @hidden */
  50128. private _internalMarkAllSubMeshesAsTexturesDirty;
  50129. /** @hidden */
  50130. _markAllSubMeshesAsTexturesDirty(): void;
  50131. /**
  50132. * Instantiate a new istance of anisotropy configuration.
  50133. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50134. */
  50135. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50136. /**
  50137. * Specifies that the submesh is ready to be used.
  50138. * @param defines the list of "defines" to update.
  50139. * @param scene defines the scene the material belongs to.
  50140. * @returns - boolean indicating that the submesh is ready or not.
  50141. */
  50142. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50143. /**
  50144. * Checks to see if a texture is used in the material.
  50145. * @param defines the list of "defines" to update.
  50146. * @param mesh the mesh we are preparing the defines for.
  50147. * @param scene defines the scene the material belongs to.
  50148. */
  50149. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50150. /**
  50151. * Binds the material data.
  50152. * @param uniformBuffer defines the Uniform buffer to fill in.
  50153. * @param scene defines the scene the material belongs to.
  50154. * @param isFrozen defines wether the material is frozen or not.
  50155. */
  50156. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50157. /**
  50158. * Checks to see if a texture is used in the material.
  50159. * @param texture - Base texture to use.
  50160. * @returns - Boolean specifying if a texture is used in the material.
  50161. */
  50162. hasTexture(texture: BaseTexture): boolean;
  50163. /**
  50164. * Returns an array of the actively used textures.
  50165. * @param activeTextures Array of BaseTextures
  50166. */
  50167. getActiveTextures(activeTextures: BaseTexture[]): void;
  50168. /**
  50169. * Returns the animatable textures.
  50170. * @param animatables Array of animatable textures.
  50171. */
  50172. getAnimatables(animatables: IAnimatable[]): void;
  50173. /**
  50174. * Disposes the resources of the material.
  50175. * @param forceDisposeTextures - Forces the disposal of all textures.
  50176. */
  50177. dispose(forceDisposeTextures?: boolean): void;
  50178. /**
  50179. * Get the current class name of the texture useful for serialization or dynamic coding.
  50180. * @returns "PBRAnisotropicConfiguration"
  50181. */
  50182. getClassName(): string;
  50183. /**
  50184. * Add fallbacks to the effect fallbacks list.
  50185. * @param defines defines the Base texture to use.
  50186. * @param fallbacks defines the current fallback list.
  50187. * @param currentRank defines the current fallback rank.
  50188. * @returns the new fallback rank.
  50189. */
  50190. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50191. /**
  50192. * Add the required uniforms to the current list.
  50193. * @param uniforms defines the current uniform list.
  50194. */
  50195. static AddUniforms(uniforms: string[]): void;
  50196. /**
  50197. * Add the required uniforms to the current buffer.
  50198. * @param uniformBuffer defines the current uniform buffer.
  50199. */
  50200. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50201. /**
  50202. * Add the required samplers to the current list.
  50203. * @param samplers defines the current sampler list.
  50204. */
  50205. static AddSamplers(samplers: string[]): void;
  50206. /**
  50207. * Makes a duplicate of the current configuration into another one.
  50208. * @param anisotropicConfiguration define the config where to copy the info
  50209. */
  50210. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50211. /**
  50212. * Serializes this anisotropy configuration.
  50213. * @returns - An object with the serialized config.
  50214. */
  50215. serialize(): any;
  50216. /**
  50217. * Parses a anisotropy Configuration from a serialized object.
  50218. * @param source - Serialized object.
  50219. * @param scene Defines the scene we are parsing for
  50220. * @param rootUrl Defines the rootUrl to load from
  50221. */
  50222. parse(source: any, scene: Scene, rootUrl: string): void;
  50223. }
  50224. }
  50225. declare module BABYLON {
  50226. /**
  50227. * @hidden
  50228. */
  50229. export interface IMaterialBRDFDefines {
  50230. BRDF_V_HEIGHT_CORRELATED: boolean;
  50231. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50232. SPHERICAL_HARMONICS: boolean;
  50233. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50234. /** @hidden */
  50235. _areMiscDirty: boolean;
  50236. }
  50237. /**
  50238. * Define the code related to the BRDF parameters of the pbr material.
  50239. */
  50240. export class PBRBRDFConfiguration {
  50241. /**
  50242. * Default value used for the energy conservation.
  50243. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50244. */
  50245. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50246. /**
  50247. * Default value used for the Smith Visibility Height Correlated mode.
  50248. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50249. */
  50250. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50251. /**
  50252. * Default value used for the IBL diffuse part.
  50253. * This can help switching back to the polynomials mode globally which is a tiny bit
  50254. * less GPU intensive at the drawback of a lower quality.
  50255. */
  50256. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50257. /**
  50258. * Default value used for activating energy conservation for the specular workflow.
  50259. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50260. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50261. */
  50262. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50263. private _useEnergyConservation;
  50264. /**
  50265. * Defines if the material uses energy conservation.
  50266. */
  50267. useEnergyConservation: boolean;
  50268. private _useSmithVisibilityHeightCorrelated;
  50269. /**
  50270. * LEGACY Mode set to false
  50271. * Defines if the material uses height smith correlated visibility term.
  50272. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50273. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50274. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50275. * Not relying on height correlated will also disable energy conservation.
  50276. */
  50277. useSmithVisibilityHeightCorrelated: boolean;
  50278. private _useSphericalHarmonics;
  50279. /**
  50280. * LEGACY Mode set to false
  50281. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50282. * diffuse part of the IBL.
  50283. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50284. * to the ground truth.
  50285. */
  50286. useSphericalHarmonics: boolean;
  50287. private _useSpecularGlossinessInputEnergyConservation;
  50288. /**
  50289. * Defines if the material uses energy conservation, when the specular workflow is active.
  50290. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50291. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50292. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50293. */
  50294. useSpecularGlossinessInputEnergyConservation: boolean;
  50295. /** @hidden */
  50296. private _internalMarkAllSubMeshesAsMiscDirty;
  50297. /** @hidden */
  50298. _markAllSubMeshesAsMiscDirty(): void;
  50299. /**
  50300. * Instantiate a new istance of clear coat configuration.
  50301. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50302. */
  50303. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50304. /**
  50305. * Checks to see if a texture is used in the material.
  50306. * @param defines the list of "defines" to update.
  50307. */
  50308. prepareDefines(defines: IMaterialBRDFDefines): void;
  50309. /**
  50310. * Get the current class name of the texture useful for serialization or dynamic coding.
  50311. * @returns "PBRClearCoatConfiguration"
  50312. */
  50313. getClassName(): string;
  50314. /**
  50315. * Makes a duplicate of the current configuration into another one.
  50316. * @param brdfConfiguration define the config where to copy the info
  50317. */
  50318. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50319. /**
  50320. * Serializes this BRDF configuration.
  50321. * @returns - An object with the serialized config.
  50322. */
  50323. serialize(): any;
  50324. /**
  50325. * Parses a anisotropy Configuration from a serialized object.
  50326. * @param source - Serialized object.
  50327. * @param scene Defines the scene we are parsing for
  50328. * @param rootUrl Defines the rootUrl to load from
  50329. */
  50330. parse(source: any, scene: Scene, rootUrl: string): void;
  50331. }
  50332. }
  50333. declare module BABYLON {
  50334. /**
  50335. * @hidden
  50336. */
  50337. export interface IMaterialSheenDefines {
  50338. SHEEN: boolean;
  50339. SHEEN_TEXTURE: boolean;
  50340. SHEEN_TEXTUREDIRECTUV: number;
  50341. SHEEN_LINKWITHALBEDO: boolean;
  50342. /** @hidden */
  50343. _areTexturesDirty: boolean;
  50344. }
  50345. /**
  50346. * Define the code related to the Sheen parameters of the pbr material.
  50347. */
  50348. export class PBRSheenConfiguration {
  50349. private _isEnabled;
  50350. /**
  50351. * Defines if the material uses sheen.
  50352. */
  50353. isEnabled: boolean;
  50354. private _linkSheenWithAlbedo;
  50355. /**
  50356. * Defines if the sheen is linked to the sheen color.
  50357. */
  50358. linkSheenWithAlbedo: boolean;
  50359. /**
  50360. * Defines the sheen intensity.
  50361. */
  50362. intensity: number;
  50363. /**
  50364. * Defines the sheen color.
  50365. */
  50366. color: Color3;
  50367. private _texture;
  50368. /**
  50369. * Stores the sheen tint values in a texture.
  50370. * rgb is tint
  50371. * a is a intensity
  50372. */
  50373. texture: Nullable<BaseTexture>;
  50374. /** @hidden */
  50375. private _internalMarkAllSubMeshesAsTexturesDirty;
  50376. /** @hidden */
  50377. _markAllSubMeshesAsTexturesDirty(): void;
  50378. /**
  50379. * Instantiate a new istance of clear coat configuration.
  50380. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50381. */
  50382. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50383. /**
  50384. * Specifies that the submesh is ready to be used.
  50385. * @param defines the list of "defines" to update.
  50386. * @param scene defines the scene the material belongs to.
  50387. * @returns - boolean indicating that the submesh is ready or not.
  50388. */
  50389. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50390. /**
  50391. * Checks to see if a texture is used in the material.
  50392. * @param defines the list of "defines" to update.
  50393. * @param scene defines the scene the material belongs to.
  50394. */
  50395. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50396. /**
  50397. * Binds the material data.
  50398. * @param uniformBuffer defines the Uniform buffer to fill in.
  50399. * @param scene defines the scene the material belongs to.
  50400. * @param isFrozen defines wether the material is frozen or not.
  50401. */
  50402. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50403. /**
  50404. * Checks to see if a texture is used in the material.
  50405. * @param texture - Base texture to use.
  50406. * @returns - Boolean specifying if a texture is used in the material.
  50407. */
  50408. hasTexture(texture: BaseTexture): boolean;
  50409. /**
  50410. * Returns an array of the actively used textures.
  50411. * @param activeTextures Array of BaseTextures
  50412. */
  50413. getActiveTextures(activeTextures: BaseTexture[]): void;
  50414. /**
  50415. * Returns the animatable textures.
  50416. * @param animatables Array of animatable textures.
  50417. */
  50418. getAnimatables(animatables: IAnimatable[]): void;
  50419. /**
  50420. * Disposes the resources of the material.
  50421. * @param forceDisposeTextures - Forces the disposal of all textures.
  50422. */
  50423. dispose(forceDisposeTextures?: boolean): void;
  50424. /**
  50425. * Get the current class name of the texture useful for serialization or dynamic coding.
  50426. * @returns "PBRSheenConfiguration"
  50427. */
  50428. getClassName(): string;
  50429. /**
  50430. * Add fallbacks to the effect fallbacks list.
  50431. * @param defines defines the Base texture to use.
  50432. * @param fallbacks defines the current fallback list.
  50433. * @param currentRank defines the current fallback rank.
  50434. * @returns the new fallback rank.
  50435. */
  50436. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50437. /**
  50438. * Add the required uniforms to the current list.
  50439. * @param uniforms defines the current uniform list.
  50440. */
  50441. static AddUniforms(uniforms: string[]): void;
  50442. /**
  50443. * Add the required uniforms to the current buffer.
  50444. * @param uniformBuffer defines the current uniform buffer.
  50445. */
  50446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50447. /**
  50448. * Add the required samplers to the current list.
  50449. * @param samplers defines the current sampler list.
  50450. */
  50451. static AddSamplers(samplers: string[]): void;
  50452. /**
  50453. * Makes a duplicate of the current configuration into another one.
  50454. * @param sheenConfiguration define the config where to copy the info
  50455. */
  50456. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50457. /**
  50458. * Serializes this BRDF configuration.
  50459. * @returns - An object with the serialized config.
  50460. */
  50461. serialize(): any;
  50462. /**
  50463. * Parses a anisotropy Configuration from a serialized object.
  50464. * @param source - Serialized object.
  50465. * @param scene Defines the scene we are parsing for
  50466. * @param rootUrl Defines the rootUrl to load from
  50467. */
  50468. parse(source: any, scene: Scene, rootUrl: string): void;
  50469. }
  50470. }
  50471. declare module BABYLON {
  50472. /**
  50473. * @hidden
  50474. */
  50475. export interface IMaterialSubSurfaceDefines {
  50476. SUBSURFACE: boolean;
  50477. SS_REFRACTION: boolean;
  50478. SS_TRANSLUCENCY: boolean;
  50479. SS_SCATERRING: boolean;
  50480. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50481. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50482. SS_REFRACTIONMAP_3D: boolean;
  50483. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50484. SS_LODINREFRACTIONALPHA: boolean;
  50485. SS_GAMMAREFRACTION: boolean;
  50486. SS_RGBDREFRACTION: boolean;
  50487. SS_LINEARSPECULARREFRACTION: boolean;
  50488. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50489. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50490. /** @hidden */
  50491. _areTexturesDirty: boolean;
  50492. }
  50493. /**
  50494. * Define the code related to the sub surface parameters of the pbr material.
  50495. */
  50496. export class PBRSubSurfaceConfiguration {
  50497. private _isRefractionEnabled;
  50498. /**
  50499. * Defines if the refraction is enabled in the material.
  50500. */
  50501. isRefractionEnabled: boolean;
  50502. private _isTranslucencyEnabled;
  50503. /**
  50504. * Defines if the translucency is enabled in the material.
  50505. */
  50506. isTranslucencyEnabled: boolean;
  50507. private _isScatteringEnabled;
  50508. /**
  50509. * Defines the refraction intensity of the material.
  50510. * The refraction when enabled replaces the Diffuse part of the material.
  50511. * The intensity helps transitionning between diffuse and refraction.
  50512. */
  50513. refractionIntensity: number;
  50514. /**
  50515. * Defines the translucency intensity of the material.
  50516. * When translucency has been enabled, this defines how much of the "translucency"
  50517. * is addded to the diffuse part of the material.
  50518. */
  50519. translucencyIntensity: number;
  50520. /**
  50521. * Defines the scattering intensity of the material.
  50522. * When scattering has been enabled, this defines how much of the "scattered light"
  50523. * is addded to the diffuse part of the material.
  50524. */
  50525. scatteringIntensity: number;
  50526. private _thicknessTexture;
  50527. /**
  50528. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50529. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50530. * 0 would mean minimumThickness
  50531. * 1 would mean maximumThickness
  50532. * The other channels might be use as a mask to vary the different effects intensity.
  50533. */
  50534. thicknessTexture: Nullable<BaseTexture>;
  50535. private _refractionTexture;
  50536. /**
  50537. * Defines the texture to use for refraction.
  50538. */
  50539. refractionTexture: Nullable<BaseTexture>;
  50540. private _indexOfRefraction;
  50541. /**
  50542. * Defines the index of refraction used in the material.
  50543. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50544. */
  50545. indexOfRefraction: number;
  50546. private _invertRefractionY;
  50547. /**
  50548. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50549. */
  50550. invertRefractionY: boolean;
  50551. private _linkRefractionWithTransparency;
  50552. /**
  50553. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50554. * Materials half opaque for instance using refraction could benefit from this control.
  50555. */
  50556. linkRefractionWithTransparency: boolean;
  50557. /**
  50558. * Defines the minimum thickness stored in the thickness map.
  50559. * If no thickness map is defined, this value will be used to simulate thickness.
  50560. */
  50561. minimumThickness: number;
  50562. /**
  50563. * Defines the maximum thickness stored in the thickness map.
  50564. */
  50565. maximumThickness: number;
  50566. /**
  50567. * Defines the volume tint of the material.
  50568. * This is used for both translucency and scattering.
  50569. */
  50570. tintColor: Color3;
  50571. /**
  50572. * Defines the distance at which the tint color should be found in the media.
  50573. * This is used for refraction only.
  50574. */
  50575. tintColorAtDistance: number;
  50576. /**
  50577. * Defines how far each channel transmit through the media.
  50578. * It is defined as a color to simplify it selection.
  50579. */
  50580. diffusionDistance: Color3;
  50581. private _useMaskFromThicknessTexture;
  50582. /**
  50583. * Stores the intensity of the different subsurface effects in the thickness texture.
  50584. * * the green channel is the translucency intensity.
  50585. * * the blue channel is the scattering intensity.
  50586. * * the alpha channel is the refraction intensity.
  50587. */
  50588. useMaskFromThicknessTexture: boolean;
  50589. /** @hidden */
  50590. private _internalMarkAllSubMeshesAsTexturesDirty;
  50591. /** @hidden */
  50592. _markAllSubMeshesAsTexturesDirty(): void;
  50593. /**
  50594. * Instantiate a new istance of sub surface configuration.
  50595. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50596. */
  50597. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50598. /**
  50599. * Gets wehter the submesh is ready to be used or not.
  50600. * @param defines the list of "defines" to update.
  50601. * @param scene defines the scene the material belongs to.
  50602. * @returns - boolean indicating that the submesh is ready or not.
  50603. */
  50604. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50605. /**
  50606. * Checks to see if a texture is used in the material.
  50607. * @param defines the list of "defines" to update.
  50608. * @param scene defines the scene to the material belongs to.
  50609. */
  50610. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50611. /**
  50612. * Binds the material data.
  50613. * @param uniformBuffer defines the Uniform buffer to fill in.
  50614. * @param scene defines the scene the material belongs to.
  50615. * @param engine defines the engine the material belongs to.
  50616. * @param isFrozen defines wether the material is frozen or not.
  50617. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50618. */
  50619. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50620. /**
  50621. * Unbinds the material from the mesh.
  50622. * @param activeEffect defines the effect that should be unbound from.
  50623. * @returns true if unbound, otherwise false
  50624. */
  50625. unbind(activeEffect: Effect): boolean;
  50626. /**
  50627. * Returns the texture used for refraction or null if none is used.
  50628. * @param scene defines the scene the material belongs to.
  50629. * @returns - Refraction texture if present. If no refraction texture and refraction
  50630. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50631. */
  50632. private _getRefractionTexture;
  50633. /**
  50634. * Returns true if alpha blending should be disabled.
  50635. */
  50636. get disableAlphaBlending(): boolean;
  50637. /**
  50638. * Fills the list of render target textures.
  50639. * @param renderTargets the list of render targets to update
  50640. */
  50641. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50642. /**
  50643. * Checks to see if a texture is used in the material.
  50644. * @param texture - Base texture to use.
  50645. * @returns - Boolean specifying if a texture is used in the material.
  50646. */
  50647. hasTexture(texture: BaseTexture): boolean;
  50648. /**
  50649. * Gets a boolean indicating that current material needs to register RTT
  50650. * @returns true if this uses a render target otherwise false.
  50651. */
  50652. hasRenderTargetTextures(): boolean;
  50653. /**
  50654. * Returns an array of the actively used textures.
  50655. * @param activeTextures Array of BaseTextures
  50656. */
  50657. getActiveTextures(activeTextures: BaseTexture[]): void;
  50658. /**
  50659. * Returns the animatable textures.
  50660. * @param animatables Array of animatable textures.
  50661. */
  50662. getAnimatables(animatables: IAnimatable[]): void;
  50663. /**
  50664. * Disposes the resources of the material.
  50665. * @param forceDisposeTextures - Forces the disposal of all textures.
  50666. */
  50667. dispose(forceDisposeTextures?: boolean): void;
  50668. /**
  50669. * Get the current class name of the texture useful for serialization or dynamic coding.
  50670. * @returns "PBRSubSurfaceConfiguration"
  50671. */
  50672. getClassName(): string;
  50673. /**
  50674. * Add fallbacks to the effect fallbacks list.
  50675. * @param defines defines the Base texture to use.
  50676. * @param fallbacks defines the current fallback list.
  50677. * @param currentRank defines the current fallback rank.
  50678. * @returns the new fallback rank.
  50679. */
  50680. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50681. /**
  50682. * Add the required uniforms to the current list.
  50683. * @param uniforms defines the current uniform list.
  50684. */
  50685. static AddUniforms(uniforms: string[]): void;
  50686. /**
  50687. * Add the required samplers to the current list.
  50688. * @param samplers defines the current sampler list.
  50689. */
  50690. static AddSamplers(samplers: string[]): void;
  50691. /**
  50692. * Add the required uniforms to the current buffer.
  50693. * @param uniformBuffer defines the current uniform buffer.
  50694. */
  50695. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50696. /**
  50697. * Makes a duplicate of the current configuration into another one.
  50698. * @param configuration define the config where to copy the info
  50699. */
  50700. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50701. /**
  50702. * Serializes this Sub Surface configuration.
  50703. * @returns - An object with the serialized config.
  50704. */
  50705. serialize(): any;
  50706. /**
  50707. * Parses a anisotropy Configuration from a serialized object.
  50708. * @param source - Serialized object.
  50709. * @param scene Defines the scene we are parsing for
  50710. * @param rootUrl Defines the rootUrl to load from
  50711. */
  50712. parse(source: any, scene: Scene, rootUrl: string): void;
  50713. }
  50714. }
  50715. declare module BABYLON {
  50716. /** @hidden */
  50717. export var pbrFragmentDeclaration: {
  50718. name: string;
  50719. shader: string;
  50720. };
  50721. }
  50722. declare module BABYLON {
  50723. /** @hidden */
  50724. export var pbrUboDeclaration: {
  50725. name: string;
  50726. shader: string;
  50727. };
  50728. }
  50729. declare module BABYLON {
  50730. /** @hidden */
  50731. export var pbrFragmentExtraDeclaration: {
  50732. name: string;
  50733. shader: string;
  50734. };
  50735. }
  50736. declare module BABYLON {
  50737. /** @hidden */
  50738. export var pbrFragmentSamplersDeclaration: {
  50739. name: string;
  50740. shader: string;
  50741. };
  50742. }
  50743. declare module BABYLON {
  50744. /** @hidden */
  50745. export var pbrHelperFunctions: {
  50746. name: string;
  50747. shader: string;
  50748. };
  50749. }
  50750. declare module BABYLON {
  50751. /** @hidden */
  50752. export var harmonicsFunctions: {
  50753. name: string;
  50754. shader: string;
  50755. };
  50756. }
  50757. declare module BABYLON {
  50758. /** @hidden */
  50759. export var pbrDirectLightingSetupFunctions: {
  50760. name: string;
  50761. shader: string;
  50762. };
  50763. }
  50764. declare module BABYLON {
  50765. /** @hidden */
  50766. export var pbrDirectLightingFalloffFunctions: {
  50767. name: string;
  50768. shader: string;
  50769. };
  50770. }
  50771. declare module BABYLON {
  50772. /** @hidden */
  50773. export var pbrBRDFFunctions: {
  50774. name: string;
  50775. shader: string;
  50776. };
  50777. }
  50778. declare module BABYLON {
  50779. /** @hidden */
  50780. export var pbrDirectLightingFunctions: {
  50781. name: string;
  50782. shader: string;
  50783. };
  50784. }
  50785. declare module BABYLON {
  50786. /** @hidden */
  50787. export var pbrIBLFunctions: {
  50788. name: string;
  50789. shader: string;
  50790. };
  50791. }
  50792. declare module BABYLON {
  50793. /** @hidden */
  50794. export var pbrDebug: {
  50795. name: string;
  50796. shader: string;
  50797. };
  50798. }
  50799. declare module BABYLON {
  50800. /** @hidden */
  50801. export var pbrPixelShader: {
  50802. name: string;
  50803. shader: string;
  50804. };
  50805. }
  50806. declare module BABYLON {
  50807. /** @hidden */
  50808. export var pbrVertexDeclaration: {
  50809. name: string;
  50810. shader: string;
  50811. };
  50812. }
  50813. declare module BABYLON {
  50814. /** @hidden */
  50815. export var pbrVertexShader: {
  50816. name: string;
  50817. shader: string;
  50818. };
  50819. }
  50820. declare module BABYLON {
  50821. /**
  50822. * Manages the defines for the PBR Material.
  50823. * @hidden
  50824. */
  50825. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50826. PBR: boolean;
  50827. MAINUV1: boolean;
  50828. MAINUV2: boolean;
  50829. UV1: boolean;
  50830. UV2: boolean;
  50831. ALBEDO: boolean;
  50832. GAMMAALBEDO: boolean;
  50833. ALBEDODIRECTUV: number;
  50834. VERTEXCOLOR: boolean;
  50835. AMBIENT: boolean;
  50836. AMBIENTDIRECTUV: number;
  50837. AMBIENTINGRAYSCALE: boolean;
  50838. OPACITY: boolean;
  50839. VERTEXALPHA: boolean;
  50840. OPACITYDIRECTUV: number;
  50841. OPACITYRGB: boolean;
  50842. ALPHATEST: boolean;
  50843. DEPTHPREPASS: boolean;
  50844. ALPHABLEND: boolean;
  50845. ALPHAFROMALBEDO: boolean;
  50846. ALPHATESTVALUE: string;
  50847. SPECULAROVERALPHA: boolean;
  50848. RADIANCEOVERALPHA: boolean;
  50849. ALPHAFRESNEL: boolean;
  50850. LINEARALPHAFRESNEL: boolean;
  50851. PREMULTIPLYALPHA: boolean;
  50852. EMISSIVE: boolean;
  50853. EMISSIVEDIRECTUV: number;
  50854. REFLECTIVITY: boolean;
  50855. REFLECTIVITYDIRECTUV: number;
  50856. SPECULARTERM: boolean;
  50857. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50858. MICROSURFACEAUTOMATIC: boolean;
  50859. LODBASEDMICROSFURACE: boolean;
  50860. MICROSURFACEMAP: boolean;
  50861. MICROSURFACEMAPDIRECTUV: number;
  50862. METALLICWORKFLOW: boolean;
  50863. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50864. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50865. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50866. AOSTOREINMETALMAPRED: boolean;
  50867. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50868. ENVIRONMENTBRDF: boolean;
  50869. ENVIRONMENTBRDF_RGBD: boolean;
  50870. NORMAL: boolean;
  50871. TANGENT: boolean;
  50872. BUMP: boolean;
  50873. BUMPDIRECTUV: number;
  50874. OBJECTSPACE_NORMALMAP: boolean;
  50875. PARALLAX: boolean;
  50876. PARALLAXOCCLUSION: boolean;
  50877. NORMALXYSCALE: boolean;
  50878. LIGHTMAP: boolean;
  50879. LIGHTMAPDIRECTUV: number;
  50880. USELIGHTMAPASSHADOWMAP: boolean;
  50881. GAMMALIGHTMAP: boolean;
  50882. RGBDLIGHTMAP: boolean;
  50883. REFLECTION: boolean;
  50884. REFLECTIONMAP_3D: boolean;
  50885. REFLECTIONMAP_SPHERICAL: boolean;
  50886. REFLECTIONMAP_PLANAR: boolean;
  50887. REFLECTIONMAP_CUBIC: boolean;
  50888. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50889. REFLECTIONMAP_PROJECTION: boolean;
  50890. REFLECTIONMAP_SKYBOX: boolean;
  50891. REFLECTIONMAP_EXPLICIT: boolean;
  50892. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50893. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50894. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50895. INVERTCUBICMAP: boolean;
  50896. USESPHERICALFROMREFLECTIONMAP: boolean;
  50897. USEIRRADIANCEMAP: boolean;
  50898. SPHERICAL_HARMONICS: boolean;
  50899. USESPHERICALINVERTEX: boolean;
  50900. REFLECTIONMAP_OPPOSITEZ: boolean;
  50901. LODINREFLECTIONALPHA: boolean;
  50902. GAMMAREFLECTION: boolean;
  50903. RGBDREFLECTION: boolean;
  50904. LINEARSPECULARREFLECTION: boolean;
  50905. RADIANCEOCCLUSION: boolean;
  50906. HORIZONOCCLUSION: boolean;
  50907. INSTANCES: boolean;
  50908. NUM_BONE_INFLUENCERS: number;
  50909. BonesPerMesh: number;
  50910. BONETEXTURE: boolean;
  50911. NONUNIFORMSCALING: boolean;
  50912. MORPHTARGETS: boolean;
  50913. MORPHTARGETS_NORMAL: boolean;
  50914. MORPHTARGETS_TANGENT: boolean;
  50915. MORPHTARGETS_UV: boolean;
  50916. NUM_MORPH_INFLUENCERS: number;
  50917. IMAGEPROCESSING: boolean;
  50918. VIGNETTE: boolean;
  50919. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50920. VIGNETTEBLENDMODEOPAQUE: boolean;
  50921. TONEMAPPING: boolean;
  50922. TONEMAPPING_ACES: boolean;
  50923. CONTRAST: boolean;
  50924. COLORCURVES: boolean;
  50925. COLORGRADING: boolean;
  50926. COLORGRADING3D: boolean;
  50927. SAMPLER3DGREENDEPTH: boolean;
  50928. SAMPLER3DBGRMAP: boolean;
  50929. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50930. EXPOSURE: boolean;
  50931. MULTIVIEW: boolean;
  50932. USEPHYSICALLIGHTFALLOFF: boolean;
  50933. USEGLTFLIGHTFALLOFF: boolean;
  50934. TWOSIDEDLIGHTING: boolean;
  50935. SHADOWFLOAT: boolean;
  50936. CLIPPLANE: boolean;
  50937. CLIPPLANE2: boolean;
  50938. CLIPPLANE3: boolean;
  50939. CLIPPLANE4: boolean;
  50940. CLIPPLANE5: boolean;
  50941. CLIPPLANE6: boolean;
  50942. POINTSIZE: boolean;
  50943. FOG: boolean;
  50944. LOGARITHMICDEPTH: boolean;
  50945. FORCENORMALFORWARD: boolean;
  50946. SPECULARAA: boolean;
  50947. CLEARCOAT: boolean;
  50948. CLEARCOAT_DEFAULTIOR: boolean;
  50949. CLEARCOAT_TEXTURE: boolean;
  50950. CLEARCOAT_TEXTUREDIRECTUV: number;
  50951. CLEARCOAT_BUMP: boolean;
  50952. CLEARCOAT_BUMPDIRECTUV: number;
  50953. CLEARCOAT_TINT: boolean;
  50954. CLEARCOAT_TINT_TEXTURE: boolean;
  50955. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50956. ANISOTROPIC: boolean;
  50957. ANISOTROPIC_TEXTURE: boolean;
  50958. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50959. BRDF_V_HEIGHT_CORRELATED: boolean;
  50960. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50961. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50962. SHEEN: boolean;
  50963. SHEEN_TEXTURE: boolean;
  50964. SHEEN_TEXTUREDIRECTUV: number;
  50965. SHEEN_LINKWITHALBEDO: boolean;
  50966. SUBSURFACE: boolean;
  50967. SS_REFRACTION: boolean;
  50968. SS_TRANSLUCENCY: boolean;
  50969. SS_SCATERRING: boolean;
  50970. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50971. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50972. SS_REFRACTIONMAP_3D: boolean;
  50973. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50974. SS_LODINREFRACTIONALPHA: boolean;
  50975. SS_GAMMAREFRACTION: boolean;
  50976. SS_RGBDREFRACTION: boolean;
  50977. SS_LINEARSPECULARREFRACTION: boolean;
  50978. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50979. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50980. UNLIT: boolean;
  50981. DEBUGMODE: number;
  50982. /**
  50983. * Initializes the PBR Material defines.
  50984. */
  50985. constructor();
  50986. /**
  50987. * Resets the PBR Material defines.
  50988. */
  50989. reset(): void;
  50990. }
  50991. /**
  50992. * The Physically based material base class of BJS.
  50993. *
  50994. * This offers the main features of a standard PBR material.
  50995. * For more information, please refer to the documentation :
  50996. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50997. */
  50998. export abstract class PBRBaseMaterial extends PushMaterial {
  50999. /**
  51000. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51001. */
  51002. static readonly PBRMATERIAL_OPAQUE: number;
  51003. /**
  51004. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51005. */
  51006. static readonly PBRMATERIAL_ALPHATEST: number;
  51007. /**
  51008. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51009. */
  51010. static readonly PBRMATERIAL_ALPHABLEND: number;
  51011. /**
  51012. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51013. * They are also discarded below the alpha cutoff threshold to improve performances.
  51014. */
  51015. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51016. /**
  51017. * Defines the default value of how much AO map is occluding the analytical lights
  51018. * (point spot...).
  51019. */
  51020. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51021. /**
  51022. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51023. */
  51024. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51025. /**
  51026. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51027. * to enhance interoperability with other engines.
  51028. */
  51029. static readonly LIGHTFALLOFF_GLTF: number;
  51030. /**
  51031. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51032. * to enhance interoperability with other materials.
  51033. */
  51034. static readonly LIGHTFALLOFF_STANDARD: number;
  51035. /**
  51036. * Intensity of the direct lights e.g. the four lights available in your scene.
  51037. * This impacts both the direct diffuse and specular highlights.
  51038. */
  51039. protected _directIntensity: number;
  51040. /**
  51041. * Intensity of the emissive part of the material.
  51042. * This helps controlling the emissive effect without modifying the emissive color.
  51043. */
  51044. protected _emissiveIntensity: number;
  51045. /**
  51046. * Intensity of the environment e.g. how much the environment will light the object
  51047. * either through harmonics for rough material or through the refelction for shiny ones.
  51048. */
  51049. protected _environmentIntensity: number;
  51050. /**
  51051. * This is a special control allowing the reduction of the specular highlights coming from the
  51052. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51053. */
  51054. protected _specularIntensity: number;
  51055. /**
  51056. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51057. */
  51058. private _lightingInfos;
  51059. /**
  51060. * Debug Control allowing disabling the bump map on this material.
  51061. */
  51062. protected _disableBumpMap: boolean;
  51063. /**
  51064. * AKA Diffuse Texture in standard nomenclature.
  51065. */
  51066. protected _albedoTexture: Nullable<BaseTexture>;
  51067. /**
  51068. * AKA Occlusion Texture in other nomenclature.
  51069. */
  51070. protected _ambientTexture: Nullable<BaseTexture>;
  51071. /**
  51072. * AKA Occlusion Texture Intensity in other nomenclature.
  51073. */
  51074. protected _ambientTextureStrength: number;
  51075. /**
  51076. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51077. * 1 means it completely occludes it
  51078. * 0 mean it has no impact
  51079. */
  51080. protected _ambientTextureImpactOnAnalyticalLights: number;
  51081. /**
  51082. * Stores the alpha values in a texture.
  51083. */
  51084. protected _opacityTexture: Nullable<BaseTexture>;
  51085. /**
  51086. * Stores the reflection values in a texture.
  51087. */
  51088. protected _reflectionTexture: Nullable<BaseTexture>;
  51089. /**
  51090. * Stores the emissive values in a texture.
  51091. */
  51092. protected _emissiveTexture: Nullable<BaseTexture>;
  51093. /**
  51094. * AKA Specular texture in other nomenclature.
  51095. */
  51096. protected _reflectivityTexture: Nullable<BaseTexture>;
  51097. /**
  51098. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51099. */
  51100. protected _metallicTexture: Nullable<BaseTexture>;
  51101. /**
  51102. * Specifies the metallic scalar of the metallic/roughness workflow.
  51103. * Can also be used to scale the metalness values of the metallic texture.
  51104. */
  51105. protected _metallic: Nullable<number>;
  51106. /**
  51107. * Specifies the roughness scalar of the metallic/roughness workflow.
  51108. * Can also be used to scale the roughness values of the metallic texture.
  51109. */
  51110. protected _roughness: Nullable<number>;
  51111. /**
  51112. * Specifies the an F0 factor to help configuring the material F0.
  51113. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51114. * to 0.5 the previously hard coded value stays the same.
  51115. * Can also be used to scale the F0 values of the metallic texture.
  51116. */
  51117. protected _metallicF0Factor: number;
  51118. /**
  51119. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51120. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51121. * your expectation as it multiplies with the texture data.
  51122. */
  51123. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51124. /**
  51125. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51126. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51127. */
  51128. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51129. /**
  51130. * Stores surface normal data used to displace a mesh in a texture.
  51131. */
  51132. protected _bumpTexture: Nullable<BaseTexture>;
  51133. /**
  51134. * Stores the pre-calculated light information of a mesh in a texture.
  51135. */
  51136. protected _lightmapTexture: Nullable<BaseTexture>;
  51137. /**
  51138. * The color of a material in ambient lighting.
  51139. */
  51140. protected _ambientColor: Color3;
  51141. /**
  51142. * AKA Diffuse Color in other nomenclature.
  51143. */
  51144. protected _albedoColor: Color3;
  51145. /**
  51146. * AKA Specular Color in other nomenclature.
  51147. */
  51148. protected _reflectivityColor: Color3;
  51149. /**
  51150. * The color applied when light is reflected from a material.
  51151. */
  51152. protected _reflectionColor: Color3;
  51153. /**
  51154. * The color applied when light is emitted from a material.
  51155. */
  51156. protected _emissiveColor: Color3;
  51157. /**
  51158. * AKA Glossiness in other nomenclature.
  51159. */
  51160. protected _microSurface: number;
  51161. /**
  51162. * Specifies that the material will use the light map as a show map.
  51163. */
  51164. protected _useLightmapAsShadowmap: boolean;
  51165. /**
  51166. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51167. * makes the reflect vector face the model (under horizon).
  51168. */
  51169. protected _useHorizonOcclusion: boolean;
  51170. /**
  51171. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51172. * too much the area relying on ambient texture to define their ambient occlusion.
  51173. */
  51174. protected _useRadianceOcclusion: boolean;
  51175. /**
  51176. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51177. */
  51178. protected _useAlphaFromAlbedoTexture: boolean;
  51179. /**
  51180. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51181. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51182. */
  51183. protected _useSpecularOverAlpha: boolean;
  51184. /**
  51185. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51186. */
  51187. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51188. /**
  51189. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51190. */
  51191. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51192. /**
  51193. * Specifies if the metallic texture contains the roughness information in its green channel.
  51194. */
  51195. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51196. /**
  51197. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51198. */
  51199. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51200. /**
  51201. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51202. */
  51203. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51204. /**
  51205. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51206. */
  51207. protected _useAmbientInGrayScale: boolean;
  51208. /**
  51209. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51210. * The material will try to infer what glossiness each pixel should be.
  51211. */
  51212. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51213. /**
  51214. * Defines the falloff type used in this material.
  51215. * It by default is Physical.
  51216. */
  51217. protected _lightFalloff: number;
  51218. /**
  51219. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51220. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51221. */
  51222. protected _useRadianceOverAlpha: boolean;
  51223. /**
  51224. * Allows using an object space normal map (instead of tangent space).
  51225. */
  51226. protected _useObjectSpaceNormalMap: boolean;
  51227. /**
  51228. * Allows using the bump map in parallax mode.
  51229. */
  51230. protected _useParallax: boolean;
  51231. /**
  51232. * Allows using the bump map in parallax occlusion mode.
  51233. */
  51234. protected _useParallaxOcclusion: boolean;
  51235. /**
  51236. * Controls the scale bias of the parallax mode.
  51237. */
  51238. protected _parallaxScaleBias: number;
  51239. /**
  51240. * If sets to true, disables all the lights affecting the material.
  51241. */
  51242. protected _disableLighting: boolean;
  51243. /**
  51244. * Number of Simultaneous lights allowed on the material.
  51245. */
  51246. protected _maxSimultaneousLights: number;
  51247. /**
  51248. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51249. */
  51250. protected _invertNormalMapX: boolean;
  51251. /**
  51252. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51253. */
  51254. protected _invertNormalMapY: boolean;
  51255. /**
  51256. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51257. */
  51258. protected _twoSidedLighting: boolean;
  51259. /**
  51260. * Defines the alpha limits in alpha test mode.
  51261. */
  51262. protected _alphaCutOff: number;
  51263. /**
  51264. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51265. */
  51266. protected _forceAlphaTest: boolean;
  51267. /**
  51268. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51269. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51270. */
  51271. protected _useAlphaFresnel: boolean;
  51272. /**
  51273. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51274. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51275. */
  51276. protected _useLinearAlphaFresnel: boolean;
  51277. /**
  51278. * The transparency mode of the material.
  51279. */
  51280. protected _transparencyMode: Nullable<number>;
  51281. /**
  51282. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51283. * from cos thetav and roughness:
  51284. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51285. */
  51286. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51287. /**
  51288. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51289. */
  51290. protected _forceIrradianceInFragment: boolean;
  51291. /**
  51292. * Force normal to face away from face.
  51293. */
  51294. protected _forceNormalForward: boolean;
  51295. /**
  51296. * Enables specular anti aliasing in the PBR shader.
  51297. * It will both interacts on the Geometry for analytical and IBL lighting.
  51298. * It also prefilter the roughness map based on the bump values.
  51299. */
  51300. protected _enableSpecularAntiAliasing: boolean;
  51301. /**
  51302. * Default configuration related to image processing available in the PBR Material.
  51303. */
  51304. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51305. /**
  51306. * Keep track of the image processing observer to allow dispose and replace.
  51307. */
  51308. private _imageProcessingObserver;
  51309. /**
  51310. * Attaches a new image processing configuration to the PBR Material.
  51311. * @param configuration
  51312. */
  51313. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51314. /**
  51315. * Stores the available render targets.
  51316. */
  51317. private _renderTargets;
  51318. /**
  51319. * Sets the global ambient color for the material used in lighting calculations.
  51320. */
  51321. private _globalAmbientColor;
  51322. /**
  51323. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51324. */
  51325. private _useLogarithmicDepth;
  51326. /**
  51327. * If set to true, no lighting calculations will be applied.
  51328. */
  51329. private _unlit;
  51330. private _debugMode;
  51331. /**
  51332. * @hidden
  51333. * This is reserved for the inspector.
  51334. * Defines the material debug mode.
  51335. * It helps seeing only some components of the material while troubleshooting.
  51336. */
  51337. debugMode: number;
  51338. /**
  51339. * @hidden
  51340. * This is reserved for the inspector.
  51341. * Specify from where on screen the debug mode should start.
  51342. * The value goes from -1 (full screen) to 1 (not visible)
  51343. * It helps with side by side comparison against the final render
  51344. * This defaults to -1
  51345. */
  51346. private debugLimit;
  51347. /**
  51348. * @hidden
  51349. * This is reserved for the inspector.
  51350. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51351. * You can use the factor to better multiply the final value.
  51352. */
  51353. private debugFactor;
  51354. /**
  51355. * Defines the clear coat layer parameters for the material.
  51356. */
  51357. readonly clearCoat: PBRClearCoatConfiguration;
  51358. /**
  51359. * Defines the anisotropic parameters for the material.
  51360. */
  51361. readonly anisotropy: PBRAnisotropicConfiguration;
  51362. /**
  51363. * Defines the BRDF parameters for the material.
  51364. */
  51365. readonly brdf: PBRBRDFConfiguration;
  51366. /**
  51367. * Defines the Sheen parameters for the material.
  51368. */
  51369. readonly sheen: PBRSheenConfiguration;
  51370. /**
  51371. * Defines the SubSurface parameters for the material.
  51372. */
  51373. readonly subSurface: PBRSubSurfaceConfiguration;
  51374. /**
  51375. * Custom callback helping to override the default shader used in the material.
  51376. */
  51377. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51378. protected _rebuildInParallel: boolean;
  51379. /**
  51380. * Instantiates a new PBRMaterial instance.
  51381. *
  51382. * @param name The material name
  51383. * @param scene The scene the material will be use in.
  51384. */
  51385. constructor(name: string, scene: Scene);
  51386. /**
  51387. * Gets a boolean indicating that current material needs to register RTT
  51388. */
  51389. get hasRenderTargetTextures(): boolean;
  51390. /**
  51391. * Gets the name of the material class.
  51392. */
  51393. getClassName(): string;
  51394. /**
  51395. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51396. */
  51397. get useLogarithmicDepth(): boolean;
  51398. /**
  51399. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51400. */
  51401. set useLogarithmicDepth(value: boolean);
  51402. /**
  51403. * Gets the current transparency mode.
  51404. */
  51405. get transparencyMode(): Nullable<number>;
  51406. /**
  51407. * Sets the transparency mode of the material.
  51408. *
  51409. * | Value | Type | Description |
  51410. * | ----- | ----------------------------------- | ----------- |
  51411. * | 0 | OPAQUE | |
  51412. * | 1 | ALPHATEST | |
  51413. * | 2 | ALPHABLEND | |
  51414. * | 3 | ALPHATESTANDBLEND | |
  51415. *
  51416. */
  51417. set transparencyMode(value: Nullable<number>);
  51418. /**
  51419. * Returns true if alpha blending should be disabled.
  51420. */
  51421. private get _disableAlphaBlending();
  51422. /**
  51423. * Specifies whether or not this material should be rendered in alpha blend mode.
  51424. */
  51425. needAlphaBlending(): boolean;
  51426. /**
  51427. * Specifies if the mesh will require alpha blending.
  51428. * @param mesh - BJS mesh.
  51429. */
  51430. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51431. /**
  51432. * Specifies whether or not this material should be rendered in alpha test mode.
  51433. */
  51434. needAlphaTesting(): boolean;
  51435. /**
  51436. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51437. */
  51438. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51439. /**
  51440. * Gets the texture used for the alpha test.
  51441. */
  51442. getAlphaTestTexture(): Nullable<BaseTexture>;
  51443. /**
  51444. * Specifies that the submesh is ready to be used.
  51445. * @param mesh - BJS mesh.
  51446. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51447. * @param useInstances - Specifies that instances should be used.
  51448. * @returns - boolean indicating that the submesh is ready or not.
  51449. */
  51450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51451. /**
  51452. * Specifies if the material uses metallic roughness workflow.
  51453. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51454. */
  51455. isMetallicWorkflow(): boolean;
  51456. private _prepareEffect;
  51457. private _prepareDefines;
  51458. /**
  51459. * Force shader compilation
  51460. */
  51461. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51462. /**
  51463. * Initializes the uniform buffer layout for the shader.
  51464. */
  51465. buildUniformLayout(): void;
  51466. /**
  51467. * Unbinds the material from the mesh
  51468. */
  51469. unbind(): void;
  51470. /**
  51471. * Binds the submesh data.
  51472. * @param world - The world matrix.
  51473. * @param mesh - The BJS mesh.
  51474. * @param subMesh - A submesh of the BJS mesh.
  51475. */
  51476. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51477. /**
  51478. * Returns the animatable textures.
  51479. * @returns - Array of animatable textures.
  51480. */
  51481. getAnimatables(): IAnimatable[];
  51482. /**
  51483. * Returns the texture used for reflections.
  51484. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51485. */
  51486. private _getReflectionTexture;
  51487. /**
  51488. * Returns an array of the actively used textures.
  51489. * @returns - Array of BaseTextures
  51490. */
  51491. getActiveTextures(): BaseTexture[];
  51492. /**
  51493. * Checks to see if a texture is used in the material.
  51494. * @param texture - Base texture to use.
  51495. * @returns - Boolean specifying if a texture is used in the material.
  51496. */
  51497. hasTexture(texture: BaseTexture): boolean;
  51498. /**
  51499. * Disposes the resources of the material.
  51500. * @param forceDisposeEffect - Forces the disposal of effects.
  51501. * @param forceDisposeTextures - Forces the disposal of all textures.
  51502. */
  51503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51504. }
  51505. }
  51506. declare module BABYLON {
  51507. /**
  51508. * The Physically based material of BJS.
  51509. *
  51510. * This offers the main features of a standard PBR material.
  51511. * For more information, please refer to the documentation :
  51512. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51513. */
  51514. export class PBRMaterial extends PBRBaseMaterial {
  51515. /**
  51516. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51517. */
  51518. static readonly PBRMATERIAL_OPAQUE: number;
  51519. /**
  51520. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51521. */
  51522. static readonly PBRMATERIAL_ALPHATEST: number;
  51523. /**
  51524. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51525. */
  51526. static readonly PBRMATERIAL_ALPHABLEND: number;
  51527. /**
  51528. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51529. * They are also discarded below the alpha cutoff threshold to improve performances.
  51530. */
  51531. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51532. /**
  51533. * Defines the default value of how much AO map is occluding the analytical lights
  51534. * (point spot...).
  51535. */
  51536. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51537. /**
  51538. * Intensity of the direct lights e.g. the four lights available in your scene.
  51539. * This impacts both the direct diffuse and specular highlights.
  51540. */
  51541. directIntensity: number;
  51542. /**
  51543. * Intensity of the emissive part of the material.
  51544. * This helps controlling the emissive effect without modifying the emissive color.
  51545. */
  51546. emissiveIntensity: number;
  51547. /**
  51548. * Intensity of the environment e.g. how much the environment will light the object
  51549. * either through harmonics for rough material or through the refelction for shiny ones.
  51550. */
  51551. environmentIntensity: number;
  51552. /**
  51553. * This is a special control allowing the reduction of the specular highlights coming from the
  51554. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51555. */
  51556. specularIntensity: number;
  51557. /**
  51558. * Debug Control allowing disabling the bump map on this material.
  51559. */
  51560. disableBumpMap: boolean;
  51561. /**
  51562. * AKA Diffuse Texture in standard nomenclature.
  51563. */
  51564. albedoTexture: BaseTexture;
  51565. /**
  51566. * AKA Occlusion Texture in other nomenclature.
  51567. */
  51568. ambientTexture: BaseTexture;
  51569. /**
  51570. * AKA Occlusion Texture Intensity in other nomenclature.
  51571. */
  51572. ambientTextureStrength: number;
  51573. /**
  51574. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51575. * 1 means it completely occludes it
  51576. * 0 mean it has no impact
  51577. */
  51578. ambientTextureImpactOnAnalyticalLights: number;
  51579. /**
  51580. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51581. */
  51582. opacityTexture: BaseTexture;
  51583. /**
  51584. * Stores the reflection values in a texture.
  51585. */
  51586. reflectionTexture: Nullable<BaseTexture>;
  51587. /**
  51588. * Stores the emissive values in a texture.
  51589. */
  51590. emissiveTexture: BaseTexture;
  51591. /**
  51592. * AKA Specular texture in other nomenclature.
  51593. */
  51594. reflectivityTexture: BaseTexture;
  51595. /**
  51596. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51597. */
  51598. metallicTexture: BaseTexture;
  51599. /**
  51600. * Specifies the metallic scalar of the metallic/roughness workflow.
  51601. * Can also be used to scale the metalness values of the metallic texture.
  51602. */
  51603. metallic: Nullable<number>;
  51604. /**
  51605. * Specifies the roughness scalar of the metallic/roughness workflow.
  51606. * Can also be used to scale the roughness values of the metallic texture.
  51607. */
  51608. roughness: Nullable<number>;
  51609. /**
  51610. * Specifies the an F0 factor to help configuring the material F0.
  51611. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51612. * to 0.5 the previously hard coded value stays the same.
  51613. * Can also be used to scale the F0 values of the metallic texture.
  51614. */
  51615. metallicF0Factor: number;
  51616. /**
  51617. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51618. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51619. * your expectation as it multiplies with the texture data.
  51620. */
  51621. useMetallicF0FactorFromMetallicTexture: boolean;
  51622. /**
  51623. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51624. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51625. */
  51626. microSurfaceTexture: BaseTexture;
  51627. /**
  51628. * Stores surface normal data used to displace a mesh in a texture.
  51629. */
  51630. bumpTexture: BaseTexture;
  51631. /**
  51632. * Stores the pre-calculated light information of a mesh in a texture.
  51633. */
  51634. lightmapTexture: BaseTexture;
  51635. /**
  51636. * Stores the refracted light information in a texture.
  51637. */
  51638. get refractionTexture(): Nullable<BaseTexture>;
  51639. set refractionTexture(value: Nullable<BaseTexture>);
  51640. /**
  51641. * The color of a material in ambient lighting.
  51642. */
  51643. ambientColor: Color3;
  51644. /**
  51645. * AKA Diffuse Color in other nomenclature.
  51646. */
  51647. albedoColor: Color3;
  51648. /**
  51649. * AKA Specular Color in other nomenclature.
  51650. */
  51651. reflectivityColor: Color3;
  51652. /**
  51653. * The color reflected from the material.
  51654. */
  51655. reflectionColor: Color3;
  51656. /**
  51657. * The color emitted from the material.
  51658. */
  51659. emissiveColor: Color3;
  51660. /**
  51661. * AKA Glossiness in other nomenclature.
  51662. */
  51663. microSurface: number;
  51664. /**
  51665. * source material index of refraction (IOR)' / 'destination material IOR.
  51666. */
  51667. get indexOfRefraction(): number;
  51668. set indexOfRefraction(value: number);
  51669. /**
  51670. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51671. */
  51672. get invertRefractionY(): boolean;
  51673. set invertRefractionY(value: boolean);
  51674. /**
  51675. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51676. * Materials half opaque for instance using refraction could benefit from this control.
  51677. */
  51678. get linkRefractionWithTransparency(): boolean;
  51679. set linkRefractionWithTransparency(value: boolean);
  51680. /**
  51681. * If true, the light map contains occlusion information instead of lighting info.
  51682. */
  51683. useLightmapAsShadowmap: boolean;
  51684. /**
  51685. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51686. */
  51687. useAlphaFromAlbedoTexture: boolean;
  51688. /**
  51689. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51690. */
  51691. forceAlphaTest: boolean;
  51692. /**
  51693. * Defines the alpha limits in alpha test mode.
  51694. */
  51695. alphaCutOff: number;
  51696. /**
  51697. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51698. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51699. */
  51700. useSpecularOverAlpha: boolean;
  51701. /**
  51702. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51703. */
  51704. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51705. /**
  51706. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51707. */
  51708. useRoughnessFromMetallicTextureAlpha: boolean;
  51709. /**
  51710. * Specifies if the metallic texture contains the roughness information in its green channel.
  51711. */
  51712. useRoughnessFromMetallicTextureGreen: boolean;
  51713. /**
  51714. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51715. */
  51716. useMetallnessFromMetallicTextureBlue: boolean;
  51717. /**
  51718. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51719. */
  51720. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51721. /**
  51722. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51723. */
  51724. useAmbientInGrayScale: boolean;
  51725. /**
  51726. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51727. * The material will try to infer what glossiness each pixel should be.
  51728. */
  51729. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51730. /**
  51731. * BJS is using an harcoded light falloff based on a manually sets up range.
  51732. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51733. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51734. */
  51735. get usePhysicalLightFalloff(): boolean;
  51736. /**
  51737. * BJS is using an harcoded light falloff based on a manually sets up range.
  51738. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51739. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51740. */
  51741. set usePhysicalLightFalloff(value: boolean);
  51742. /**
  51743. * In order to support the falloff compatibility with gltf, a special mode has been added
  51744. * to reproduce the gltf light falloff.
  51745. */
  51746. get useGLTFLightFalloff(): boolean;
  51747. /**
  51748. * In order to support the falloff compatibility with gltf, a special mode has been added
  51749. * to reproduce the gltf light falloff.
  51750. */
  51751. set useGLTFLightFalloff(value: boolean);
  51752. /**
  51753. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51754. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51755. */
  51756. useRadianceOverAlpha: boolean;
  51757. /**
  51758. * Allows using an object space normal map (instead of tangent space).
  51759. */
  51760. useObjectSpaceNormalMap: boolean;
  51761. /**
  51762. * Allows using the bump map in parallax mode.
  51763. */
  51764. useParallax: boolean;
  51765. /**
  51766. * Allows using the bump map in parallax occlusion mode.
  51767. */
  51768. useParallaxOcclusion: boolean;
  51769. /**
  51770. * Controls the scale bias of the parallax mode.
  51771. */
  51772. parallaxScaleBias: number;
  51773. /**
  51774. * If sets to true, disables all the lights affecting the material.
  51775. */
  51776. disableLighting: boolean;
  51777. /**
  51778. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51779. */
  51780. forceIrradianceInFragment: boolean;
  51781. /**
  51782. * Number of Simultaneous lights allowed on the material.
  51783. */
  51784. maxSimultaneousLights: number;
  51785. /**
  51786. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51787. */
  51788. invertNormalMapX: boolean;
  51789. /**
  51790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51791. */
  51792. invertNormalMapY: boolean;
  51793. /**
  51794. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51795. */
  51796. twoSidedLighting: boolean;
  51797. /**
  51798. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51799. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51800. */
  51801. useAlphaFresnel: boolean;
  51802. /**
  51803. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51804. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51805. */
  51806. useLinearAlphaFresnel: boolean;
  51807. /**
  51808. * Let user defines the brdf lookup texture used for IBL.
  51809. * A default 8bit version is embedded but you could point at :
  51810. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51811. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51812. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51813. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51814. */
  51815. environmentBRDFTexture: Nullable<BaseTexture>;
  51816. /**
  51817. * Force normal to face away from face.
  51818. */
  51819. forceNormalForward: boolean;
  51820. /**
  51821. * Enables specular anti aliasing in the PBR shader.
  51822. * It will both interacts on the Geometry for analytical and IBL lighting.
  51823. * It also prefilter the roughness map based on the bump values.
  51824. */
  51825. enableSpecularAntiAliasing: boolean;
  51826. /**
  51827. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51828. * makes the reflect vector face the model (under horizon).
  51829. */
  51830. useHorizonOcclusion: boolean;
  51831. /**
  51832. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51833. * too much the area relying on ambient texture to define their ambient occlusion.
  51834. */
  51835. useRadianceOcclusion: boolean;
  51836. /**
  51837. * If set to true, no lighting calculations will be applied.
  51838. */
  51839. unlit: boolean;
  51840. /**
  51841. * Gets the image processing configuration used either in this material.
  51842. */
  51843. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51844. /**
  51845. * Sets the Default image processing configuration used either in the this material.
  51846. *
  51847. * If sets to null, the scene one is in use.
  51848. */
  51849. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51850. /**
  51851. * Gets wether the color curves effect is enabled.
  51852. */
  51853. get cameraColorCurvesEnabled(): boolean;
  51854. /**
  51855. * Sets wether the color curves effect is enabled.
  51856. */
  51857. set cameraColorCurvesEnabled(value: boolean);
  51858. /**
  51859. * Gets wether the color grading effect is enabled.
  51860. */
  51861. get cameraColorGradingEnabled(): boolean;
  51862. /**
  51863. * Gets wether the color grading effect is enabled.
  51864. */
  51865. set cameraColorGradingEnabled(value: boolean);
  51866. /**
  51867. * Gets wether tonemapping is enabled or not.
  51868. */
  51869. get cameraToneMappingEnabled(): boolean;
  51870. /**
  51871. * Sets wether tonemapping is enabled or not
  51872. */
  51873. set cameraToneMappingEnabled(value: boolean);
  51874. /**
  51875. * The camera exposure used on this material.
  51876. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51877. * This corresponds to a photographic exposure.
  51878. */
  51879. get cameraExposure(): number;
  51880. /**
  51881. * The camera exposure used on this material.
  51882. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51883. * This corresponds to a photographic exposure.
  51884. */
  51885. set cameraExposure(value: number);
  51886. /**
  51887. * Gets The camera contrast used on this material.
  51888. */
  51889. get cameraContrast(): number;
  51890. /**
  51891. * Sets The camera contrast used on this material.
  51892. */
  51893. set cameraContrast(value: number);
  51894. /**
  51895. * Gets the Color Grading 2D Lookup Texture.
  51896. */
  51897. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51898. /**
  51899. * Sets the Color Grading 2D Lookup Texture.
  51900. */
  51901. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51902. /**
  51903. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51904. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51905. * 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;
  51906. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51907. */
  51908. get cameraColorCurves(): Nullable<ColorCurves>;
  51909. /**
  51910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51912. * 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;
  51913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51914. */
  51915. set cameraColorCurves(value: Nullable<ColorCurves>);
  51916. /**
  51917. * Instantiates a new PBRMaterial instance.
  51918. *
  51919. * @param name The material name
  51920. * @param scene The scene the material will be use in.
  51921. */
  51922. constructor(name: string, scene: Scene);
  51923. /**
  51924. * Returns the name of this material class.
  51925. */
  51926. getClassName(): string;
  51927. /**
  51928. * Makes a duplicate of the current material.
  51929. * @param name - name to use for the new material.
  51930. */
  51931. clone(name: string): PBRMaterial;
  51932. /**
  51933. * Serializes this PBR Material.
  51934. * @returns - An object with the serialized material.
  51935. */
  51936. serialize(): any;
  51937. /**
  51938. * Parses a PBR Material from a serialized object.
  51939. * @param source - Serialized object.
  51940. * @param scene - BJS scene instance.
  51941. * @param rootUrl - url for the scene object
  51942. * @returns - PBRMaterial
  51943. */
  51944. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51945. }
  51946. }
  51947. declare module BABYLON {
  51948. /**
  51949. * Direct draw surface info
  51950. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51951. */
  51952. export interface DDSInfo {
  51953. /**
  51954. * Width of the texture
  51955. */
  51956. width: number;
  51957. /**
  51958. * Width of the texture
  51959. */
  51960. height: number;
  51961. /**
  51962. * Number of Mipmaps for the texture
  51963. * @see https://en.wikipedia.org/wiki/Mipmap
  51964. */
  51965. mipmapCount: number;
  51966. /**
  51967. * If the textures format is a known fourCC format
  51968. * @see https://www.fourcc.org/
  51969. */
  51970. isFourCC: boolean;
  51971. /**
  51972. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51973. */
  51974. isRGB: boolean;
  51975. /**
  51976. * If the texture is a lumincance format
  51977. */
  51978. isLuminance: boolean;
  51979. /**
  51980. * If this is a cube texture
  51981. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51982. */
  51983. isCube: boolean;
  51984. /**
  51985. * If the texture is a compressed format eg. FOURCC_DXT1
  51986. */
  51987. isCompressed: boolean;
  51988. /**
  51989. * The dxgiFormat of the texture
  51990. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51991. */
  51992. dxgiFormat: number;
  51993. /**
  51994. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51995. */
  51996. textureType: number;
  51997. /**
  51998. * Sphericle polynomial created for the dds texture
  51999. */
  52000. sphericalPolynomial?: SphericalPolynomial;
  52001. }
  52002. /**
  52003. * Class used to provide DDS decompression tools
  52004. */
  52005. export class DDSTools {
  52006. /**
  52007. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52008. */
  52009. static StoreLODInAlphaChannel: boolean;
  52010. /**
  52011. * Gets DDS information from an array buffer
  52012. * @param data defines the array buffer view to read data from
  52013. * @returns the DDS information
  52014. */
  52015. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52016. private static _FloatView;
  52017. private static _Int32View;
  52018. private static _ToHalfFloat;
  52019. private static _FromHalfFloat;
  52020. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52021. private static _GetHalfFloatRGBAArrayBuffer;
  52022. private static _GetFloatRGBAArrayBuffer;
  52023. private static _GetFloatAsUIntRGBAArrayBuffer;
  52024. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52025. private static _GetRGBAArrayBuffer;
  52026. private static _ExtractLongWordOrder;
  52027. private static _GetRGBArrayBuffer;
  52028. private static _GetLuminanceArrayBuffer;
  52029. /**
  52030. * Uploads DDS Levels to a Babylon Texture
  52031. * @hidden
  52032. */
  52033. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52034. }
  52035. interface ThinEngine {
  52036. /**
  52037. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52038. * @param rootUrl defines the url where the file to load is located
  52039. * @param scene defines the current scene
  52040. * @param lodScale defines scale to apply to the mip map selection
  52041. * @param lodOffset defines offset to apply to the mip map selection
  52042. * @param onLoad defines an optional callback raised when the texture is loaded
  52043. * @param onError defines an optional callback raised if there is an issue to load the texture
  52044. * @param format defines the format of the data
  52045. * @param forcedExtension defines the extension to use to pick the right loader
  52046. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52047. * @returns the cube texture as an InternalTexture
  52048. */
  52049. 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;
  52050. }
  52051. }
  52052. declare module BABYLON {
  52053. /**
  52054. * Implementation of the DDS Texture Loader.
  52055. * @hidden
  52056. */
  52057. export class _DDSTextureLoader implements IInternalTextureLoader {
  52058. /**
  52059. * Defines wether the loader supports cascade loading the different faces.
  52060. */
  52061. readonly supportCascades: boolean;
  52062. /**
  52063. * This returns if the loader support the current file information.
  52064. * @param extension defines the file extension of the file being loaded
  52065. * @returns true if the loader can load the specified file
  52066. */
  52067. canLoad(extension: string): boolean;
  52068. /**
  52069. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52070. * @param data contains the texture data
  52071. * @param texture defines the BabylonJS internal texture
  52072. * @param createPolynomials will be true if polynomials have been requested
  52073. * @param onLoad defines the callback to trigger once the texture is ready
  52074. * @param onError defines the callback to trigger in case of error
  52075. */
  52076. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52077. /**
  52078. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52079. * @param data contains the texture data
  52080. * @param texture defines the BabylonJS internal texture
  52081. * @param callback defines the method to call once ready to upload
  52082. */
  52083. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52084. }
  52085. }
  52086. declare module BABYLON {
  52087. /**
  52088. * Implementation of the ENV Texture Loader.
  52089. * @hidden
  52090. */
  52091. export class _ENVTextureLoader implements IInternalTextureLoader {
  52092. /**
  52093. * Defines wether the loader supports cascade loading the different faces.
  52094. */
  52095. readonly supportCascades: boolean;
  52096. /**
  52097. * This returns if the loader support the current file information.
  52098. * @param extension defines the file extension of the file being loaded
  52099. * @returns true if the loader can load the specified file
  52100. */
  52101. canLoad(extension: string): boolean;
  52102. /**
  52103. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52104. * @param data contains the texture data
  52105. * @param texture defines the BabylonJS internal texture
  52106. * @param createPolynomials will be true if polynomials have been requested
  52107. * @param onLoad defines the callback to trigger once the texture is ready
  52108. * @param onError defines the callback to trigger in case of error
  52109. */
  52110. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52111. /**
  52112. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52113. * @param data contains the texture data
  52114. * @param texture defines the BabylonJS internal texture
  52115. * @param callback defines the method to call once ready to upload
  52116. */
  52117. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52118. }
  52119. }
  52120. declare module BABYLON {
  52121. /**
  52122. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52123. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52124. */
  52125. export class KhronosTextureContainer {
  52126. /** contents of the KTX container file */
  52127. data: ArrayBufferView;
  52128. private static HEADER_LEN;
  52129. private static COMPRESSED_2D;
  52130. private static COMPRESSED_3D;
  52131. private static TEX_2D;
  52132. private static TEX_3D;
  52133. /**
  52134. * Gets the openGL type
  52135. */
  52136. glType: number;
  52137. /**
  52138. * Gets the openGL type size
  52139. */
  52140. glTypeSize: number;
  52141. /**
  52142. * Gets the openGL format
  52143. */
  52144. glFormat: number;
  52145. /**
  52146. * Gets the openGL internal format
  52147. */
  52148. glInternalFormat: number;
  52149. /**
  52150. * Gets the base internal format
  52151. */
  52152. glBaseInternalFormat: number;
  52153. /**
  52154. * Gets image width in pixel
  52155. */
  52156. pixelWidth: number;
  52157. /**
  52158. * Gets image height in pixel
  52159. */
  52160. pixelHeight: number;
  52161. /**
  52162. * Gets image depth in pixels
  52163. */
  52164. pixelDepth: number;
  52165. /**
  52166. * Gets the number of array elements
  52167. */
  52168. numberOfArrayElements: number;
  52169. /**
  52170. * Gets the number of faces
  52171. */
  52172. numberOfFaces: number;
  52173. /**
  52174. * Gets the number of mipmap levels
  52175. */
  52176. numberOfMipmapLevels: number;
  52177. /**
  52178. * Gets the bytes of key value data
  52179. */
  52180. bytesOfKeyValueData: number;
  52181. /**
  52182. * Gets the load type
  52183. */
  52184. loadType: number;
  52185. /**
  52186. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52187. */
  52188. isInvalid: boolean;
  52189. /**
  52190. * Creates a new KhronosTextureContainer
  52191. * @param data contents of the KTX container file
  52192. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52193. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52194. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52195. */
  52196. constructor(
  52197. /** contents of the KTX container file */
  52198. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52199. /**
  52200. * Uploads KTX content to a Babylon Texture.
  52201. * It is assumed that the texture has already been created & is currently bound
  52202. * @hidden
  52203. */
  52204. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52205. private _upload2DCompressedLevels;
  52206. /**
  52207. * Checks if the given data starts with a KTX file identifier.
  52208. * @param data the data to check
  52209. * @returns true if the data is a KTX file or false otherwise
  52210. */
  52211. static IsValid(data: ArrayBufferView): boolean;
  52212. }
  52213. }
  52214. declare module BABYLON {
  52215. /**
  52216. * Class for loading KTX2 files
  52217. * !!! Experimental Extension Subject to Changes !!!
  52218. * @hidden
  52219. */
  52220. export class KhronosTextureContainer2 {
  52221. private static _ModulePromise;
  52222. private static _TranscodeFormat;
  52223. constructor(engine: ThinEngine);
  52224. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52225. private _determineTranscodeFormat;
  52226. /**
  52227. * Checks if the given data starts with a KTX2 file identifier.
  52228. * @param data the data to check
  52229. * @returns true if the data is a KTX2 file or false otherwise
  52230. */
  52231. static IsValid(data: ArrayBufferView): boolean;
  52232. }
  52233. }
  52234. declare module BABYLON {
  52235. /**
  52236. * Implementation of the KTX Texture Loader.
  52237. * @hidden
  52238. */
  52239. export class _KTXTextureLoader implements IInternalTextureLoader {
  52240. /**
  52241. * Defines wether the loader supports cascade loading the different faces.
  52242. */
  52243. readonly supportCascades: boolean;
  52244. /**
  52245. * This returns if the loader support the current file information.
  52246. * @param extension defines the file extension of the file being loaded
  52247. * @returns true if the loader can load the specified file
  52248. */
  52249. canLoad(extension: string): boolean;
  52250. /**
  52251. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52252. * @param data contains the texture data
  52253. * @param texture defines the BabylonJS internal texture
  52254. * @param createPolynomials will be true if polynomials have been requested
  52255. * @param onLoad defines the callback to trigger once the texture is ready
  52256. * @param onError defines the callback to trigger in case of error
  52257. */
  52258. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52259. /**
  52260. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52261. * @param data contains the texture data
  52262. * @param texture defines the BabylonJS internal texture
  52263. * @param callback defines the method to call once ready to upload
  52264. */
  52265. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52266. }
  52267. }
  52268. declare module BABYLON {
  52269. /** @hidden */
  52270. export var _forceSceneHelpersToBundle: boolean;
  52271. interface Scene {
  52272. /**
  52273. * Creates a default light for the scene.
  52274. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52275. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52276. */
  52277. createDefaultLight(replace?: boolean): void;
  52278. /**
  52279. * Creates a default camera for the scene.
  52280. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52281. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52282. * @param replace has default false, when true replaces the active camera in the scene
  52283. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52284. */
  52285. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52286. /**
  52287. * Creates a default camera and a default light.
  52288. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52289. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52290. * @param replace has the default false, when true replaces the active camera/light in the scene
  52291. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52292. */
  52293. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52294. /**
  52295. * Creates a new sky box
  52296. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52297. * @param environmentTexture defines the texture to use as environment texture
  52298. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52299. * @param scale defines the overall scale of the skybox
  52300. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52301. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52302. * @returns a new mesh holding the sky box
  52303. */
  52304. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52305. /**
  52306. * Creates a new environment
  52307. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52308. * @param options defines the options you can use to configure the environment
  52309. * @returns the new EnvironmentHelper
  52310. */
  52311. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52312. /**
  52313. * Creates a new VREXperienceHelper
  52314. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52315. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52316. * @returns a new VREXperienceHelper
  52317. */
  52318. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52319. /**
  52320. * Creates a new WebXRDefaultExperience
  52321. * @see http://doc.babylonjs.com/how_to/webxr
  52322. * @param options experience options
  52323. * @returns a promise for a new WebXRDefaultExperience
  52324. */
  52325. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52326. }
  52327. }
  52328. declare module BABYLON {
  52329. /**
  52330. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52331. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52332. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52333. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52334. */
  52335. export class VideoDome extends TransformNode {
  52336. /**
  52337. * Define the video source as a Monoscopic panoramic 360 video.
  52338. */
  52339. static readonly MODE_MONOSCOPIC: number;
  52340. /**
  52341. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52342. */
  52343. static readonly MODE_TOPBOTTOM: number;
  52344. /**
  52345. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52346. */
  52347. static readonly MODE_SIDEBYSIDE: number;
  52348. private _halfDome;
  52349. private _useDirectMapping;
  52350. /**
  52351. * The video texture being displayed on the sphere
  52352. */
  52353. protected _videoTexture: VideoTexture;
  52354. /**
  52355. * Gets the video texture being displayed on the sphere
  52356. */
  52357. get videoTexture(): VideoTexture;
  52358. /**
  52359. * The skybox material
  52360. */
  52361. protected _material: BackgroundMaterial;
  52362. /**
  52363. * The surface used for the skybox
  52364. */
  52365. protected _mesh: Mesh;
  52366. /**
  52367. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52368. */
  52369. private _halfDomeMask;
  52370. /**
  52371. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52372. * Also see the options.resolution property.
  52373. */
  52374. get fovMultiplier(): number;
  52375. set fovMultiplier(value: number);
  52376. private _videoMode;
  52377. /**
  52378. * Gets or set the current video mode for the video. It can be:
  52379. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52380. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52381. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52382. */
  52383. get videoMode(): number;
  52384. set videoMode(value: number);
  52385. /**
  52386. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52387. *
  52388. */
  52389. get halfDome(): boolean;
  52390. /**
  52391. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52392. */
  52393. set halfDome(enabled: boolean);
  52394. /**
  52395. * Oberserver used in Stereoscopic VR Mode.
  52396. */
  52397. private _onBeforeCameraRenderObserver;
  52398. /**
  52399. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52400. * @param name Element's name, child elements will append suffixes for their own names.
  52401. * @param urlsOrVideo defines the url(s) or the video element to use
  52402. * @param options An object containing optional or exposed sub element properties
  52403. */
  52404. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52405. resolution?: number;
  52406. clickToPlay?: boolean;
  52407. autoPlay?: boolean;
  52408. loop?: boolean;
  52409. size?: number;
  52410. poster?: string;
  52411. faceForward?: boolean;
  52412. useDirectMapping?: boolean;
  52413. halfDomeMode?: boolean;
  52414. }, scene: Scene);
  52415. private _changeVideoMode;
  52416. /**
  52417. * Releases resources associated with this node.
  52418. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52419. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52420. */
  52421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52422. }
  52423. }
  52424. declare module BABYLON {
  52425. /**
  52426. * This class can be used to get instrumentation data from a Babylon engine
  52427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52428. */
  52429. export class EngineInstrumentation implements IDisposable {
  52430. /**
  52431. * Define the instrumented engine.
  52432. */
  52433. engine: Engine;
  52434. private _captureGPUFrameTime;
  52435. private _gpuFrameTimeToken;
  52436. private _gpuFrameTime;
  52437. private _captureShaderCompilationTime;
  52438. private _shaderCompilationTime;
  52439. private _onBeginFrameObserver;
  52440. private _onEndFrameObserver;
  52441. private _onBeforeShaderCompilationObserver;
  52442. private _onAfterShaderCompilationObserver;
  52443. /**
  52444. * Gets the perf counter used for GPU frame time
  52445. */
  52446. get gpuFrameTimeCounter(): PerfCounter;
  52447. /**
  52448. * Gets the GPU frame time capture status
  52449. */
  52450. get captureGPUFrameTime(): boolean;
  52451. /**
  52452. * Enable or disable the GPU frame time capture
  52453. */
  52454. set captureGPUFrameTime(value: boolean);
  52455. /**
  52456. * Gets the perf counter used for shader compilation time
  52457. */
  52458. get shaderCompilationTimeCounter(): PerfCounter;
  52459. /**
  52460. * Gets the shader compilation time capture status
  52461. */
  52462. get captureShaderCompilationTime(): boolean;
  52463. /**
  52464. * Enable or disable the shader compilation time capture
  52465. */
  52466. set captureShaderCompilationTime(value: boolean);
  52467. /**
  52468. * Instantiates a new engine instrumentation.
  52469. * This class can be used to get instrumentation data from a Babylon engine
  52470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52471. * @param engine Defines the engine to instrument
  52472. */
  52473. constructor(
  52474. /**
  52475. * Define the instrumented engine.
  52476. */
  52477. engine: Engine);
  52478. /**
  52479. * Dispose and release associated resources.
  52480. */
  52481. dispose(): void;
  52482. }
  52483. }
  52484. declare module BABYLON {
  52485. /**
  52486. * This class can be used to get instrumentation data from a Babylon engine
  52487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52488. */
  52489. export class SceneInstrumentation implements IDisposable {
  52490. /**
  52491. * Defines the scene to instrument
  52492. */
  52493. scene: Scene;
  52494. private _captureActiveMeshesEvaluationTime;
  52495. private _activeMeshesEvaluationTime;
  52496. private _captureRenderTargetsRenderTime;
  52497. private _renderTargetsRenderTime;
  52498. private _captureFrameTime;
  52499. private _frameTime;
  52500. private _captureRenderTime;
  52501. private _renderTime;
  52502. private _captureInterFrameTime;
  52503. private _interFrameTime;
  52504. private _captureParticlesRenderTime;
  52505. private _particlesRenderTime;
  52506. private _captureSpritesRenderTime;
  52507. private _spritesRenderTime;
  52508. private _capturePhysicsTime;
  52509. private _physicsTime;
  52510. private _captureAnimationsTime;
  52511. private _animationsTime;
  52512. private _captureCameraRenderTime;
  52513. private _cameraRenderTime;
  52514. private _onBeforeActiveMeshesEvaluationObserver;
  52515. private _onAfterActiveMeshesEvaluationObserver;
  52516. private _onBeforeRenderTargetsRenderObserver;
  52517. private _onAfterRenderTargetsRenderObserver;
  52518. private _onAfterRenderObserver;
  52519. private _onBeforeDrawPhaseObserver;
  52520. private _onAfterDrawPhaseObserver;
  52521. private _onBeforeAnimationsObserver;
  52522. private _onBeforeParticlesRenderingObserver;
  52523. private _onAfterParticlesRenderingObserver;
  52524. private _onBeforeSpritesRenderingObserver;
  52525. private _onAfterSpritesRenderingObserver;
  52526. private _onBeforePhysicsObserver;
  52527. private _onAfterPhysicsObserver;
  52528. private _onAfterAnimationsObserver;
  52529. private _onBeforeCameraRenderObserver;
  52530. private _onAfterCameraRenderObserver;
  52531. /**
  52532. * Gets the perf counter used for active meshes evaluation time
  52533. */
  52534. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52535. /**
  52536. * Gets the active meshes evaluation time capture status
  52537. */
  52538. get captureActiveMeshesEvaluationTime(): boolean;
  52539. /**
  52540. * Enable or disable the active meshes evaluation time capture
  52541. */
  52542. set captureActiveMeshesEvaluationTime(value: boolean);
  52543. /**
  52544. * Gets the perf counter used for render targets render time
  52545. */
  52546. get renderTargetsRenderTimeCounter(): PerfCounter;
  52547. /**
  52548. * Gets the render targets render time capture status
  52549. */
  52550. get captureRenderTargetsRenderTime(): boolean;
  52551. /**
  52552. * Enable or disable the render targets render time capture
  52553. */
  52554. set captureRenderTargetsRenderTime(value: boolean);
  52555. /**
  52556. * Gets the perf counter used for particles render time
  52557. */
  52558. get particlesRenderTimeCounter(): PerfCounter;
  52559. /**
  52560. * Gets the particles render time capture status
  52561. */
  52562. get captureParticlesRenderTime(): boolean;
  52563. /**
  52564. * Enable or disable the particles render time capture
  52565. */
  52566. set captureParticlesRenderTime(value: boolean);
  52567. /**
  52568. * Gets the perf counter used for sprites render time
  52569. */
  52570. get spritesRenderTimeCounter(): PerfCounter;
  52571. /**
  52572. * Gets the sprites render time capture status
  52573. */
  52574. get captureSpritesRenderTime(): boolean;
  52575. /**
  52576. * Enable or disable the sprites render time capture
  52577. */
  52578. set captureSpritesRenderTime(value: boolean);
  52579. /**
  52580. * Gets the perf counter used for physics time
  52581. */
  52582. get physicsTimeCounter(): PerfCounter;
  52583. /**
  52584. * Gets the physics time capture status
  52585. */
  52586. get capturePhysicsTime(): boolean;
  52587. /**
  52588. * Enable or disable the physics time capture
  52589. */
  52590. set capturePhysicsTime(value: boolean);
  52591. /**
  52592. * Gets the perf counter used for animations time
  52593. */
  52594. get animationsTimeCounter(): PerfCounter;
  52595. /**
  52596. * Gets the animations time capture status
  52597. */
  52598. get captureAnimationsTime(): boolean;
  52599. /**
  52600. * Enable or disable the animations time capture
  52601. */
  52602. set captureAnimationsTime(value: boolean);
  52603. /**
  52604. * Gets the perf counter used for frame time capture
  52605. */
  52606. get frameTimeCounter(): PerfCounter;
  52607. /**
  52608. * Gets the frame time capture status
  52609. */
  52610. get captureFrameTime(): boolean;
  52611. /**
  52612. * Enable or disable the frame time capture
  52613. */
  52614. set captureFrameTime(value: boolean);
  52615. /**
  52616. * Gets the perf counter used for inter-frames time capture
  52617. */
  52618. get interFrameTimeCounter(): PerfCounter;
  52619. /**
  52620. * Gets the inter-frames time capture status
  52621. */
  52622. get captureInterFrameTime(): boolean;
  52623. /**
  52624. * Enable or disable the inter-frames time capture
  52625. */
  52626. set captureInterFrameTime(value: boolean);
  52627. /**
  52628. * Gets the perf counter used for render time capture
  52629. */
  52630. get renderTimeCounter(): PerfCounter;
  52631. /**
  52632. * Gets the render time capture status
  52633. */
  52634. get captureRenderTime(): boolean;
  52635. /**
  52636. * Enable or disable the render time capture
  52637. */
  52638. set captureRenderTime(value: boolean);
  52639. /**
  52640. * Gets the perf counter used for camera render time capture
  52641. */
  52642. get cameraRenderTimeCounter(): PerfCounter;
  52643. /**
  52644. * Gets the camera render time capture status
  52645. */
  52646. get captureCameraRenderTime(): boolean;
  52647. /**
  52648. * Enable or disable the camera render time capture
  52649. */
  52650. set captureCameraRenderTime(value: boolean);
  52651. /**
  52652. * Gets the perf counter used for draw calls
  52653. */
  52654. get drawCallsCounter(): PerfCounter;
  52655. /**
  52656. * Instantiates a new scene instrumentation.
  52657. * This class can be used to get instrumentation data from a Babylon engine
  52658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52659. * @param scene Defines the scene to instrument
  52660. */
  52661. constructor(
  52662. /**
  52663. * Defines the scene to instrument
  52664. */
  52665. scene: Scene);
  52666. /**
  52667. * Dispose and release associated resources.
  52668. */
  52669. dispose(): void;
  52670. }
  52671. }
  52672. declare module BABYLON {
  52673. /** @hidden */
  52674. export var glowMapGenerationPixelShader: {
  52675. name: string;
  52676. shader: string;
  52677. };
  52678. }
  52679. declare module BABYLON {
  52680. /** @hidden */
  52681. export var glowMapGenerationVertexShader: {
  52682. name: string;
  52683. shader: string;
  52684. };
  52685. }
  52686. declare module BABYLON {
  52687. /**
  52688. * Effect layer options. This helps customizing the behaviour
  52689. * of the effect layer.
  52690. */
  52691. export interface IEffectLayerOptions {
  52692. /**
  52693. * Multiplication factor apply to the canvas size to compute the render target size
  52694. * used to generated the objects (the smaller the faster).
  52695. */
  52696. mainTextureRatio: number;
  52697. /**
  52698. * Enforces a fixed size texture to ensure effect stability across devices.
  52699. */
  52700. mainTextureFixedSize?: number;
  52701. /**
  52702. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52703. */
  52704. alphaBlendingMode: number;
  52705. /**
  52706. * The camera attached to the layer.
  52707. */
  52708. camera: Nullable<Camera>;
  52709. /**
  52710. * The rendering group to draw the layer in.
  52711. */
  52712. renderingGroupId: number;
  52713. }
  52714. /**
  52715. * The effect layer Helps adding post process effect blended with the main pass.
  52716. *
  52717. * This can be for instance use to generate glow or higlight effects on the scene.
  52718. *
  52719. * The effect layer class can not be used directly and is intented to inherited from to be
  52720. * customized per effects.
  52721. */
  52722. export abstract class EffectLayer {
  52723. private _vertexBuffers;
  52724. private _indexBuffer;
  52725. private _cachedDefines;
  52726. private _effectLayerMapGenerationEffect;
  52727. private _effectLayerOptions;
  52728. private _mergeEffect;
  52729. protected _scene: Scene;
  52730. protected _engine: Engine;
  52731. protected _maxSize: number;
  52732. protected _mainTextureDesiredSize: ISize;
  52733. protected _mainTexture: RenderTargetTexture;
  52734. protected _shouldRender: boolean;
  52735. protected _postProcesses: PostProcess[];
  52736. protected _textures: BaseTexture[];
  52737. protected _emissiveTextureAndColor: {
  52738. texture: Nullable<BaseTexture>;
  52739. color: Color4;
  52740. };
  52741. /**
  52742. * The name of the layer
  52743. */
  52744. name: string;
  52745. /**
  52746. * The clear color of the texture used to generate the glow map.
  52747. */
  52748. neutralColor: Color4;
  52749. /**
  52750. * Specifies whether the highlight layer is enabled or not.
  52751. */
  52752. isEnabled: boolean;
  52753. /**
  52754. * Gets the camera attached to the layer.
  52755. */
  52756. get camera(): Nullable<Camera>;
  52757. /**
  52758. * Gets the rendering group id the layer should render in.
  52759. */
  52760. get renderingGroupId(): number;
  52761. set renderingGroupId(renderingGroupId: number);
  52762. /**
  52763. * An event triggered when the effect layer has been disposed.
  52764. */
  52765. onDisposeObservable: Observable<EffectLayer>;
  52766. /**
  52767. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52768. */
  52769. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52770. /**
  52771. * An event triggered when the generated texture is being merged in the scene.
  52772. */
  52773. onBeforeComposeObservable: Observable<EffectLayer>;
  52774. /**
  52775. * An event triggered when the mesh is rendered into the effect render target.
  52776. */
  52777. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52778. /**
  52779. * An event triggered after the mesh has been rendered into the effect render target.
  52780. */
  52781. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52782. /**
  52783. * An event triggered when the generated texture has been merged in the scene.
  52784. */
  52785. onAfterComposeObservable: Observable<EffectLayer>;
  52786. /**
  52787. * An event triggered when the efffect layer changes its size.
  52788. */
  52789. onSizeChangedObservable: Observable<EffectLayer>;
  52790. /** @hidden */
  52791. static _SceneComponentInitialization: (scene: Scene) => void;
  52792. /**
  52793. * Instantiates a new effect Layer and references it in the scene.
  52794. * @param name The name of the layer
  52795. * @param scene The scene to use the layer in
  52796. */
  52797. constructor(
  52798. /** The Friendly of the effect in the scene */
  52799. name: string, scene: Scene);
  52800. /**
  52801. * Get the effect name of the layer.
  52802. * @return The effect name
  52803. */
  52804. abstract getEffectName(): string;
  52805. /**
  52806. * Checks for the readiness of the element composing the layer.
  52807. * @param subMesh the mesh to check for
  52808. * @param useInstances specify whether or not to use instances to render the mesh
  52809. * @return true if ready otherwise, false
  52810. */
  52811. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52812. /**
  52813. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52814. * @returns true if the effect requires stencil during the main canvas render pass.
  52815. */
  52816. abstract needStencil(): boolean;
  52817. /**
  52818. * Create the merge effect. This is the shader use to blit the information back
  52819. * to the main canvas at the end of the scene rendering.
  52820. * @returns The effect containing the shader used to merge the effect on the main canvas
  52821. */
  52822. protected abstract _createMergeEffect(): Effect;
  52823. /**
  52824. * Creates the render target textures and post processes used in the effect layer.
  52825. */
  52826. protected abstract _createTextureAndPostProcesses(): void;
  52827. /**
  52828. * Implementation specific of rendering the generating effect on the main canvas.
  52829. * @param effect The effect used to render through
  52830. */
  52831. protected abstract _internalRender(effect: Effect): void;
  52832. /**
  52833. * Sets the required values for both the emissive texture and and the main color.
  52834. */
  52835. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52836. /**
  52837. * Free any resources and references associated to a mesh.
  52838. * Internal use
  52839. * @param mesh The mesh to free.
  52840. */
  52841. abstract _disposeMesh(mesh: Mesh): void;
  52842. /**
  52843. * Serializes this layer (Glow or Highlight for example)
  52844. * @returns a serialized layer object
  52845. */
  52846. abstract serialize?(): any;
  52847. /**
  52848. * Initializes the effect layer with the required options.
  52849. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52850. */
  52851. protected _init(options: Partial<IEffectLayerOptions>): void;
  52852. /**
  52853. * Generates the index buffer of the full screen quad blending to the main canvas.
  52854. */
  52855. private _generateIndexBuffer;
  52856. /**
  52857. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52858. */
  52859. private _generateVertexBuffer;
  52860. /**
  52861. * Sets the main texture desired size which is the closest power of two
  52862. * of the engine canvas size.
  52863. */
  52864. private _setMainTextureSize;
  52865. /**
  52866. * Creates the main texture for the effect layer.
  52867. */
  52868. protected _createMainTexture(): void;
  52869. /**
  52870. * Adds specific effects defines.
  52871. * @param defines The defines to add specifics to.
  52872. */
  52873. protected _addCustomEffectDefines(defines: string[]): void;
  52874. /**
  52875. * Checks for the readiness of the element composing the layer.
  52876. * @param subMesh the mesh to check for
  52877. * @param useInstances specify whether or not to use instances to render the mesh
  52878. * @param emissiveTexture the associated emissive texture used to generate the glow
  52879. * @return true if ready otherwise, false
  52880. */
  52881. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52882. /**
  52883. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52884. */
  52885. render(): void;
  52886. /**
  52887. * Determine if a given mesh will be used in the current effect.
  52888. * @param mesh mesh to test
  52889. * @returns true if the mesh will be used
  52890. */
  52891. hasMesh(mesh: AbstractMesh): boolean;
  52892. /**
  52893. * Returns true if the layer contains information to display, otherwise false.
  52894. * @returns true if the glow layer should be rendered
  52895. */
  52896. shouldRender(): boolean;
  52897. /**
  52898. * Returns true if the mesh should render, otherwise false.
  52899. * @param mesh The mesh to render
  52900. * @returns true if it should render otherwise false
  52901. */
  52902. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52903. /**
  52904. * Returns true if the mesh can be rendered, otherwise false.
  52905. * @param mesh The mesh to render
  52906. * @param material The material used on the mesh
  52907. * @returns true if it can be rendered otherwise false
  52908. */
  52909. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52910. /**
  52911. * Returns true if the mesh should render, otherwise false.
  52912. * @param mesh The mesh to render
  52913. * @returns true if it should render otherwise false
  52914. */
  52915. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52916. /**
  52917. * Renders the submesh passed in parameter to the generation map.
  52918. */
  52919. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52920. /**
  52921. * Defines whether the current material of the mesh should be use to render the effect.
  52922. * @param mesh defines the current mesh to render
  52923. */
  52924. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52925. /**
  52926. * Rebuild the required buffers.
  52927. * @hidden Internal use only.
  52928. */
  52929. _rebuild(): void;
  52930. /**
  52931. * Dispose only the render target textures and post process.
  52932. */
  52933. private _disposeTextureAndPostProcesses;
  52934. /**
  52935. * Dispose the highlight layer and free resources.
  52936. */
  52937. dispose(): void;
  52938. /**
  52939. * Gets the class name of the effect layer
  52940. * @returns the string with the class name of the effect layer
  52941. */
  52942. getClassName(): string;
  52943. /**
  52944. * Creates an effect layer from parsed effect layer data
  52945. * @param parsedEffectLayer defines effect layer data
  52946. * @param scene defines the current scene
  52947. * @param rootUrl defines the root URL containing the effect layer information
  52948. * @returns a parsed effect Layer
  52949. */
  52950. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52951. }
  52952. }
  52953. declare module BABYLON {
  52954. interface AbstractScene {
  52955. /**
  52956. * The list of effect layers (highlights/glow) added to the scene
  52957. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52958. * @see http://doc.babylonjs.com/how_to/glow_layer
  52959. */
  52960. effectLayers: Array<EffectLayer>;
  52961. /**
  52962. * Removes the given effect layer from this scene.
  52963. * @param toRemove defines the effect layer to remove
  52964. * @returns the index of the removed effect layer
  52965. */
  52966. removeEffectLayer(toRemove: EffectLayer): number;
  52967. /**
  52968. * Adds the given effect layer to this scene
  52969. * @param newEffectLayer defines the effect layer to add
  52970. */
  52971. addEffectLayer(newEffectLayer: EffectLayer): void;
  52972. }
  52973. /**
  52974. * Defines the layer scene component responsible to manage any effect layers
  52975. * in a given scene.
  52976. */
  52977. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52978. /**
  52979. * The component name helpfull to identify the component in the list of scene components.
  52980. */
  52981. readonly name: string;
  52982. /**
  52983. * The scene the component belongs to.
  52984. */
  52985. scene: Scene;
  52986. private _engine;
  52987. private _renderEffects;
  52988. private _needStencil;
  52989. private _previousStencilState;
  52990. /**
  52991. * Creates a new instance of the component for the given scene
  52992. * @param scene Defines the scene to register the component in
  52993. */
  52994. constructor(scene: Scene);
  52995. /**
  52996. * Registers the component in a given scene
  52997. */
  52998. register(): void;
  52999. /**
  53000. * Rebuilds the elements related to this component in case of
  53001. * context lost for instance.
  53002. */
  53003. rebuild(): void;
  53004. /**
  53005. * Serializes the component data to the specified json object
  53006. * @param serializationObject The object to serialize to
  53007. */
  53008. serialize(serializationObject: any): void;
  53009. /**
  53010. * Adds all the elements from the container to the scene
  53011. * @param container the container holding the elements
  53012. */
  53013. addFromContainer(container: AbstractScene): void;
  53014. /**
  53015. * Removes all the elements in the container from the scene
  53016. * @param container contains the elements to remove
  53017. * @param dispose if the removed element should be disposed (default: false)
  53018. */
  53019. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53020. /**
  53021. * Disposes the component and the associated ressources.
  53022. */
  53023. dispose(): void;
  53024. private _isReadyForMesh;
  53025. private _renderMainTexture;
  53026. private _setStencil;
  53027. private _setStencilBack;
  53028. private _draw;
  53029. private _drawCamera;
  53030. private _drawRenderingGroup;
  53031. }
  53032. }
  53033. declare module BABYLON {
  53034. /** @hidden */
  53035. export var glowMapMergePixelShader: {
  53036. name: string;
  53037. shader: string;
  53038. };
  53039. }
  53040. declare module BABYLON {
  53041. /** @hidden */
  53042. export var glowMapMergeVertexShader: {
  53043. name: string;
  53044. shader: string;
  53045. };
  53046. }
  53047. declare module BABYLON {
  53048. interface AbstractScene {
  53049. /**
  53050. * Return a the first highlight layer of the scene with a given name.
  53051. * @param name The name of the highlight layer to look for.
  53052. * @return The highlight layer if found otherwise null.
  53053. */
  53054. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53055. }
  53056. /**
  53057. * Glow layer options. This helps customizing the behaviour
  53058. * of the glow layer.
  53059. */
  53060. export interface IGlowLayerOptions {
  53061. /**
  53062. * Multiplication factor apply to the canvas size to compute the render target size
  53063. * used to generated the glowing objects (the smaller the faster).
  53064. */
  53065. mainTextureRatio: number;
  53066. /**
  53067. * Enforces a fixed size texture to ensure resize independant blur.
  53068. */
  53069. mainTextureFixedSize?: number;
  53070. /**
  53071. * How big is the kernel of the blur texture.
  53072. */
  53073. blurKernelSize: number;
  53074. /**
  53075. * The camera attached to the layer.
  53076. */
  53077. camera: Nullable<Camera>;
  53078. /**
  53079. * Enable MSAA by chosing the number of samples.
  53080. */
  53081. mainTextureSamples?: number;
  53082. /**
  53083. * The rendering group to draw the layer in.
  53084. */
  53085. renderingGroupId: number;
  53086. }
  53087. /**
  53088. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53089. *
  53090. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53091. *
  53092. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53093. */
  53094. export class GlowLayer extends EffectLayer {
  53095. /**
  53096. * Effect Name of the layer.
  53097. */
  53098. static readonly EffectName: string;
  53099. /**
  53100. * The default blur kernel size used for the glow.
  53101. */
  53102. static DefaultBlurKernelSize: number;
  53103. /**
  53104. * The default texture size ratio used for the glow.
  53105. */
  53106. static DefaultTextureRatio: number;
  53107. /**
  53108. * Sets the kernel size of the blur.
  53109. */
  53110. set blurKernelSize(value: number);
  53111. /**
  53112. * Gets the kernel size of the blur.
  53113. */
  53114. get blurKernelSize(): number;
  53115. /**
  53116. * Sets the glow intensity.
  53117. */
  53118. set intensity(value: number);
  53119. /**
  53120. * Gets the glow intensity.
  53121. */
  53122. get intensity(): number;
  53123. private _options;
  53124. private _intensity;
  53125. private _horizontalBlurPostprocess1;
  53126. private _verticalBlurPostprocess1;
  53127. private _horizontalBlurPostprocess2;
  53128. private _verticalBlurPostprocess2;
  53129. private _blurTexture1;
  53130. private _blurTexture2;
  53131. private _postProcesses1;
  53132. private _postProcesses2;
  53133. private _includedOnlyMeshes;
  53134. private _excludedMeshes;
  53135. private _meshesUsingTheirOwnMaterials;
  53136. /**
  53137. * Callback used to let the user override the color selection on a per mesh basis
  53138. */
  53139. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53140. /**
  53141. * Callback used to let the user override the texture selection on a per mesh basis
  53142. */
  53143. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53144. /**
  53145. * Instantiates a new glow Layer and references it to the scene.
  53146. * @param name The name of the layer
  53147. * @param scene The scene to use the layer in
  53148. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53149. */
  53150. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53151. /**
  53152. * Get the effect name of the layer.
  53153. * @return The effect name
  53154. */
  53155. getEffectName(): string;
  53156. /**
  53157. * Create the merge effect. This is the shader use to blit the information back
  53158. * to the main canvas at the end of the scene rendering.
  53159. */
  53160. protected _createMergeEffect(): Effect;
  53161. /**
  53162. * Creates the render target textures and post processes used in the glow layer.
  53163. */
  53164. protected _createTextureAndPostProcesses(): void;
  53165. /**
  53166. * Checks for the readiness of the element composing the layer.
  53167. * @param subMesh the mesh to check for
  53168. * @param useInstances specify wether or not to use instances to render the mesh
  53169. * @param emissiveTexture the associated emissive texture used to generate the glow
  53170. * @return true if ready otherwise, false
  53171. */
  53172. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53173. /**
  53174. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53175. */
  53176. needStencil(): boolean;
  53177. /**
  53178. * Returns true if the mesh can be rendered, otherwise false.
  53179. * @param mesh The mesh to render
  53180. * @param material The material used on the mesh
  53181. * @returns true if it can be rendered otherwise false
  53182. */
  53183. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53184. /**
  53185. * Implementation specific of rendering the generating effect on the main canvas.
  53186. * @param effect The effect used to render through
  53187. */
  53188. protected _internalRender(effect: Effect): void;
  53189. /**
  53190. * Sets the required values for both the emissive texture and and the main color.
  53191. */
  53192. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53193. /**
  53194. * Returns true if the mesh should render, otherwise false.
  53195. * @param mesh The mesh to render
  53196. * @returns true if it should render otherwise false
  53197. */
  53198. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53199. /**
  53200. * Adds specific effects defines.
  53201. * @param defines The defines to add specifics to.
  53202. */
  53203. protected _addCustomEffectDefines(defines: string[]): void;
  53204. /**
  53205. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53206. * @param mesh The mesh to exclude from the glow layer
  53207. */
  53208. addExcludedMesh(mesh: Mesh): void;
  53209. /**
  53210. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53211. * @param mesh The mesh to remove
  53212. */
  53213. removeExcludedMesh(mesh: Mesh): void;
  53214. /**
  53215. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53216. * @param mesh The mesh to include in the glow layer
  53217. */
  53218. addIncludedOnlyMesh(mesh: Mesh): void;
  53219. /**
  53220. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53221. * @param mesh The mesh to remove
  53222. */
  53223. removeIncludedOnlyMesh(mesh: Mesh): void;
  53224. /**
  53225. * Determine if a given mesh will be used in the glow layer
  53226. * @param mesh The mesh to test
  53227. * @returns true if the mesh will be highlighted by the current glow layer
  53228. */
  53229. hasMesh(mesh: AbstractMesh): boolean;
  53230. /**
  53231. * Defines whether the current material of the mesh should be use to render the effect.
  53232. * @param mesh defines the current mesh to render
  53233. */
  53234. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53235. /**
  53236. * Add a mesh to be rendered through its own material and not with emissive only.
  53237. * @param mesh The mesh for which we need to use its material
  53238. */
  53239. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53240. /**
  53241. * Remove a mesh from being rendered through its own material and not with emissive only.
  53242. * @param mesh The mesh for which we need to not use its material
  53243. */
  53244. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53245. /**
  53246. * Free any resources and references associated to a mesh.
  53247. * Internal use
  53248. * @param mesh The mesh to free.
  53249. * @hidden
  53250. */
  53251. _disposeMesh(mesh: Mesh): void;
  53252. /**
  53253. * Gets the class name of the effect layer
  53254. * @returns the string with the class name of the effect layer
  53255. */
  53256. getClassName(): string;
  53257. /**
  53258. * Serializes this glow layer
  53259. * @returns a serialized glow layer object
  53260. */
  53261. serialize(): any;
  53262. /**
  53263. * Creates a Glow Layer from parsed glow layer data
  53264. * @param parsedGlowLayer defines glow layer data
  53265. * @param scene defines the current scene
  53266. * @param rootUrl defines the root URL containing the glow layer information
  53267. * @returns a parsed Glow Layer
  53268. */
  53269. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53270. }
  53271. }
  53272. declare module BABYLON {
  53273. /** @hidden */
  53274. export var glowBlurPostProcessPixelShader: {
  53275. name: string;
  53276. shader: string;
  53277. };
  53278. }
  53279. declare module BABYLON {
  53280. interface AbstractScene {
  53281. /**
  53282. * Return a the first highlight layer of the scene with a given name.
  53283. * @param name The name of the highlight layer to look for.
  53284. * @return The highlight layer if found otherwise null.
  53285. */
  53286. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53287. }
  53288. /**
  53289. * Highlight layer options. This helps customizing the behaviour
  53290. * of the highlight layer.
  53291. */
  53292. export interface IHighlightLayerOptions {
  53293. /**
  53294. * Multiplication factor apply to the canvas size to compute the render target size
  53295. * used to generated the glowing objects (the smaller the faster).
  53296. */
  53297. mainTextureRatio: number;
  53298. /**
  53299. * Enforces a fixed size texture to ensure resize independant blur.
  53300. */
  53301. mainTextureFixedSize?: number;
  53302. /**
  53303. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53304. * of the picture to blur (the smaller the faster).
  53305. */
  53306. blurTextureSizeRatio: number;
  53307. /**
  53308. * How big in texel of the blur texture is the vertical blur.
  53309. */
  53310. blurVerticalSize: number;
  53311. /**
  53312. * How big in texel of the blur texture is the horizontal blur.
  53313. */
  53314. blurHorizontalSize: number;
  53315. /**
  53316. * Alpha blending mode used to apply the blur. Default is combine.
  53317. */
  53318. alphaBlendingMode: number;
  53319. /**
  53320. * The camera attached to the layer.
  53321. */
  53322. camera: Nullable<Camera>;
  53323. /**
  53324. * Should we display highlight as a solid stroke?
  53325. */
  53326. isStroke?: boolean;
  53327. /**
  53328. * The rendering group to draw the layer in.
  53329. */
  53330. renderingGroupId: number;
  53331. }
  53332. /**
  53333. * The highlight layer Helps adding a glow effect around a mesh.
  53334. *
  53335. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53336. * glowy meshes to your scene.
  53337. *
  53338. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53339. */
  53340. export class HighlightLayer extends EffectLayer {
  53341. name: string;
  53342. /**
  53343. * Effect Name of the highlight layer.
  53344. */
  53345. static readonly EffectName: string;
  53346. /**
  53347. * The neutral color used during the preparation of the glow effect.
  53348. * This is black by default as the blend operation is a blend operation.
  53349. */
  53350. static NeutralColor: Color4;
  53351. /**
  53352. * Stencil value used for glowing meshes.
  53353. */
  53354. static GlowingMeshStencilReference: number;
  53355. /**
  53356. * Stencil value used for the other meshes in the scene.
  53357. */
  53358. static NormalMeshStencilReference: number;
  53359. /**
  53360. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53361. */
  53362. innerGlow: boolean;
  53363. /**
  53364. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53365. */
  53366. outerGlow: boolean;
  53367. /**
  53368. * Specifies the horizontal size of the blur.
  53369. */
  53370. set blurHorizontalSize(value: number);
  53371. /**
  53372. * Specifies the vertical size of the blur.
  53373. */
  53374. set blurVerticalSize(value: number);
  53375. /**
  53376. * Gets the horizontal size of the blur.
  53377. */
  53378. get blurHorizontalSize(): number;
  53379. /**
  53380. * Gets the vertical size of the blur.
  53381. */
  53382. get blurVerticalSize(): number;
  53383. /**
  53384. * An event triggered when the highlight layer is being blurred.
  53385. */
  53386. onBeforeBlurObservable: Observable<HighlightLayer>;
  53387. /**
  53388. * An event triggered when the highlight layer has been blurred.
  53389. */
  53390. onAfterBlurObservable: Observable<HighlightLayer>;
  53391. private _instanceGlowingMeshStencilReference;
  53392. private _options;
  53393. private _downSamplePostprocess;
  53394. private _horizontalBlurPostprocess;
  53395. private _verticalBlurPostprocess;
  53396. private _blurTexture;
  53397. private _meshes;
  53398. private _excludedMeshes;
  53399. /**
  53400. * Instantiates a new highlight Layer and references it to the scene..
  53401. * @param name The name of the layer
  53402. * @param scene The scene to use the layer in
  53403. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53404. */
  53405. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53406. /**
  53407. * Get the effect name of the layer.
  53408. * @return The effect name
  53409. */
  53410. getEffectName(): string;
  53411. /**
  53412. * Create the merge effect. This is the shader use to blit the information back
  53413. * to the main canvas at the end of the scene rendering.
  53414. */
  53415. protected _createMergeEffect(): Effect;
  53416. /**
  53417. * Creates the render target textures and post processes used in the highlight layer.
  53418. */
  53419. protected _createTextureAndPostProcesses(): void;
  53420. /**
  53421. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53422. */
  53423. needStencil(): boolean;
  53424. /**
  53425. * Checks for the readiness of the element composing the layer.
  53426. * @param subMesh the mesh to check for
  53427. * @param useInstances specify wether or not to use instances to render the mesh
  53428. * @param emissiveTexture the associated emissive texture used to generate the glow
  53429. * @return true if ready otherwise, false
  53430. */
  53431. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53432. /**
  53433. * Implementation specific of rendering the generating effect on the main canvas.
  53434. * @param effect The effect used to render through
  53435. */
  53436. protected _internalRender(effect: Effect): void;
  53437. /**
  53438. * Returns true if the layer contains information to display, otherwise false.
  53439. */
  53440. shouldRender(): boolean;
  53441. /**
  53442. * Returns true if the mesh should render, otherwise false.
  53443. * @param mesh The mesh to render
  53444. * @returns true if it should render otherwise false
  53445. */
  53446. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53447. /**
  53448. * Sets the required values for both the emissive texture and and the main color.
  53449. */
  53450. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53451. /**
  53452. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53453. * @param mesh The mesh to exclude from the highlight layer
  53454. */
  53455. addExcludedMesh(mesh: Mesh): void;
  53456. /**
  53457. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53458. * @param mesh The mesh to highlight
  53459. */
  53460. removeExcludedMesh(mesh: Mesh): void;
  53461. /**
  53462. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53463. * @param mesh mesh to test
  53464. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53465. */
  53466. hasMesh(mesh: AbstractMesh): boolean;
  53467. /**
  53468. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53469. * @param mesh The mesh to highlight
  53470. * @param color The color of the highlight
  53471. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53472. */
  53473. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53474. /**
  53475. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53476. * @param mesh The mesh to highlight
  53477. */
  53478. removeMesh(mesh: Mesh): void;
  53479. /**
  53480. * Remove all the meshes currently referenced in the highlight layer
  53481. */
  53482. removeAllMeshes(): void;
  53483. /**
  53484. * Force the stencil to the normal expected value for none glowing parts
  53485. */
  53486. private _defaultStencilReference;
  53487. /**
  53488. * Free any resources and references associated to a mesh.
  53489. * Internal use
  53490. * @param mesh The mesh to free.
  53491. * @hidden
  53492. */
  53493. _disposeMesh(mesh: Mesh): void;
  53494. /**
  53495. * Dispose the highlight layer and free resources.
  53496. */
  53497. dispose(): void;
  53498. /**
  53499. * Gets the class name of the effect layer
  53500. * @returns the string with the class name of the effect layer
  53501. */
  53502. getClassName(): string;
  53503. /**
  53504. * Serializes this Highlight layer
  53505. * @returns a serialized Highlight layer object
  53506. */
  53507. serialize(): any;
  53508. /**
  53509. * Creates a Highlight layer from parsed Highlight layer data
  53510. * @param parsedHightlightLayer defines the Highlight layer data
  53511. * @param scene defines the current scene
  53512. * @param rootUrl defines the root URL containing the Highlight layer information
  53513. * @returns a parsed Highlight layer
  53514. */
  53515. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53516. }
  53517. }
  53518. declare module BABYLON {
  53519. interface AbstractScene {
  53520. /**
  53521. * The list of layers (background and foreground) of the scene
  53522. */
  53523. layers: Array<Layer>;
  53524. }
  53525. /**
  53526. * Defines the layer scene component responsible to manage any layers
  53527. * in a given scene.
  53528. */
  53529. export class LayerSceneComponent implements ISceneComponent {
  53530. /**
  53531. * The component name helpfull to identify the component in the list of scene components.
  53532. */
  53533. readonly name: string;
  53534. /**
  53535. * The scene the component belongs to.
  53536. */
  53537. scene: Scene;
  53538. private _engine;
  53539. /**
  53540. * Creates a new instance of the component for the given scene
  53541. * @param scene Defines the scene to register the component in
  53542. */
  53543. constructor(scene: Scene);
  53544. /**
  53545. * Registers the component in a given scene
  53546. */
  53547. register(): void;
  53548. /**
  53549. * Rebuilds the elements related to this component in case of
  53550. * context lost for instance.
  53551. */
  53552. rebuild(): void;
  53553. /**
  53554. * Disposes the component and the associated ressources.
  53555. */
  53556. dispose(): void;
  53557. private _draw;
  53558. private _drawCameraPredicate;
  53559. private _drawCameraBackground;
  53560. private _drawCameraForeground;
  53561. private _drawRenderTargetPredicate;
  53562. private _drawRenderTargetBackground;
  53563. private _drawRenderTargetForeground;
  53564. /**
  53565. * Adds all the elements from the container to the scene
  53566. * @param container the container holding the elements
  53567. */
  53568. addFromContainer(container: AbstractScene): void;
  53569. /**
  53570. * Removes all the elements in the container from the scene
  53571. * @param container contains the elements to remove
  53572. * @param dispose if the removed element should be disposed (default: false)
  53573. */
  53574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53575. }
  53576. }
  53577. declare module BABYLON {
  53578. /** @hidden */
  53579. export var layerPixelShader: {
  53580. name: string;
  53581. shader: string;
  53582. };
  53583. }
  53584. declare module BABYLON {
  53585. /** @hidden */
  53586. export var layerVertexShader: {
  53587. name: string;
  53588. shader: string;
  53589. };
  53590. }
  53591. declare module BABYLON {
  53592. /**
  53593. * This represents a full screen 2d layer.
  53594. * This can be useful to display a picture in the background of your scene for instance.
  53595. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53596. */
  53597. export class Layer {
  53598. /**
  53599. * Define the name of the layer.
  53600. */
  53601. name: string;
  53602. /**
  53603. * Define the texture the layer should display.
  53604. */
  53605. texture: Nullable<Texture>;
  53606. /**
  53607. * Is the layer in background or foreground.
  53608. */
  53609. isBackground: boolean;
  53610. /**
  53611. * Define the color of the layer (instead of texture).
  53612. */
  53613. color: Color4;
  53614. /**
  53615. * Define the scale of the layer in order to zoom in out of the texture.
  53616. */
  53617. scale: Vector2;
  53618. /**
  53619. * Define an offset for the layer in order to shift the texture.
  53620. */
  53621. offset: Vector2;
  53622. /**
  53623. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53624. */
  53625. alphaBlendingMode: number;
  53626. /**
  53627. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53628. * Alpha test will not mix with the background color in case of transparency.
  53629. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53630. */
  53631. alphaTest: boolean;
  53632. /**
  53633. * Define a mask to restrict the layer to only some of the scene cameras.
  53634. */
  53635. layerMask: number;
  53636. /**
  53637. * Define the list of render target the layer is visible into.
  53638. */
  53639. renderTargetTextures: RenderTargetTexture[];
  53640. /**
  53641. * Define if the layer is only used in renderTarget or if it also
  53642. * renders in the main frame buffer of the canvas.
  53643. */
  53644. renderOnlyInRenderTargetTextures: boolean;
  53645. private _scene;
  53646. private _vertexBuffers;
  53647. private _indexBuffer;
  53648. private _effect;
  53649. private _previousDefines;
  53650. /**
  53651. * An event triggered when the layer is disposed.
  53652. */
  53653. onDisposeObservable: Observable<Layer>;
  53654. private _onDisposeObserver;
  53655. /**
  53656. * Back compatibility with callback before the onDisposeObservable existed.
  53657. * The set callback will be triggered when the layer has been disposed.
  53658. */
  53659. set onDispose(callback: () => void);
  53660. /**
  53661. * An event triggered before rendering the scene
  53662. */
  53663. onBeforeRenderObservable: Observable<Layer>;
  53664. private _onBeforeRenderObserver;
  53665. /**
  53666. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53667. * The set callback will be triggered just before rendering the layer.
  53668. */
  53669. set onBeforeRender(callback: () => void);
  53670. /**
  53671. * An event triggered after rendering the scene
  53672. */
  53673. onAfterRenderObservable: Observable<Layer>;
  53674. private _onAfterRenderObserver;
  53675. /**
  53676. * Back compatibility with callback before the onAfterRenderObservable existed.
  53677. * The set callback will be triggered just after rendering the layer.
  53678. */
  53679. set onAfterRender(callback: () => void);
  53680. /**
  53681. * Instantiates a new layer.
  53682. * This represents a full screen 2d layer.
  53683. * This can be useful to display a picture in the background of your scene for instance.
  53684. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53685. * @param name Define the name of the layer in the scene
  53686. * @param imgUrl Define the url of the texture to display in the layer
  53687. * @param scene Define the scene the layer belongs to
  53688. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53689. * @param color Defines a color for the layer
  53690. */
  53691. constructor(
  53692. /**
  53693. * Define the name of the layer.
  53694. */
  53695. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53696. private _createIndexBuffer;
  53697. /** @hidden */
  53698. _rebuild(): void;
  53699. /**
  53700. * Renders the layer in the scene.
  53701. */
  53702. render(): void;
  53703. /**
  53704. * Disposes and releases the associated ressources.
  53705. */
  53706. dispose(): void;
  53707. }
  53708. }
  53709. declare module BABYLON {
  53710. /** @hidden */
  53711. export var lensFlarePixelShader: {
  53712. name: string;
  53713. shader: string;
  53714. };
  53715. }
  53716. declare module BABYLON {
  53717. /** @hidden */
  53718. export var lensFlareVertexShader: {
  53719. name: string;
  53720. shader: string;
  53721. };
  53722. }
  53723. declare module BABYLON {
  53724. /**
  53725. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53726. * It is usually composed of several `lensFlare`.
  53727. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53728. */
  53729. export class LensFlareSystem {
  53730. /**
  53731. * Define the name of the lens flare system
  53732. */
  53733. name: string;
  53734. /**
  53735. * List of lens flares used in this system.
  53736. */
  53737. lensFlares: LensFlare[];
  53738. /**
  53739. * Define a limit from the border the lens flare can be visible.
  53740. */
  53741. borderLimit: number;
  53742. /**
  53743. * Define a viewport border we do not want to see the lens flare in.
  53744. */
  53745. viewportBorder: number;
  53746. /**
  53747. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53748. */
  53749. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53750. /**
  53751. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53752. */
  53753. layerMask: number;
  53754. /**
  53755. * Define the id of the lens flare system in the scene.
  53756. * (equal to name by default)
  53757. */
  53758. id: string;
  53759. private _scene;
  53760. private _emitter;
  53761. private _vertexBuffers;
  53762. private _indexBuffer;
  53763. private _effect;
  53764. private _positionX;
  53765. private _positionY;
  53766. private _isEnabled;
  53767. /** @hidden */
  53768. static _SceneComponentInitialization: (scene: Scene) => void;
  53769. /**
  53770. * Instantiates a lens flare system.
  53771. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53772. * It is usually composed of several `lensFlare`.
  53773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53774. * @param name Define the name of the lens flare system in the scene
  53775. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53776. * @param scene Define the scene the lens flare system belongs to
  53777. */
  53778. constructor(
  53779. /**
  53780. * Define the name of the lens flare system
  53781. */
  53782. name: string, emitter: any, scene: Scene);
  53783. /**
  53784. * Define if the lens flare system is enabled.
  53785. */
  53786. get isEnabled(): boolean;
  53787. set isEnabled(value: boolean);
  53788. /**
  53789. * Get the scene the effects belongs to.
  53790. * @returns the scene holding the lens flare system
  53791. */
  53792. getScene(): Scene;
  53793. /**
  53794. * Get the emitter of the lens flare system.
  53795. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53796. * @returns the emitter of the lens flare system
  53797. */
  53798. getEmitter(): any;
  53799. /**
  53800. * Set the emitter of the lens flare system.
  53801. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53802. * @param newEmitter Define the new emitter of the system
  53803. */
  53804. setEmitter(newEmitter: any): void;
  53805. /**
  53806. * Get the lens flare system emitter position.
  53807. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53808. * @returns the position
  53809. */
  53810. getEmitterPosition(): Vector3;
  53811. /**
  53812. * @hidden
  53813. */
  53814. computeEffectivePosition(globalViewport: Viewport): boolean;
  53815. /** @hidden */
  53816. _isVisible(): boolean;
  53817. /**
  53818. * @hidden
  53819. */
  53820. render(): boolean;
  53821. /**
  53822. * Dispose and release the lens flare with its associated resources.
  53823. */
  53824. dispose(): void;
  53825. /**
  53826. * Parse a lens flare system from a JSON repressentation
  53827. * @param parsedLensFlareSystem Define the JSON to parse
  53828. * @param scene Define the scene the parsed system should be instantiated in
  53829. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53830. * @returns the parsed system
  53831. */
  53832. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53833. /**
  53834. * Serialize the current Lens Flare System into a JSON representation.
  53835. * @returns the serialized JSON
  53836. */
  53837. serialize(): any;
  53838. }
  53839. }
  53840. declare module BABYLON {
  53841. /**
  53842. * This represents one of the lens effect in a `lensFlareSystem`.
  53843. * It controls one of the indiviual texture used in the effect.
  53844. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53845. */
  53846. export class LensFlare {
  53847. /**
  53848. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53849. */
  53850. size: number;
  53851. /**
  53852. * 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.
  53853. */
  53854. position: number;
  53855. /**
  53856. * Define the lens color.
  53857. */
  53858. color: Color3;
  53859. /**
  53860. * Define the lens texture.
  53861. */
  53862. texture: Nullable<Texture>;
  53863. /**
  53864. * Define the alpha mode to render this particular lens.
  53865. */
  53866. alphaMode: number;
  53867. private _system;
  53868. /**
  53869. * Creates a new Lens Flare.
  53870. * This represents one of the lens effect in a `lensFlareSystem`.
  53871. * It controls one of the indiviual texture used in the effect.
  53872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53873. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53874. * @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.
  53875. * @param color Define the lens color
  53876. * @param imgUrl Define the lens texture url
  53877. * @param system Define the `lensFlareSystem` this flare is part of
  53878. * @returns The newly created Lens Flare
  53879. */
  53880. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53881. /**
  53882. * Instantiates a new Lens Flare.
  53883. * This represents one of the lens effect in a `lensFlareSystem`.
  53884. * It controls one of the indiviual texture used in the effect.
  53885. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53886. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53887. * @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.
  53888. * @param color Define the lens color
  53889. * @param imgUrl Define the lens texture url
  53890. * @param system Define the `lensFlareSystem` this flare is part of
  53891. */
  53892. constructor(
  53893. /**
  53894. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53895. */
  53896. size: number,
  53897. /**
  53898. * 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.
  53899. */
  53900. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53901. /**
  53902. * Dispose and release the lens flare with its associated resources.
  53903. */
  53904. dispose(): void;
  53905. }
  53906. }
  53907. declare module BABYLON {
  53908. interface AbstractScene {
  53909. /**
  53910. * The list of lens flare system added to the scene
  53911. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53912. */
  53913. lensFlareSystems: Array<LensFlareSystem>;
  53914. /**
  53915. * Removes the given lens flare system from this scene.
  53916. * @param toRemove The lens flare system to remove
  53917. * @returns The index of the removed lens flare system
  53918. */
  53919. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53920. /**
  53921. * Adds the given lens flare system to this scene
  53922. * @param newLensFlareSystem The lens flare system to add
  53923. */
  53924. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53925. /**
  53926. * Gets a lens flare system using its name
  53927. * @param name defines the name to look for
  53928. * @returns the lens flare system or null if not found
  53929. */
  53930. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53931. /**
  53932. * Gets a lens flare system using its id
  53933. * @param id defines the id to look for
  53934. * @returns the lens flare system or null if not found
  53935. */
  53936. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53937. }
  53938. /**
  53939. * Defines the lens flare scene component responsible to manage any lens flares
  53940. * in a given scene.
  53941. */
  53942. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53943. /**
  53944. * The component name helpfull to identify the component in the list of scene components.
  53945. */
  53946. readonly name: string;
  53947. /**
  53948. * The scene the component belongs to.
  53949. */
  53950. scene: Scene;
  53951. /**
  53952. * Creates a new instance of the component for the given scene
  53953. * @param scene Defines the scene to register the component in
  53954. */
  53955. constructor(scene: Scene);
  53956. /**
  53957. * Registers the component in a given scene
  53958. */
  53959. register(): void;
  53960. /**
  53961. * Rebuilds the elements related to this component in case of
  53962. * context lost for instance.
  53963. */
  53964. rebuild(): void;
  53965. /**
  53966. * Adds all the elements from the container to the scene
  53967. * @param container the container holding the elements
  53968. */
  53969. addFromContainer(container: AbstractScene): void;
  53970. /**
  53971. * Removes all the elements in the container from the scene
  53972. * @param container contains the elements to remove
  53973. * @param dispose if the removed element should be disposed (default: false)
  53974. */
  53975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53976. /**
  53977. * Serializes the component data to the specified json object
  53978. * @param serializationObject The object to serialize to
  53979. */
  53980. serialize(serializationObject: any): void;
  53981. /**
  53982. * Disposes the component and the associated ressources.
  53983. */
  53984. dispose(): void;
  53985. private _draw;
  53986. }
  53987. }
  53988. declare module BABYLON {
  53989. /** @hidden */
  53990. export var depthPixelShader: {
  53991. name: string;
  53992. shader: string;
  53993. };
  53994. }
  53995. declare module BABYLON {
  53996. /** @hidden */
  53997. export var depthVertexShader: {
  53998. name: string;
  53999. shader: string;
  54000. };
  54001. }
  54002. declare module BABYLON {
  54003. /**
  54004. * This represents a depth renderer in Babylon.
  54005. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54006. */
  54007. export class DepthRenderer {
  54008. private _scene;
  54009. private _depthMap;
  54010. private _effect;
  54011. private readonly _storeNonLinearDepth;
  54012. private readonly _clearColor;
  54013. /** Get if the depth renderer is using packed depth or not */
  54014. readonly isPacked: boolean;
  54015. private _cachedDefines;
  54016. private _camera;
  54017. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54018. enabled: boolean;
  54019. /**
  54020. * Specifiess that the depth renderer will only be used within
  54021. * the camera it is created for.
  54022. * This can help forcing its rendering during the camera processing.
  54023. */
  54024. useOnlyInActiveCamera: boolean;
  54025. /** @hidden */
  54026. static _SceneComponentInitialization: (scene: Scene) => void;
  54027. /**
  54028. * Instantiates a depth renderer
  54029. * @param scene The scene the renderer belongs to
  54030. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54031. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54032. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54033. */
  54034. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54035. /**
  54036. * Creates the depth rendering effect and checks if the effect is ready.
  54037. * @param subMesh The submesh to be used to render the depth map of
  54038. * @param useInstances If multiple world instances should be used
  54039. * @returns if the depth renderer is ready to render the depth map
  54040. */
  54041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54042. /**
  54043. * Gets the texture which the depth map will be written to.
  54044. * @returns The depth map texture
  54045. */
  54046. getDepthMap(): RenderTargetTexture;
  54047. /**
  54048. * Disposes of the depth renderer.
  54049. */
  54050. dispose(): void;
  54051. }
  54052. }
  54053. declare module BABYLON {
  54054. /** @hidden */
  54055. export var minmaxReduxPixelShader: {
  54056. name: string;
  54057. shader: string;
  54058. };
  54059. }
  54060. declare module BABYLON {
  54061. /**
  54062. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54063. * and maximum values from all values of the texture.
  54064. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54065. * The source values are read from the red channel of the texture.
  54066. */
  54067. export class MinMaxReducer {
  54068. /**
  54069. * Observable triggered when the computation has been performed
  54070. */
  54071. onAfterReductionPerformed: Observable<{
  54072. min: number;
  54073. max: number;
  54074. }>;
  54075. protected _camera: Camera;
  54076. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54077. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54078. protected _postProcessManager: PostProcessManager;
  54079. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54080. protected _forceFullscreenViewport: boolean;
  54081. /**
  54082. * Creates a min/max reducer
  54083. * @param camera The camera to use for the post processes
  54084. */
  54085. constructor(camera: Camera);
  54086. /**
  54087. * Gets the texture used to read the values from.
  54088. */
  54089. get sourceTexture(): Nullable<RenderTargetTexture>;
  54090. /**
  54091. * Sets the source texture to read the values from.
  54092. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54093. * because in such textures '1' value must not be taken into account to compute the maximum
  54094. * as this value is used to clear the texture.
  54095. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54096. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54097. * @param depthRedux Indicates if the texture is a depth texture or not
  54098. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54099. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54100. */
  54101. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54102. /**
  54103. * Defines the refresh rate of the computation.
  54104. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54105. */
  54106. get refreshRate(): number;
  54107. set refreshRate(value: number);
  54108. protected _activated: boolean;
  54109. /**
  54110. * Gets the activation status of the reducer
  54111. */
  54112. get activated(): boolean;
  54113. /**
  54114. * Activates the reduction computation.
  54115. * When activated, the observers registered in onAfterReductionPerformed are
  54116. * called after the compuation is performed
  54117. */
  54118. activate(): void;
  54119. /**
  54120. * Deactivates the reduction computation.
  54121. */
  54122. deactivate(): void;
  54123. /**
  54124. * Disposes the min/max reducer
  54125. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54126. */
  54127. dispose(disposeAll?: boolean): void;
  54128. }
  54129. }
  54130. declare module BABYLON {
  54131. /**
  54132. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54133. */
  54134. export class DepthReducer extends MinMaxReducer {
  54135. private _depthRenderer;
  54136. private _depthRendererId;
  54137. /**
  54138. * Gets the depth renderer used for the computation.
  54139. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54140. */
  54141. get depthRenderer(): Nullable<DepthRenderer>;
  54142. /**
  54143. * Creates a depth reducer
  54144. * @param camera The camera used to render the depth texture
  54145. */
  54146. constructor(camera: Camera);
  54147. /**
  54148. * Sets the depth renderer to use to generate the depth map
  54149. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54150. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54151. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54152. */
  54153. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54154. /** @hidden */
  54155. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54156. /**
  54157. * Activates the reduction computation.
  54158. * When activated, the observers registered in onAfterReductionPerformed are
  54159. * called after the compuation is performed
  54160. */
  54161. activate(): void;
  54162. /**
  54163. * Deactivates the reduction computation.
  54164. */
  54165. deactivate(): void;
  54166. /**
  54167. * Disposes the depth reducer
  54168. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54169. */
  54170. dispose(disposeAll?: boolean): void;
  54171. }
  54172. }
  54173. declare module BABYLON {
  54174. /**
  54175. * A CSM implementation allowing casting shadows on large scenes.
  54176. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54177. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54178. */
  54179. export class CascadedShadowGenerator extends ShadowGenerator {
  54180. private static readonly frustumCornersNDCSpace;
  54181. /**
  54182. * Name of the CSM class
  54183. */
  54184. static CLASSNAME: string;
  54185. /**
  54186. * Defines the default number of cascades used by the CSM.
  54187. */
  54188. static readonly DEFAULT_CASCADES_COUNT: number;
  54189. /**
  54190. * Defines the minimum number of cascades used by the CSM.
  54191. */
  54192. static readonly MIN_CASCADES_COUNT: number;
  54193. /**
  54194. * Defines the maximum number of cascades used by the CSM.
  54195. */
  54196. static readonly MAX_CASCADES_COUNT: number;
  54197. protected _validateFilter(filter: number): number;
  54198. /**
  54199. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54200. */
  54201. penumbraDarkness: number;
  54202. private _numCascades;
  54203. /**
  54204. * Gets or set the number of cascades used by the CSM.
  54205. */
  54206. get numCascades(): number;
  54207. set numCascades(value: number);
  54208. /**
  54209. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54210. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54211. */
  54212. stabilizeCascades: boolean;
  54213. private _freezeShadowCastersBoundingInfo;
  54214. private _freezeShadowCastersBoundingInfoObservable;
  54215. /**
  54216. * Enables or disables the shadow casters bounding info computation.
  54217. * If your shadow casters don't move, you can disable this feature.
  54218. * If it is enabled, the bounding box computation is done every frame.
  54219. */
  54220. get freezeShadowCastersBoundingInfo(): boolean;
  54221. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54222. private _scbiMin;
  54223. private _scbiMax;
  54224. protected _computeShadowCastersBoundingInfo(): void;
  54225. protected _shadowCastersBoundingInfo: BoundingInfo;
  54226. /**
  54227. * Gets or sets the shadow casters bounding info.
  54228. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54229. * so that the system won't overwrite the bounds you provide
  54230. */
  54231. get shadowCastersBoundingInfo(): BoundingInfo;
  54232. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54233. protected _breaksAreDirty: boolean;
  54234. protected _minDistance: number;
  54235. protected _maxDistance: number;
  54236. /**
  54237. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54238. *
  54239. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54240. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54241. * @param min minimal distance for the breaks (default to 0.)
  54242. * @param max maximal distance for the breaks (default to 1.)
  54243. */
  54244. setMinMaxDistance(min: number, max: number): void;
  54245. /** Gets the minimal distance used in the cascade break computation */
  54246. get minDistance(): number;
  54247. /** Gets the maximal distance used in the cascade break computation */
  54248. get maxDistance(): number;
  54249. /**
  54250. * Gets the class name of that object
  54251. * @returns "CascadedShadowGenerator"
  54252. */
  54253. getClassName(): string;
  54254. private _cascadeMinExtents;
  54255. private _cascadeMaxExtents;
  54256. /**
  54257. * Gets a cascade minimum extents
  54258. * @param cascadeIndex index of the cascade
  54259. * @returns the minimum cascade extents
  54260. */
  54261. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54262. /**
  54263. * Gets a cascade maximum extents
  54264. * @param cascadeIndex index of the cascade
  54265. * @returns the maximum cascade extents
  54266. */
  54267. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54268. private _cascades;
  54269. private _currentLayer;
  54270. private _viewSpaceFrustumsZ;
  54271. private _viewMatrices;
  54272. private _projectionMatrices;
  54273. private _transformMatrices;
  54274. private _transformMatricesAsArray;
  54275. private _frustumLengths;
  54276. private _lightSizeUVCorrection;
  54277. private _depthCorrection;
  54278. private _frustumCornersWorldSpace;
  54279. private _frustumCenter;
  54280. private _shadowCameraPos;
  54281. private _shadowMaxZ;
  54282. /**
  54283. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54284. * It defaults to camera.maxZ
  54285. */
  54286. get shadowMaxZ(): number;
  54287. /**
  54288. * Sets the shadow max z distance.
  54289. */
  54290. set shadowMaxZ(value: number);
  54291. protected _debug: boolean;
  54292. /**
  54293. * Gets or sets the debug flag.
  54294. * When enabled, the cascades are materialized by different colors on the screen.
  54295. */
  54296. get debug(): boolean;
  54297. set debug(dbg: boolean);
  54298. private _depthClamp;
  54299. /**
  54300. * Gets or sets the depth clamping value.
  54301. *
  54302. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54303. * to account for the shadow casters far away.
  54304. *
  54305. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54306. */
  54307. get depthClamp(): boolean;
  54308. set depthClamp(value: boolean);
  54309. private _cascadeBlendPercentage;
  54310. /**
  54311. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54312. * It defaults to 0.1 (10% blending).
  54313. */
  54314. get cascadeBlendPercentage(): number;
  54315. set cascadeBlendPercentage(value: number);
  54316. private _lambda;
  54317. /**
  54318. * Gets or set the lambda parameter.
  54319. * This parameter is used to split the camera frustum and create the cascades.
  54320. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  54321. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54322. */
  54323. get lambda(): number;
  54324. set lambda(value: number);
  54325. /**
  54326. * Gets the view matrix corresponding to a given cascade
  54327. * @param cascadeNum cascade to retrieve the view matrix from
  54328. * @returns the cascade view matrix
  54329. */
  54330. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54331. /**
  54332. * Gets the projection matrix corresponding to a given cascade
  54333. * @param cascadeNum cascade to retrieve the projection matrix from
  54334. * @returns the cascade projection matrix
  54335. */
  54336. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54337. /**
  54338. * Gets the transformation matrix corresponding to a given cascade
  54339. * @param cascadeNum cascade to retrieve the transformation matrix from
  54340. * @returns the cascade transformation matrix
  54341. */
  54342. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54343. private _depthRenderer;
  54344. /**
  54345. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54346. *
  54347. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54348. *
  54349. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54350. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54351. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  54352. */
  54353. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54354. private _depthReducer;
  54355. private _autoCalcDepthBounds;
  54356. /**
  54357. * Gets or sets the autoCalcDepthBounds property.
  54358. *
  54359. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54360. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54361. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54362. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54363. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54364. */
  54365. get autoCalcDepthBounds(): boolean;
  54366. set autoCalcDepthBounds(value: boolean);
  54367. /**
  54368. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54369. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54370. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54371. * for setting the refresh rate on the renderer yourself!
  54372. */
  54373. get autoCalcDepthBoundsRefreshRate(): number;
  54374. set autoCalcDepthBoundsRefreshRate(value: number);
  54375. /**
  54376. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54377. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54378. * you change the camera near/far planes!
  54379. */
  54380. splitFrustum(): void;
  54381. private _splitFrustum;
  54382. private _computeMatrices;
  54383. private _computeFrustumInWorldSpace;
  54384. private _computeCascadeFrustum;
  54385. /** @hidden */
  54386. static _SceneComponentInitialization: (scene: Scene) => void;
  54387. /**
  54388. * Creates a Cascaded Shadow Generator object.
  54389. * A ShadowGenerator is the required tool to use the shadows.
  54390. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54391. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54392. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54393. * @param light The directional light object generating the shadows.
  54394. * @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.
  54395. */
  54396. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54397. protected _initializeGenerator(): void;
  54398. protected _createTargetRenderTexture(): void;
  54399. protected _initializeShadowMap(): void;
  54400. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54401. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54402. /**
  54403. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54404. * @param defines Defines of the material we want to update
  54405. * @param lightIndex Index of the light in the enabled light list of the material
  54406. */
  54407. prepareDefines(defines: any, lightIndex: number): void;
  54408. /**
  54409. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54410. * defined in the generator but impacting the effect).
  54411. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54412. * @param effect The effect we are binfing the information for
  54413. */
  54414. bindShadowLight(lightIndex: string, effect: Effect): void;
  54415. /**
  54416. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54417. * (eq to view projection * shadow projection matrices)
  54418. * @returns The transform matrix used to create the shadow map
  54419. */
  54420. getTransformMatrix(): Matrix;
  54421. /**
  54422. * Disposes the ShadowGenerator.
  54423. * Returns nothing.
  54424. */
  54425. dispose(): void;
  54426. /**
  54427. * Serializes the shadow generator setup to a json object.
  54428. * @returns The serialized JSON object
  54429. */
  54430. serialize(): any;
  54431. /**
  54432. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54433. * @param parsedShadowGenerator The JSON object to parse
  54434. * @param scene The scene to create the shadow map for
  54435. * @returns The parsed shadow generator
  54436. */
  54437. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54438. }
  54439. }
  54440. declare module BABYLON {
  54441. /**
  54442. * Defines the shadow generator component responsible to manage any shadow generators
  54443. * in a given scene.
  54444. */
  54445. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54446. /**
  54447. * The component name helpfull to identify the component in the list of scene components.
  54448. */
  54449. readonly name: string;
  54450. /**
  54451. * The scene the component belongs to.
  54452. */
  54453. scene: Scene;
  54454. /**
  54455. * Creates a new instance of the component for the given scene
  54456. * @param scene Defines the scene to register the component in
  54457. */
  54458. constructor(scene: Scene);
  54459. /**
  54460. * Registers the component in a given scene
  54461. */
  54462. register(): void;
  54463. /**
  54464. * Rebuilds the elements related to this component in case of
  54465. * context lost for instance.
  54466. */
  54467. rebuild(): void;
  54468. /**
  54469. * Serializes the component data to the specified json object
  54470. * @param serializationObject The object to serialize to
  54471. */
  54472. serialize(serializationObject: any): void;
  54473. /**
  54474. * Adds all the elements from the container to the scene
  54475. * @param container the container holding the elements
  54476. */
  54477. addFromContainer(container: AbstractScene): void;
  54478. /**
  54479. * Removes all the elements in the container from the scene
  54480. * @param container contains the elements to remove
  54481. * @param dispose if the removed element should be disposed (default: false)
  54482. */
  54483. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54484. /**
  54485. * Rebuilds the elements related to this component in case of
  54486. * context lost for instance.
  54487. */
  54488. dispose(): void;
  54489. private _gatherRenderTargets;
  54490. }
  54491. }
  54492. declare module BABYLON {
  54493. /**
  54494. * A point light is a light defined by an unique point in world space.
  54495. * The light is emitted in every direction from this point.
  54496. * A good example of a point light is a standard light bulb.
  54497. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54498. */
  54499. export class PointLight extends ShadowLight {
  54500. private _shadowAngle;
  54501. /**
  54502. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54503. * This specifies what angle the shadow will use to be created.
  54504. *
  54505. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54506. */
  54507. get shadowAngle(): number;
  54508. /**
  54509. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54510. * This specifies what angle the shadow will use to be created.
  54511. *
  54512. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54513. */
  54514. set shadowAngle(value: number);
  54515. /**
  54516. * Gets the direction if it has been set.
  54517. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54518. */
  54519. get direction(): Vector3;
  54520. /**
  54521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54522. */
  54523. set direction(value: Vector3);
  54524. /**
  54525. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54526. * A PointLight emits the light in every direction.
  54527. * It can cast shadows.
  54528. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54529. * ```javascript
  54530. * var pointLight = new PointLight("pl", camera.position, scene);
  54531. * ```
  54532. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54533. * @param name The light friendly name
  54534. * @param position The position of the point light in the scene
  54535. * @param scene The scene the lights belongs to
  54536. */
  54537. constructor(name: string, position: Vector3, scene: Scene);
  54538. /**
  54539. * Returns the string "PointLight"
  54540. * @returns the class name
  54541. */
  54542. getClassName(): string;
  54543. /**
  54544. * Returns the integer 0.
  54545. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54546. */
  54547. getTypeID(): number;
  54548. /**
  54549. * Specifies wether or not the shadowmap should be a cube texture.
  54550. * @returns true if the shadowmap needs to be a cube texture.
  54551. */
  54552. needCube(): boolean;
  54553. /**
  54554. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54555. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54556. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54557. */
  54558. getShadowDirection(faceIndex?: number): Vector3;
  54559. /**
  54560. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54561. * - fov = PI / 2
  54562. * - aspect ratio : 1.0
  54563. * - z-near and far equal to the active camera minZ and maxZ.
  54564. * Returns the PointLight.
  54565. */
  54566. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54567. protected _buildUniformLayout(): void;
  54568. /**
  54569. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54570. * @param effect The effect to update
  54571. * @param lightIndex The index of the light in the effect to update
  54572. * @returns The point light
  54573. */
  54574. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54575. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54576. /**
  54577. * Prepares the list of defines specific to the light type.
  54578. * @param defines the list of defines
  54579. * @param lightIndex defines the index of the light for the effect
  54580. */
  54581. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54582. }
  54583. }
  54584. declare module BABYLON {
  54585. /**
  54586. * Header information of HDR texture files.
  54587. */
  54588. export interface HDRInfo {
  54589. /**
  54590. * The height of the texture in pixels.
  54591. */
  54592. height: number;
  54593. /**
  54594. * The width of the texture in pixels.
  54595. */
  54596. width: number;
  54597. /**
  54598. * The index of the beginning of the data in the binary file.
  54599. */
  54600. dataPosition: number;
  54601. }
  54602. /**
  54603. * This groups tools to convert HDR texture to native colors array.
  54604. */
  54605. export class HDRTools {
  54606. private static Ldexp;
  54607. private static Rgbe2float;
  54608. private static readStringLine;
  54609. /**
  54610. * Reads header information from an RGBE texture stored in a native array.
  54611. * More information on this format are available here:
  54612. * https://en.wikipedia.org/wiki/RGBE_image_format
  54613. *
  54614. * @param uint8array The binary file stored in native array.
  54615. * @return The header information.
  54616. */
  54617. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54618. /**
  54619. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54620. * This RGBE texture needs to store the information as a panorama.
  54621. *
  54622. * More information on this format are available here:
  54623. * https://en.wikipedia.org/wiki/RGBE_image_format
  54624. *
  54625. * @param buffer The binary file stored in an array buffer.
  54626. * @param size The expected size of the extracted cubemap.
  54627. * @return The Cube Map information.
  54628. */
  54629. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54630. /**
  54631. * Returns the pixels data extracted from an RGBE texture.
  54632. * This pixels will be stored left to right up to down in the R G B order in one array.
  54633. *
  54634. * More information on this format are available here:
  54635. * https://en.wikipedia.org/wiki/RGBE_image_format
  54636. *
  54637. * @param uint8array The binary file stored in an array buffer.
  54638. * @param hdrInfo The header information of the file.
  54639. * @return The pixels data in RGB right to left up to down order.
  54640. */
  54641. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54642. private static RGBE_ReadPixels_RLE;
  54643. }
  54644. }
  54645. declare module BABYLON {
  54646. /**
  54647. * This represents a texture coming from an HDR input.
  54648. *
  54649. * The only supported format is currently panorama picture stored in RGBE format.
  54650. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54651. */
  54652. export class HDRCubeTexture extends BaseTexture {
  54653. private static _facesMapping;
  54654. private _generateHarmonics;
  54655. private _noMipmap;
  54656. private _textureMatrix;
  54657. private _size;
  54658. private _onLoad;
  54659. private _onError;
  54660. /**
  54661. * The texture URL.
  54662. */
  54663. url: string;
  54664. /**
  54665. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54666. */
  54667. coordinatesMode: number;
  54668. protected _isBlocking: boolean;
  54669. /**
  54670. * Sets wether or not the texture is blocking during loading.
  54671. */
  54672. set isBlocking(value: boolean);
  54673. /**
  54674. * Gets wether or not the texture is blocking during loading.
  54675. */
  54676. get isBlocking(): boolean;
  54677. protected _rotationY: number;
  54678. /**
  54679. * Sets texture matrix rotation angle around Y axis in radians.
  54680. */
  54681. set rotationY(value: number);
  54682. /**
  54683. * Gets texture matrix rotation angle around Y axis radians.
  54684. */
  54685. get rotationY(): number;
  54686. /**
  54687. * Gets or sets the center of the bounding box associated with the cube texture
  54688. * It must define where the camera used to render the texture was set
  54689. */
  54690. boundingBoxPosition: Vector3;
  54691. private _boundingBoxSize;
  54692. /**
  54693. * Gets or sets the size of the bounding box associated with the cube texture
  54694. * When defined, the cubemap will switch to local mode
  54695. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54696. * @example https://www.babylonjs-playground.com/#RNASML
  54697. */
  54698. set boundingBoxSize(value: Vector3);
  54699. get boundingBoxSize(): Vector3;
  54700. /**
  54701. * Instantiates an HDRTexture from the following parameters.
  54702. *
  54703. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54704. * @param scene The scene the texture will be used in
  54705. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54706. * @param noMipmap Forces to not generate the mipmap if true
  54707. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54708. * @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)
  54709. * @param reserved Reserved flag for internal use.
  54710. */
  54711. 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>);
  54712. /**
  54713. * Get the current class name of the texture useful for serialization or dynamic coding.
  54714. * @returns "HDRCubeTexture"
  54715. */
  54716. getClassName(): string;
  54717. /**
  54718. * Occurs when the file is raw .hdr file.
  54719. */
  54720. private loadTexture;
  54721. clone(): HDRCubeTexture;
  54722. delayLoad(): void;
  54723. /**
  54724. * Get the texture reflection matrix used to rotate/transform the reflection.
  54725. * @returns the reflection matrix
  54726. */
  54727. getReflectionTextureMatrix(): Matrix;
  54728. /**
  54729. * Set the texture reflection matrix used to rotate/transform the reflection.
  54730. * @param value Define the reflection matrix to set
  54731. */
  54732. setReflectionTextureMatrix(value: Matrix): void;
  54733. /**
  54734. * Parses a JSON representation of an HDR Texture in order to create the texture
  54735. * @param parsedTexture Define the JSON representation
  54736. * @param scene Define the scene the texture should be created in
  54737. * @param rootUrl Define the root url in case we need to load relative dependencies
  54738. * @returns the newly created texture after parsing
  54739. */
  54740. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54741. serialize(): any;
  54742. }
  54743. }
  54744. declare module BABYLON {
  54745. /**
  54746. * Class used to control physics engine
  54747. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54748. */
  54749. export class PhysicsEngine implements IPhysicsEngine {
  54750. private _physicsPlugin;
  54751. /**
  54752. * Global value used to control the smallest number supported by the simulation
  54753. */
  54754. static Epsilon: number;
  54755. private _impostors;
  54756. private _joints;
  54757. private _subTimeStep;
  54758. /**
  54759. * Gets the gravity vector used by the simulation
  54760. */
  54761. gravity: Vector3;
  54762. /**
  54763. * Factory used to create the default physics plugin.
  54764. * @returns The default physics plugin
  54765. */
  54766. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54767. /**
  54768. * Creates a new Physics Engine
  54769. * @param gravity defines the gravity vector used by the simulation
  54770. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54771. */
  54772. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54773. /**
  54774. * Sets the gravity vector used by the simulation
  54775. * @param gravity defines the gravity vector to use
  54776. */
  54777. setGravity(gravity: Vector3): void;
  54778. /**
  54779. * Set the time step of the physics engine.
  54780. * Default is 1/60.
  54781. * To slow it down, enter 1/600 for example.
  54782. * To speed it up, 1/30
  54783. * @param newTimeStep defines the new timestep to apply to this world.
  54784. */
  54785. setTimeStep(newTimeStep?: number): void;
  54786. /**
  54787. * Get the time step of the physics engine.
  54788. * @returns the current time step
  54789. */
  54790. getTimeStep(): number;
  54791. /**
  54792. * Set the sub time step of the physics engine.
  54793. * Default is 0 meaning there is no sub steps
  54794. * To increase physics resolution precision, set a small value (like 1 ms)
  54795. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54796. */
  54797. setSubTimeStep(subTimeStep?: number): void;
  54798. /**
  54799. * Get the sub time step of the physics engine.
  54800. * @returns the current sub time step
  54801. */
  54802. getSubTimeStep(): number;
  54803. /**
  54804. * Release all resources
  54805. */
  54806. dispose(): void;
  54807. /**
  54808. * Gets the name of the current physics plugin
  54809. * @returns the name of the plugin
  54810. */
  54811. getPhysicsPluginName(): string;
  54812. /**
  54813. * Adding a new impostor for the impostor tracking.
  54814. * This will be done by the impostor itself.
  54815. * @param impostor the impostor to add
  54816. */
  54817. addImpostor(impostor: PhysicsImpostor): void;
  54818. /**
  54819. * Remove an impostor from the engine.
  54820. * This impostor and its mesh will not longer be updated by the physics engine.
  54821. * @param impostor the impostor to remove
  54822. */
  54823. removeImpostor(impostor: PhysicsImpostor): void;
  54824. /**
  54825. * Add a joint to the physics engine
  54826. * @param mainImpostor defines the main impostor to which the joint is added.
  54827. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54828. * @param joint defines the joint that will connect both impostors.
  54829. */
  54830. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54831. /**
  54832. * Removes a joint from the simulation
  54833. * @param mainImpostor defines the impostor used with the joint
  54834. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54835. * @param joint defines the joint to remove
  54836. */
  54837. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54838. /**
  54839. * Called by the scene. No need to call it.
  54840. * @param delta defines the timespam between frames
  54841. */
  54842. _step(delta: number): void;
  54843. /**
  54844. * Gets the current plugin used to run the simulation
  54845. * @returns current plugin
  54846. */
  54847. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54848. /**
  54849. * Gets the list of physic impostors
  54850. * @returns an array of PhysicsImpostor
  54851. */
  54852. getImpostors(): Array<PhysicsImpostor>;
  54853. /**
  54854. * Gets the impostor for a physics enabled object
  54855. * @param object defines the object impersonated by the impostor
  54856. * @returns the PhysicsImpostor or null if not found
  54857. */
  54858. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54859. /**
  54860. * Gets the impostor for a physics body object
  54861. * @param body defines physics body used by the impostor
  54862. * @returns the PhysicsImpostor or null if not found
  54863. */
  54864. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54865. /**
  54866. * Does a raycast in the physics world
  54867. * @param from when should the ray start?
  54868. * @param to when should the ray end?
  54869. * @returns PhysicsRaycastResult
  54870. */
  54871. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54872. }
  54873. }
  54874. declare module BABYLON {
  54875. /** @hidden */
  54876. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54877. private _useDeltaForWorldStep;
  54878. world: any;
  54879. name: string;
  54880. private _physicsMaterials;
  54881. private _fixedTimeStep;
  54882. private _cannonRaycastResult;
  54883. private _raycastResult;
  54884. private _physicsBodysToRemoveAfterStep;
  54885. BJSCANNON: any;
  54886. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54887. setGravity(gravity: Vector3): void;
  54888. setTimeStep(timeStep: number): void;
  54889. getTimeStep(): number;
  54890. executeStep(delta: number): void;
  54891. private _removeMarkedPhysicsBodiesFromWorld;
  54892. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54893. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54894. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54895. private _processChildMeshes;
  54896. removePhysicsBody(impostor: PhysicsImpostor): void;
  54897. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54898. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54899. private _addMaterial;
  54900. private _checkWithEpsilon;
  54901. private _createShape;
  54902. private _createHeightmap;
  54903. private _minus90X;
  54904. private _plus90X;
  54905. private _tmpPosition;
  54906. private _tmpDeltaPosition;
  54907. private _tmpUnityRotation;
  54908. private _updatePhysicsBodyTransformation;
  54909. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54910. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54911. isSupported(): boolean;
  54912. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54913. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54914. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54915. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54916. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54917. getBodyMass(impostor: PhysicsImpostor): number;
  54918. getBodyFriction(impostor: PhysicsImpostor): number;
  54919. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54920. getBodyRestitution(impostor: PhysicsImpostor): number;
  54921. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54922. sleepBody(impostor: PhysicsImpostor): void;
  54923. wakeUpBody(impostor: PhysicsImpostor): void;
  54924. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54925. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54926. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54927. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54928. getRadius(impostor: PhysicsImpostor): number;
  54929. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54930. dispose(): void;
  54931. private _extendNamespace;
  54932. /**
  54933. * Does a raycast in the physics world
  54934. * @param from when should the ray start?
  54935. * @param to when should the ray end?
  54936. * @returns PhysicsRaycastResult
  54937. */
  54938. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54939. }
  54940. }
  54941. declare module BABYLON {
  54942. /** @hidden */
  54943. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54944. world: any;
  54945. name: string;
  54946. BJSOIMO: any;
  54947. private _raycastResult;
  54948. constructor(iterations?: number, oimoInjection?: any);
  54949. setGravity(gravity: Vector3): void;
  54950. setTimeStep(timeStep: number): void;
  54951. getTimeStep(): number;
  54952. private _tmpImpostorsArray;
  54953. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54954. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54955. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54956. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54957. private _tmpPositionVector;
  54958. removePhysicsBody(impostor: PhysicsImpostor): void;
  54959. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54960. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54961. isSupported(): boolean;
  54962. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54963. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54964. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54965. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54966. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54967. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54968. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54969. getBodyMass(impostor: PhysicsImpostor): number;
  54970. getBodyFriction(impostor: PhysicsImpostor): number;
  54971. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54972. getBodyRestitution(impostor: PhysicsImpostor): number;
  54973. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54974. sleepBody(impostor: PhysicsImpostor): void;
  54975. wakeUpBody(impostor: PhysicsImpostor): void;
  54976. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54977. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54978. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54979. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54980. getRadius(impostor: PhysicsImpostor): number;
  54981. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54982. dispose(): void;
  54983. /**
  54984. * Does a raycast in the physics world
  54985. * @param from when should the ray start?
  54986. * @param to when should the ray end?
  54987. * @returns PhysicsRaycastResult
  54988. */
  54989. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54990. }
  54991. }
  54992. declare module BABYLON {
  54993. /**
  54994. * Class containing static functions to help procedurally build meshes
  54995. */
  54996. export class RibbonBuilder {
  54997. /**
  54998. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54999. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55000. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55001. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55002. * * 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
  55003. * * 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
  55004. * * 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
  55005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55006. * * 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
  55007. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55008. * * 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
  55009. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55010. * * 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
  55011. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55013. * @param name defines the name of the mesh
  55014. * @param options defines the options used to create the mesh
  55015. * @param scene defines the hosting scene
  55016. * @returns the ribbon mesh
  55017. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55019. */
  55020. static CreateRibbon(name: string, options: {
  55021. pathArray: Vector3[][];
  55022. closeArray?: boolean;
  55023. closePath?: boolean;
  55024. offset?: number;
  55025. updatable?: boolean;
  55026. sideOrientation?: number;
  55027. frontUVs?: Vector4;
  55028. backUVs?: Vector4;
  55029. instance?: Mesh;
  55030. invertUV?: boolean;
  55031. uvs?: Vector2[];
  55032. colors?: Color4[];
  55033. }, scene?: Nullable<Scene>): Mesh;
  55034. }
  55035. }
  55036. declare module BABYLON {
  55037. /**
  55038. * Class containing static functions to help procedurally build meshes
  55039. */
  55040. export class ShapeBuilder {
  55041. /**
  55042. * 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.
  55043. * * 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.
  55044. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55045. * * 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.
  55046. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55047. * * 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
  55048. * * 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
  55049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55051. * * 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
  55052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55054. * @param name defines the name of the mesh
  55055. * @param options defines the options used to create the mesh
  55056. * @param scene defines the hosting scene
  55057. * @returns the extruded shape mesh
  55058. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55060. */
  55061. static ExtrudeShape(name: string, options: {
  55062. shape: Vector3[];
  55063. path: Vector3[];
  55064. scale?: number;
  55065. rotation?: number;
  55066. cap?: number;
  55067. updatable?: boolean;
  55068. sideOrientation?: number;
  55069. frontUVs?: Vector4;
  55070. backUVs?: Vector4;
  55071. instance?: Mesh;
  55072. invertUV?: boolean;
  55073. }, scene?: Nullable<Scene>): Mesh;
  55074. /**
  55075. * Creates an custom extruded shape mesh.
  55076. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55077. * * 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.
  55078. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55079. * * 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
  55080. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55081. * * 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
  55082. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55083. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55084. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55085. * * 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
  55086. * * 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
  55087. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55089. * * 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
  55090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55092. * @param name defines the name of the mesh
  55093. * @param options defines the options used to create the mesh
  55094. * @param scene defines the hosting scene
  55095. * @returns the custom extruded shape mesh
  55096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55097. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55099. */
  55100. static ExtrudeShapeCustom(name: string, options: {
  55101. shape: Vector3[];
  55102. path: Vector3[];
  55103. scaleFunction?: any;
  55104. rotationFunction?: any;
  55105. ribbonCloseArray?: boolean;
  55106. ribbonClosePath?: boolean;
  55107. cap?: number;
  55108. updatable?: boolean;
  55109. sideOrientation?: number;
  55110. frontUVs?: Vector4;
  55111. backUVs?: Vector4;
  55112. instance?: Mesh;
  55113. invertUV?: boolean;
  55114. }, scene?: Nullable<Scene>): Mesh;
  55115. private static _ExtrudeShapeGeneric;
  55116. }
  55117. }
  55118. declare module BABYLON {
  55119. /**
  55120. * AmmoJS Physics plugin
  55121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55122. * @see https://github.com/kripken/ammo.js/
  55123. */
  55124. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55125. private _useDeltaForWorldStep;
  55126. /**
  55127. * Reference to the Ammo library
  55128. */
  55129. bjsAMMO: any;
  55130. /**
  55131. * Created ammoJS world which physics bodies are added to
  55132. */
  55133. world: any;
  55134. /**
  55135. * Name of the plugin
  55136. */
  55137. name: string;
  55138. private _timeStep;
  55139. private _fixedTimeStep;
  55140. private _maxSteps;
  55141. private _tmpQuaternion;
  55142. private _tmpAmmoTransform;
  55143. private _tmpAmmoQuaternion;
  55144. private _tmpAmmoConcreteContactResultCallback;
  55145. private _collisionConfiguration;
  55146. private _dispatcher;
  55147. private _overlappingPairCache;
  55148. private _solver;
  55149. private _softBodySolver;
  55150. private _tmpAmmoVectorA;
  55151. private _tmpAmmoVectorB;
  55152. private _tmpAmmoVectorC;
  55153. private _tmpAmmoVectorD;
  55154. private _tmpContactCallbackResult;
  55155. private _tmpAmmoVectorRCA;
  55156. private _tmpAmmoVectorRCB;
  55157. private _raycastResult;
  55158. private static readonly DISABLE_COLLISION_FLAG;
  55159. private static readonly KINEMATIC_FLAG;
  55160. private static readonly DISABLE_DEACTIVATION_FLAG;
  55161. /**
  55162. * Initializes the ammoJS plugin
  55163. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55164. * @param ammoInjection can be used to inject your own ammo reference
  55165. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55166. */
  55167. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55168. /**
  55169. * Sets the gravity of the physics world (m/(s^2))
  55170. * @param gravity Gravity to set
  55171. */
  55172. setGravity(gravity: Vector3): void;
  55173. /**
  55174. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55175. * @param timeStep timestep to use in seconds
  55176. */
  55177. setTimeStep(timeStep: number): void;
  55178. /**
  55179. * 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)
  55180. * @param fixedTimeStep fixedTimeStep to use in seconds
  55181. */
  55182. setFixedTimeStep(fixedTimeStep: number): void;
  55183. /**
  55184. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55185. * @param maxSteps the maximum number of steps by the physics engine per frame
  55186. */
  55187. setMaxSteps(maxSteps: number): void;
  55188. /**
  55189. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55190. * @returns the current timestep in seconds
  55191. */
  55192. getTimeStep(): number;
  55193. /**
  55194. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55195. */
  55196. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55197. private _isImpostorInContact;
  55198. private _isImpostorPairInContact;
  55199. private _stepSimulation;
  55200. /**
  55201. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55202. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55203. * After the step the babylon meshes are set to the position of the physics imposters
  55204. * @param delta amount of time to step forward
  55205. * @param impostors array of imposters to update before/after the step
  55206. */
  55207. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55208. /**
  55209. * Update babylon mesh to match physics world object
  55210. * @param impostor imposter to match
  55211. */
  55212. private _afterSoftStep;
  55213. /**
  55214. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55215. * @param impostor imposter to match
  55216. */
  55217. private _ropeStep;
  55218. /**
  55219. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55220. * @param impostor imposter to match
  55221. */
  55222. private _softbodyOrClothStep;
  55223. private _tmpVector;
  55224. private _tmpMatrix;
  55225. /**
  55226. * Applies an impulse on the imposter
  55227. * @param impostor imposter to apply impulse to
  55228. * @param force amount of force to be applied to the imposter
  55229. * @param contactPoint the location to apply the impulse on the imposter
  55230. */
  55231. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55232. /**
  55233. * Applies a force on the imposter
  55234. * @param impostor imposter to apply force
  55235. * @param force amount of force to be applied to the imposter
  55236. * @param contactPoint the location to apply the force on the imposter
  55237. */
  55238. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55239. /**
  55240. * Creates a physics body using the plugin
  55241. * @param impostor the imposter to create the physics body on
  55242. */
  55243. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55244. /**
  55245. * Removes the physics body from the imposter and disposes of the body's memory
  55246. * @param impostor imposter to remove the physics body from
  55247. */
  55248. removePhysicsBody(impostor: PhysicsImpostor): void;
  55249. /**
  55250. * Generates a joint
  55251. * @param impostorJoint the imposter joint to create the joint with
  55252. */
  55253. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55254. /**
  55255. * Removes a joint
  55256. * @param impostorJoint the imposter joint to remove the joint from
  55257. */
  55258. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55259. private _addMeshVerts;
  55260. /**
  55261. * Initialise the soft body vertices to match its object's (mesh) vertices
  55262. * Softbody vertices (nodes) are in world space and to match this
  55263. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55264. * @param impostor to create the softbody for
  55265. */
  55266. private _softVertexData;
  55267. /**
  55268. * Create an impostor's soft body
  55269. * @param impostor to create the softbody for
  55270. */
  55271. private _createSoftbody;
  55272. /**
  55273. * Create cloth for an impostor
  55274. * @param impostor to create the softbody for
  55275. */
  55276. private _createCloth;
  55277. /**
  55278. * Create rope for an impostor
  55279. * @param impostor to create the softbody for
  55280. */
  55281. private _createRope;
  55282. /**
  55283. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55284. * @param impostor to create the custom physics shape for
  55285. */
  55286. private _createCustom;
  55287. private _addHullVerts;
  55288. private _createShape;
  55289. /**
  55290. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55291. * @param impostor imposter containing the physics body and babylon object
  55292. */
  55293. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55294. /**
  55295. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55296. * @param impostor imposter containing the physics body and babylon object
  55297. * @param newPosition new position
  55298. * @param newRotation new rotation
  55299. */
  55300. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55301. /**
  55302. * If this plugin is supported
  55303. * @returns true if its supported
  55304. */
  55305. isSupported(): boolean;
  55306. /**
  55307. * Sets the linear velocity of the physics body
  55308. * @param impostor imposter to set the velocity on
  55309. * @param velocity velocity to set
  55310. */
  55311. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55312. /**
  55313. * Sets the angular velocity of the physics body
  55314. * @param impostor imposter to set the velocity on
  55315. * @param velocity velocity to set
  55316. */
  55317. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55318. /**
  55319. * gets the linear velocity
  55320. * @param impostor imposter to get linear velocity from
  55321. * @returns linear velocity
  55322. */
  55323. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55324. /**
  55325. * gets the angular velocity
  55326. * @param impostor imposter to get angular velocity from
  55327. * @returns angular velocity
  55328. */
  55329. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55330. /**
  55331. * Sets the mass of physics body
  55332. * @param impostor imposter to set the mass on
  55333. * @param mass mass to set
  55334. */
  55335. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55336. /**
  55337. * Gets the mass of the physics body
  55338. * @param impostor imposter to get the mass from
  55339. * @returns mass
  55340. */
  55341. getBodyMass(impostor: PhysicsImpostor): number;
  55342. /**
  55343. * Gets friction of the impostor
  55344. * @param impostor impostor to get friction from
  55345. * @returns friction value
  55346. */
  55347. getBodyFriction(impostor: PhysicsImpostor): number;
  55348. /**
  55349. * Sets friction of the impostor
  55350. * @param impostor impostor to set friction on
  55351. * @param friction friction value
  55352. */
  55353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55354. /**
  55355. * Gets restitution of the impostor
  55356. * @param impostor impostor to get restitution from
  55357. * @returns restitution value
  55358. */
  55359. getBodyRestitution(impostor: PhysicsImpostor): number;
  55360. /**
  55361. * Sets resitution of the impostor
  55362. * @param impostor impostor to set resitution on
  55363. * @param restitution resitution value
  55364. */
  55365. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55366. /**
  55367. * Gets pressure inside the impostor
  55368. * @param impostor impostor to get pressure from
  55369. * @returns pressure value
  55370. */
  55371. getBodyPressure(impostor: PhysicsImpostor): number;
  55372. /**
  55373. * Sets pressure inside a soft body impostor
  55374. * Cloth and rope must remain 0 pressure
  55375. * @param impostor impostor to set pressure on
  55376. * @param pressure pressure value
  55377. */
  55378. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55379. /**
  55380. * Gets stiffness of the impostor
  55381. * @param impostor impostor to get stiffness from
  55382. * @returns pressure value
  55383. */
  55384. getBodyStiffness(impostor: PhysicsImpostor): number;
  55385. /**
  55386. * Sets stiffness of the impostor
  55387. * @param impostor impostor to set stiffness on
  55388. * @param stiffness stiffness value from 0 to 1
  55389. */
  55390. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55391. /**
  55392. * Gets velocityIterations of the impostor
  55393. * @param impostor impostor to get velocity iterations from
  55394. * @returns velocityIterations value
  55395. */
  55396. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55397. /**
  55398. * Sets velocityIterations of the impostor
  55399. * @param impostor impostor to set velocity iterations on
  55400. * @param velocityIterations velocityIterations value
  55401. */
  55402. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55403. /**
  55404. * Gets positionIterations of the impostor
  55405. * @param impostor impostor to get position iterations from
  55406. * @returns positionIterations value
  55407. */
  55408. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55409. /**
  55410. * Sets positionIterations of the impostor
  55411. * @param impostor impostor to set position on
  55412. * @param positionIterations positionIterations value
  55413. */
  55414. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55415. /**
  55416. * Append an anchor to a cloth object
  55417. * @param impostor is the cloth impostor to add anchor to
  55418. * @param otherImpostor is the rigid impostor to anchor to
  55419. * @param width ratio across width from 0 to 1
  55420. * @param height ratio up height from 0 to 1
  55421. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55422. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55423. */
  55424. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55425. /**
  55426. * Append an hook to a rope object
  55427. * @param impostor is the rope impostor to add hook to
  55428. * @param otherImpostor is the rigid impostor to hook to
  55429. * @param length ratio along the rope from 0 to 1
  55430. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55431. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55432. */
  55433. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55434. /**
  55435. * Sleeps the physics body and stops it from being active
  55436. * @param impostor impostor to sleep
  55437. */
  55438. sleepBody(impostor: PhysicsImpostor): void;
  55439. /**
  55440. * Activates the physics body
  55441. * @param impostor impostor to activate
  55442. */
  55443. wakeUpBody(impostor: PhysicsImpostor): void;
  55444. /**
  55445. * Updates the distance parameters of the joint
  55446. * @param joint joint to update
  55447. * @param maxDistance maximum distance of the joint
  55448. * @param minDistance minimum distance of the joint
  55449. */
  55450. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55451. /**
  55452. * Sets a motor on the joint
  55453. * @param joint joint to set motor on
  55454. * @param speed speed of the motor
  55455. * @param maxForce maximum force of the motor
  55456. * @param motorIndex index of the motor
  55457. */
  55458. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55459. /**
  55460. * Sets the motors limit
  55461. * @param joint joint to set limit on
  55462. * @param upperLimit upper limit
  55463. * @param lowerLimit lower limit
  55464. */
  55465. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55466. /**
  55467. * Syncs the position and rotation of a mesh with the impostor
  55468. * @param mesh mesh to sync
  55469. * @param impostor impostor to update the mesh with
  55470. */
  55471. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55472. /**
  55473. * Gets the radius of the impostor
  55474. * @param impostor impostor to get radius from
  55475. * @returns the radius
  55476. */
  55477. getRadius(impostor: PhysicsImpostor): number;
  55478. /**
  55479. * Gets the box size of the impostor
  55480. * @param impostor impostor to get box size from
  55481. * @param result the resulting box size
  55482. */
  55483. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55484. /**
  55485. * Disposes of the impostor
  55486. */
  55487. dispose(): void;
  55488. /**
  55489. * Does a raycast in the physics world
  55490. * @param from when should the ray start?
  55491. * @param to when should the ray end?
  55492. * @returns PhysicsRaycastResult
  55493. */
  55494. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55495. }
  55496. }
  55497. declare module BABYLON {
  55498. interface AbstractScene {
  55499. /**
  55500. * The list of reflection probes added to the scene
  55501. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55502. */
  55503. reflectionProbes: Array<ReflectionProbe>;
  55504. /**
  55505. * Removes the given reflection probe from this scene.
  55506. * @param toRemove The reflection probe to remove
  55507. * @returns The index of the removed reflection probe
  55508. */
  55509. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55510. /**
  55511. * Adds the given reflection probe to this scene.
  55512. * @param newReflectionProbe The reflection probe to add
  55513. */
  55514. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55515. }
  55516. /**
  55517. * Class used to generate realtime reflection / refraction cube textures
  55518. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55519. */
  55520. export class ReflectionProbe {
  55521. /** defines the name of the probe */
  55522. name: string;
  55523. private _scene;
  55524. private _renderTargetTexture;
  55525. private _projectionMatrix;
  55526. private _viewMatrix;
  55527. private _target;
  55528. private _add;
  55529. private _attachedMesh;
  55530. private _invertYAxis;
  55531. /** Gets or sets probe position (center of the cube map) */
  55532. position: Vector3;
  55533. /**
  55534. * Creates a new reflection probe
  55535. * @param name defines the name of the probe
  55536. * @param size defines the texture resolution (for each face)
  55537. * @param scene defines the hosting scene
  55538. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55539. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55540. */
  55541. constructor(
  55542. /** defines the name of the probe */
  55543. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55544. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55545. get samples(): number;
  55546. set samples(value: number);
  55547. /** Gets or sets the refresh rate to use (on every frame by default) */
  55548. get refreshRate(): number;
  55549. set refreshRate(value: number);
  55550. /**
  55551. * Gets the hosting scene
  55552. * @returns a Scene
  55553. */
  55554. getScene(): Scene;
  55555. /** Gets the internal CubeTexture used to render to */
  55556. get cubeTexture(): RenderTargetTexture;
  55557. /** Gets the list of meshes to render */
  55558. get renderList(): Nullable<AbstractMesh[]>;
  55559. /**
  55560. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55561. * @param mesh defines the mesh to attach to
  55562. */
  55563. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55564. /**
  55565. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55566. * @param renderingGroupId The rendering group id corresponding to its index
  55567. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55568. */
  55569. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55570. /**
  55571. * Clean all associated resources
  55572. */
  55573. dispose(): void;
  55574. /**
  55575. * Converts the reflection probe information to a readable string for debug purpose.
  55576. * @param fullDetails Supports for multiple levels of logging within scene loading
  55577. * @returns the human readable reflection probe info
  55578. */
  55579. toString(fullDetails?: boolean): string;
  55580. /**
  55581. * Get the class name of the relfection probe.
  55582. * @returns "ReflectionProbe"
  55583. */
  55584. getClassName(): string;
  55585. /**
  55586. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55587. * @returns The JSON representation of the texture
  55588. */
  55589. serialize(): any;
  55590. /**
  55591. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55592. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55593. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55594. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55595. * @returns The parsed reflection probe if successful
  55596. */
  55597. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55598. }
  55599. }
  55600. declare module BABYLON {
  55601. /** @hidden */
  55602. export var _BabylonLoaderRegistered: boolean;
  55603. /**
  55604. * Helps setting up some configuration for the babylon file loader.
  55605. */
  55606. export class BabylonFileLoaderConfiguration {
  55607. /**
  55608. * The loader does not allow injecting custom physix engine into the plugins.
  55609. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55610. * So you could set this variable to your engine import to make it work.
  55611. */
  55612. static LoaderInjectedPhysicsEngine: any;
  55613. }
  55614. }
  55615. declare module BABYLON {
  55616. /**
  55617. * The Physically based simple base material of BJS.
  55618. *
  55619. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55620. * It is used as the base class for both the specGloss and metalRough conventions.
  55621. */
  55622. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55623. /**
  55624. * Number of Simultaneous lights allowed on the material.
  55625. */
  55626. maxSimultaneousLights: number;
  55627. /**
  55628. * If sets to true, disables all the lights affecting the material.
  55629. */
  55630. disableLighting: boolean;
  55631. /**
  55632. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55633. */
  55634. environmentTexture: BaseTexture;
  55635. /**
  55636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55637. */
  55638. invertNormalMapX: boolean;
  55639. /**
  55640. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55641. */
  55642. invertNormalMapY: boolean;
  55643. /**
  55644. * Normal map used in the model.
  55645. */
  55646. normalTexture: BaseTexture;
  55647. /**
  55648. * Emissivie color used to self-illuminate the model.
  55649. */
  55650. emissiveColor: Color3;
  55651. /**
  55652. * Emissivie texture used to self-illuminate the model.
  55653. */
  55654. emissiveTexture: BaseTexture;
  55655. /**
  55656. * Occlusion Channel Strenght.
  55657. */
  55658. occlusionStrength: number;
  55659. /**
  55660. * Occlusion Texture of the material (adding extra occlusion effects).
  55661. */
  55662. occlusionTexture: BaseTexture;
  55663. /**
  55664. * Defines the alpha limits in alpha test mode.
  55665. */
  55666. alphaCutOff: number;
  55667. /**
  55668. * Gets the current double sided mode.
  55669. */
  55670. get doubleSided(): boolean;
  55671. /**
  55672. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55673. */
  55674. set doubleSided(value: boolean);
  55675. /**
  55676. * Stores the pre-calculated light information of a mesh in a texture.
  55677. */
  55678. lightmapTexture: BaseTexture;
  55679. /**
  55680. * If true, the light map contains occlusion information instead of lighting info.
  55681. */
  55682. useLightmapAsShadowmap: boolean;
  55683. /**
  55684. * Instantiates a new PBRMaterial instance.
  55685. *
  55686. * @param name The material name
  55687. * @param scene The scene the material will be use in.
  55688. */
  55689. constructor(name: string, scene: Scene);
  55690. getClassName(): string;
  55691. }
  55692. }
  55693. declare module BABYLON {
  55694. /**
  55695. * The PBR material of BJS following the metal roughness convention.
  55696. *
  55697. * This fits to the PBR convention in the GLTF definition:
  55698. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55699. */
  55700. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55701. /**
  55702. * The base color has two different interpretations depending on the value of metalness.
  55703. * When the material is a metal, the base color is the specific measured reflectance value
  55704. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55705. * of the material.
  55706. */
  55707. baseColor: Color3;
  55708. /**
  55709. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55710. * well as opacity information in the alpha channel.
  55711. */
  55712. baseTexture: BaseTexture;
  55713. /**
  55714. * Specifies the metallic scalar value of the material.
  55715. * Can also be used to scale the metalness values of the metallic texture.
  55716. */
  55717. metallic: number;
  55718. /**
  55719. * Specifies the roughness scalar value of the material.
  55720. * Can also be used to scale the roughness values of the metallic texture.
  55721. */
  55722. roughness: number;
  55723. /**
  55724. * Texture containing both the metallic value in the B channel and the
  55725. * roughness value in the G channel to keep better precision.
  55726. */
  55727. metallicRoughnessTexture: BaseTexture;
  55728. /**
  55729. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55730. *
  55731. * @param name The material name
  55732. * @param scene The scene the material will be use in.
  55733. */
  55734. constructor(name: string, scene: Scene);
  55735. /**
  55736. * Return the currrent class name of the material.
  55737. */
  55738. getClassName(): string;
  55739. /**
  55740. * Makes a duplicate of the current material.
  55741. * @param name - name to use for the new material.
  55742. */
  55743. clone(name: string): PBRMetallicRoughnessMaterial;
  55744. /**
  55745. * Serialize the material to a parsable JSON object.
  55746. */
  55747. serialize(): any;
  55748. /**
  55749. * Parses a JSON object correponding to the serialize function.
  55750. */
  55751. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55752. }
  55753. }
  55754. declare module BABYLON {
  55755. /**
  55756. * The PBR material of BJS following the specular glossiness convention.
  55757. *
  55758. * This fits to the PBR convention in the GLTF definition:
  55759. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55760. */
  55761. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55762. /**
  55763. * Specifies the diffuse color of the material.
  55764. */
  55765. diffuseColor: Color3;
  55766. /**
  55767. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55768. * channel.
  55769. */
  55770. diffuseTexture: BaseTexture;
  55771. /**
  55772. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55773. */
  55774. specularColor: Color3;
  55775. /**
  55776. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55777. */
  55778. glossiness: number;
  55779. /**
  55780. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55781. */
  55782. specularGlossinessTexture: BaseTexture;
  55783. /**
  55784. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55785. *
  55786. * @param name The material name
  55787. * @param scene The scene the material will be use in.
  55788. */
  55789. constructor(name: string, scene: Scene);
  55790. /**
  55791. * Return the currrent class name of the material.
  55792. */
  55793. getClassName(): string;
  55794. /**
  55795. * Makes a duplicate of the current material.
  55796. * @param name - name to use for the new material.
  55797. */
  55798. clone(name: string): PBRSpecularGlossinessMaterial;
  55799. /**
  55800. * Serialize the material to a parsable JSON object.
  55801. */
  55802. serialize(): any;
  55803. /**
  55804. * Parses a JSON object correponding to the serialize function.
  55805. */
  55806. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55807. }
  55808. }
  55809. declare module BABYLON {
  55810. /**
  55811. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55812. * It can help converting any input color in a desired output one. This can then be used to create effects
  55813. * from sepia, black and white to sixties or futuristic rendering...
  55814. *
  55815. * The only supported format is currently 3dl.
  55816. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55817. */
  55818. export class ColorGradingTexture extends BaseTexture {
  55819. /**
  55820. * The current texture matrix. (will always be identity in color grading texture)
  55821. */
  55822. private _textureMatrix;
  55823. /**
  55824. * The texture URL.
  55825. */
  55826. url: string;
  55827. /**
  55828. * Empty line regex stored for GC.
  55829. */
  55830. private static _noneEmptyLineRegex;
  55831. private _engine;
  55832. /**
  55833. * Instantiates a ColorGradingTexture from the following parameters.
  55834. *
  55835. * @param url The location of the color gradind data (currently only supporting 3dl)
  55836. * @param scene The scene the texture will be used in
  55837. */
  55838. constructor(url: string, scene: Scene);
  55839. /**
  55840. * Returns the texture matrix used in most of the material.
  55841. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55842. */
  55843. getTextureMatrix(): Matrix;
  55844. /**
  55845. * Occurs when the file being loaded is a .3dl LUT file.
  55846. */
  55847. private load3dlTexture;
  55848. /**
  55849. * Starts the loading process of the texture.
  55850. */
  55851. private loadTexture;
  55852. /**
  55853. * Clones the color gradind texture.
  55854. */
  55855. clone(): ColorGradingTexture;
  55856. /**
  55857. * Called during delayed load for textures.
  55858. */
  55859. delayLoad(): void;
  55860. /**
  55861. * Parses a color grading texture serialized by Babylon.
  55862. * @param parsedTexture The texture information being parsedTexture
  55863. * @param scene The scene to load the texture in
  55864. * @param rootUrl The root url of the data assets to load
  55865. * @return A color gradind texture
  55866. */
  55867. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55868. /**
  55869. * Serializes the LUT texture to json format.
  55870. */
  55871. serialize(): any;
  55872. }
  55873. }
  55874. declare module BABYLON {
  55875. /**
  55876. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55877. */
  55878. export class EquiRectangularCubeTexture extends BaseTexture {
  55879. /** The six faces of the cube. */
  55880. private static _FacesMapping;
  55881. private _noMipmap;
  55882. private _onLoad;
  55883. private _onError;
  55884. /** The size of the cubemap. */
  55885. private _size;
  55886. /** The buffer of the image. */
  55887. private _buffer;
  55888. /** The width of the input image. */
  55889. private _width;
  55890. /** The height of the input image. */
  55891. private _height;
  55892. /** The URL to the image. */
  55893. url: string;
  55894. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55895. coordinatesMode: number;
  55896. /**
  55897. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55898. * @param url The location of the image
  55899. * @param scene The scene the texture will be used in
  55900. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55901. * @param noMipmap Forces to not generate the mipmap if true
  55902. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55903. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55904. * @param onLoad — defines a callback called when texture is loaded
  55905. * @param onError — defines a callback called if there is an error
  55906. */
  55907. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55908. /**
  55909. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55910. */
  55911. private loadImage;
  55912. /**
  55913. * Convert the image buffer into a cubemap and create a CubeTexture.
  55914. */
  55915. private loadTexture;
  55916. /**
  55917. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55918. * @param buffer The ArrayBuffer that should be converted.
  55919. * @returns The buffer as Float32Array.
  55920. */
  55921. private getFloat32ArrayFromArrayBuffer;
  55922. /**
  55923. * Get the current class name of the texture useful for serialization or dynamic coding.
  55924. * @returns "EquiRectangularCubeTexture"
  55925. */
  55926. getClassName(): string;
  55927. /**
  55928. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55929. * @returns A clone of the current EquiRectangularCubeTexture.
  55930. */
  55931. clone(): EquiRectangularCubeTexture;
  55932. }
  55933. }
  55934. declare module BABYLON {
  55935. /**
  55936. * Based on jsTGALoader - Javascript loader for TGA file
  55937. * By Vincent Thibault
  55938. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55939. */
  55940. export class TGATools {
  55941. private static _TYPE_INDEXED;
  55942. private static _TYPE_RGB;
  55943. private static _TYPE_GREY;
  55944. private static _TYPE_RLE_INDEXED;
  55945. private static _TYPE_RLE_RGB;
  55946. private static _TYPE_RLE_GREY;
  55947. private static _ORIGIN_MASK;
  55948. private static _ORIGIN_SHIFT;
  55949. private static _ORIGIN_BL;
  55950. private static _ORIGIN_BR;
  55951. private static _ORIGIN_UL;
  55952. private static _ORIGIN_UR;
  55953. /**
  55954. * Gets the header of a TGA file
  55955. * @param data defines the TGA data
  55956. * @returns the header
  55957. */
  55958. static GetTGAHeader(data: Uint8Array): any;
  55959. /**
  55960. * Uploads TGA content to a Babylon Texture
  55961. * @hidden
  55962. */
  55963. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55964. /** @hidden */
  55965. 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;
  55966. /** @hidden */
  55967. 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;
  55968. /** @hidden */
  55969. 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;
  55970. /** @hidden */
  55971. 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;
  55972. /** @hidden */
  55973. 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;
  55974. /** @hidden */
  55975. 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;
  55976. }
  55977. }
  55978. declare module BABYLON {
  55979. /**
  55980. * Implementation of the TGA Texture Loader.
  55981. * @hidden
  55982. */
  55983. export class _TGATextureLoader implements IInternalTextureLoader {
  55984. /**
  55985. * Defines wether the loader supports cascade loading the different faces.
  55986. */
  55987. readonly supportCascades: boolean;
  55988. /**
  55989. * This returns if the loader support the current file information.
  55990. * @param extension defines the file extension of the file being loaded
  55991. * @returns true if the loader can load the specified file
  55992. */
  55993. canLoad(extension: string): boolean;
  55994. /**
  55995. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55996. * @param data contains the texture data
  55997. * @param texture defines the BabylonJS internal texture
  55998. * @param createPolynomials will be true if polynomials have been requested
  55999. * @param onLoad defines the callback to trigger once the texture is ready
  56000. * @param onError defines the callback to trigger in case of error
  56001. */
  56002. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56003. /**
  56004. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56005. * @param data contains the texture data
  56006. * @param texture defines the BabylonJS internal texture
  56007. * @param callback defines the method to call once ready to upload
  56008. */
  56009. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56010. }
  56011. }
  56012. declare module BABYLON {
  56013. /**
  56014. * Info about the .basis files
  56015. */
  56016. class BasisFileInfo {
  56017. /**
  56018. * If the file has alpha
  56019. */
  56020. hasAlpha: boolean;
  56021. /**
  56022. * Info about each image of the basis file
  56023. */
  56024. images: Array<{
  56025. levels: Array<{
  56026. width: number;
  56027. height: number;
  56028. transcodedPixels: ArrayBufferView;
  56029. }>;
  56030. }>;
  56031. }
  56032. /**
  56033. * Result of transcoding a basis file
  56034. */
  56035. class TranscodeResult {
  56036. /**
  56037. * Info about the .basis file
  56038. */
  56039. fileInfo: BasisFileInfo;
  56040. /**
  56041. * Format to use when loading the file
  56042. */
  56043. format: number;
  56044. }
  56045. /**
  56046. * Configuration options for the Basis transcoder
  56047. */
  56048. export class BasisTranscodeConfiguration {
  56049. /**
  56050. * Supported compression formats used to determine the supported output format of the transcoder
  56051. */
  56052. supportedCompressionFormats?: {
  56053. /**
  56054. * etc1 compression format
  56055. */
  56056. etc1?: boolean;
  56057. /**
  56058. * s3tc compression format
  56059. */
  56060. s3tc?: boolean;
  56061. /**
  56062. * pvrtc compression format
  56063. */
  56064. pvrtc?: boolean;
  56065. /**
  56066. * etc2 compression format
  56067. */
  56068. etc2?: boolean;
  56069. };
  56070. /**
  56071. * If mipmap levels should be loaded for transcoded images (Default: true)
  56072. */
  56073. loadMipmapLevels?: boolean;
  56074. /**
  56075. * Index of a single image to load (Default: all images)
  56076. */
  56077. loadSingleImage?: number;
  56078. }
  56079. /**
  56080. * Used to load .Basis files
  56081. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56082. */
  56083. export class BasisTools {
  56084. private static _IgnoreSupportedFormats;
  56085. /**
  56086. * URL to use when loading the basis transcoder
  56087. */
  56088. static JSModuleURL: string;
  56089. /**
  56090. * URL to use when loading the wasm module for the transcoder
  56091. */
  56092. static WasmModuleURL: string;
  56093. /**
  56094. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56095. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56096. * @returns internal format corresponding to the Basis format
  56097. */
  56098. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56099. private static _WorkerPromise;
  56100. private static _Worker;
  56101. private static _actionId;
  56102. private static _CreateWorkerAsync;
  56103. /**
  56104. * Transcodes a loaded image file to compressed pixel data
  56105. * @param data image data to transcode
  56106. * @param config configuration options for the transcoding
  56107. * @returns a promise resulting in the transcoded image
  56108. */
  56109. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56110. /**
  56111. * Loads a texture from the transcode result
  56112. * @param texture texture load to
  56113. * @param transcodeResult the result of transcoding the basis file to load from
  56114. */
  56115. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56116. }
  56117. }
  56118. declare module BABYLON {
  56119. /**
  56120. * Loader for .basis file format
  56121. */
  56122. export class _BasisTextureLoader implements IInternalTextureLoader {
  56123. /**
  56124. * Defines whether the loader supports cascade loading the different faces.
  56125. */
  56126. readonly supportCascades: boolean;
  56127. /**
  56128. * This returns if the loader support the current file information.
  56129. * @param extension defines the file extension of the file being loaded
  56130. * @returns true if the loader can load the specified file
  56131. */
  56132. canLoad(extension: string): boolean;
  56133. /**
  56134. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56135. * @param data contains the texture data
  56136. * @param texture defines the BabylonJS internal texture
  56137. * @param createPolynomials will be true if polynomials have been requested
  56138. * @param onLoad defines the callback to trigger once the texture is ready
  56139. * @param onError defines the callback to trigger in case of error
  56140. */
  56141. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56142. /**
  56143. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56144. * @param data contains the texture data
  56145. * @param texture defines the BabylonJS internal texture
  56146. * @param callback defines the method to call once ready to upload
  56147. */
  56148. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56149. }
  56150. }
  56151. declare module BABYLON {
  56152. /**
  56153. * 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.
  56154. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56155. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56156. */
  56157. export class CustomProceduralTexture extends ProceduralTexture {
  56158. private _animate;
  56159. private _time;
  56160. private _config;
  56161. private _texturePath;
  56162. /**
  56163. * Instantiates a new Custom Procedural Texture.
  56164. * 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.
  56165. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56166. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56167. * @param name Define the name of the texture
  56168. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56169. * @param size Define the size of the texture to create
  56170. * @param scene Define the scene the texture belongs to
  56171. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56172. * @param generateMipMaps Define if the texture should creates mip maps or not
  56173. */
  56174. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56175. private _loadJson;
  56176. /**
  56177. * Is the texture ready to be used ? (rendered at least once)
  56178. * @returns true if ready, otherwise, false.
  56179. */
  56180. isReady(): boolean;
  56181. /**
  56182. * Render the texture to its associated render target.
  56183. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56184. */
  56185. render(useCameraPostProcess?: boolean): void;
  56186. /**
  56187. * Update the list of dependant textures samplers in the shader.
  56188. */
  56189. updateTextures(): void;
  56190. /**
  56191. * Update the uniform values of the procedural texture in the shader.
  56192. */
  56193. updateShaderUniforms(): void;
  56194. /**
  56195. * Define if the texture animates or not.
  56196. */
  56197. get animate(): boolean;
  56198. set animate(value: boolean);
  56199. }
  56200. }
  56201. declare module BABYLON {
  56202. /** @hidden */
  56203. export var noisePixelShader: {
  56204. name: string;
  56205. shader: string;
  56206. };
  56207. }
  56208. declare module BABYLON {
  56209. /**
  56210. * Class used to generate noise procedural textures
  56211. */
  56212. export class NoiseProceduralTexture extends ProceduralTexture {
  56213. private _time;
  56214. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56215. brightness: number;
  56216. /** Defines the number of octaves to process */
  56217. octaves: number;
  56218. /** Defines the level of persistence (0.8 by default) */
  56219. persistence: number;
  56220. /** Gets or sets animation speed factor (default is 1) */
  56221. animationSpeedFactor: number;
  56222. /**
  56223. * Creates a new NoiseProceduralTexture
  56224. * @param name defines the name fo the texture
  56225. * @param size defines the size of the texture (default is 256)
  56226. * @param scene defines the hosting scene
  56227. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56228. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56229. */
  56230. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56231. private _updateShaderUniforms;
  56232. protected _getDefines(): string;
  56233. /** Generate the current state of the procedural texture */
  56234. render(useCameraPostProcess?: boolean): void;
  56235. /**
  56236. * Serializes this noise procedural texture
  56237. * @returns a serialized noise procedural texture object
  56238. */
  56239. serialize(): any;
  56240. /**
  56241. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56242. * @param parsedTexture defines parsed texture data
  56243. * @param scene defines the current scene
  56244. * @param rootUrl defines the root URL containing noise procedural texture information
  56245. * @returns a parsed NoiseProceduralTexture
  56246. */
  56247. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56248. }
  56249. }
  56250. declare module BABYLON {
  56251. /**
  56252. * Raw cube texture where the raw buffers are passed in
  56253. */
  56254. export class RawCubeTexture extends CubeTexture {
  56255. /**
  56256. * Creates a cube texture where the raw buffers are passed in.
  56257. * @param scene defines the scene the texture is attached to
  56258. * @param data defines the array of data to use to create each face
  56259. * @param size defines the size of the textures
  56260. * @param format defines the format of the data
  56261. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56262. * @param generateMipMaps defines if the engine should generate the mip levels
  56263. * @param invertY defines if data must be stored with Y axis inverted
  56264. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56265. * @param compression defines the compression used (null by default)
  56266. */
  56267. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56268. /**
  56269. * Updates the raw cube texture.
  56270. * @param data defines the data to store
  56271. * @param format defines the data format
  56272. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56273. * @param invertY defines if data must be stored with Y axis inverted
  56274. * @param compression defines the compression used (null by default)
  56275. * @param level defines which level of the texture to update
  56276. */
  56277. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56278. /**
  56279. * Updates a raw cube texture with RGBD encoded data.
  56280. * @param data defines the array of data [mipmap][face] to use to create each face
  56281. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56282. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56283. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56284. * @returns a promsie that resolves when the operation is complete
  56285. */
  56286. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56287. /**
  56288. * Clones the raw cube texture.
  56289. * @return a new cube texture
  56290. */
  56291. clone(): CubeTexture;
  56292. /** @hidden */
  56293. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56294. }
  56295. }
  56296. declare module BABYLON {
  56297. /**
  56298. * Class used to store 3D textures containing user data
  56299. */
  56300. export class RawTexture3D extends Texture {
  56301. /** Gets or sets the texture format to use */
  56302. format: number;
  56303. private _engine;
  56304. /**
  56305. * Create a new RawTexture3D
  56306. * @param data defines the data of the texture
  56307. * @param width defines the width of the texture
  56308. * @param height defines the height of the texture
  56309. * @param depth defines the depth of the texture
  56310. * @param format defines the texture format to use
  56311. * @param scene defines the hosting scene
  56312. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56313. * @param invertY defines if texture must be stored with Y axis inverted
  56314. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56315. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56316. */
  56317. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56318. /** Gets or sets the texture format to use */
  56319. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56320. /**
  56321. * Update the texture with new data
  56322. * @param data defines the data to store in the texture
  56323. */
  56324. update(data: ArrayBufferView): void;
  56325. }
  56326. }
  56327. declare module BABYLON {
  56328. /**
  56329. * Class used to store 2D array textures containing user data
  56330. */
  56331. export class RawTexture2DArray extends Texture {
  56332. /** Gets or sets the texture format to use */
  56333. format: number;
  56334. private _engine;
  56335. /**
  56336. * Create a new RawTexture2DArray
  56337. * @param data defines the data of the texture
  56338. * @param width defines the width of the texture
  56339. * @param height defines the height of the texture
  56340. * @param depth defines the number of layers of the texture
  56341. * @param format defines the texture format to use
  56342. * @param scene defines the hosting scene
  56343. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56344. * @param invertY defines if texture must be stored with Y axis inverted
  56345. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56346. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56347. */
  56348. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56349. /** Gets or sets the texture format to use */
  56350. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56351. /**
  56352. * Update the texture with new data
  56353. * @param data defines the data to store in the texture
  56354. */
  56355. update(data: ArrayBufferView): void;
  56356. }
  56357. }
  56358. declare module BABYLON {
  56359. /**
  56360. * Creates a refraction texture used by refraction channel of the standard material.
  56361. * It is like a mirror but to see through a material.
  56362. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56363. */
  56364. export class RefractionTexture extends RenderTargetTexture {
  56365. /**
  56366. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56367. * 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.
  56368. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56369. */
  56370. refractionPlane: Plane;
  56371. /**
  56372. * Define how deep under the surface we should see.
  56373. */
  56374. depth: number;
  56375. /**
  56376. * Creates a refraction texture used by refraction channel of the standard material.
  56377. * It is like a mirror but to see through a material.
  56378. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56379. * @param name Define the texture name
  56380. * @param size Define the size of the underlying texture
  56381. * @param scene Define the scene the refraction belongs to
  56382. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56383. */
  56384. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56385. /**
  56386. * Clone the refraction texture.
  56387. * @returns the cloned texture
  56388. */
  56389. clone(): RefractionTexture;
  56390. /**
  56391. * Serialize the texture to a JSON representation you could use in Parse later on
  56392. * @returns the serialized JSON representation
  56393. */
  56394. serialize(): any;
  56395. }
  56396. }
  56397. declare module BABYLON {
  56398. /**
  56399. * Defines the options related to the creation of an HtmlElementTexture
  56400. */
  56401. export interface IHtmlElementTextureOptions {
  56402. /**
  56403. * Defines wether mip maps should be created or not.
  56404. */
  56405. generateMipMaps?: boolean;
  56406. /**
  56407. * Defines the sampling mode of the texture.
  56408. */
  56409. samplingMode?: number;
  56410. /**
  56411. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56412. */
  56413. engine: Nullable<ThinEngine>;
  56414. /**
  56415. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56416. */
  56417. scene: Nullable<Scene>;
  56418. }
  56419. /**
  56420. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56421. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56422. * is automatically managed.
  56423. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56424. * in your application.
  56425. *
  56426. * As the update is not automatic, you need to call them manually.
  56427. */
  56428. export class HtmlElementTexture extends BaseTexture {
  56429. /**
  56430. * The texture URL.
  56431. */
  56432. element: HTMLVideoElement | HTMLCanvasElement;
  56433. private static readonly DefaultOptions;
  56434. private _textureMatrix;
  56435. private _engine;
  56436. private _isVideo;
  56437. private _generateMipMaps;
  56438. private _samplingMode;
  56439. /**
  56440. * Instantiates a HtmlElementTexture from the following parameters.
  56441. *
  56442. * @param name Defines the name of the texture
  56443. * @param element Defines the video or canvas the texture is filled with
  56444. * @param options Defines the other none mandatory texture creation options
  56445. */
  56446. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56447. private _createInternalTexture;
  56448. /**
  56449. * Returns the texture matrix used in most of the material.
  56450. */
  56451. getTextureMatrix(): Matrix;
  56452. /**
  56453. * Updates the content of the texture.
  56454. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56455. */
  56456. update(invertY?: Nullable<boolean>): void;
  56457. }
  56458. }
  56459. declare module BABYLON {
  56460. /**
  56461. * Defines the basic options interface of a TexturePacker Frame
  56462. */
  56463. export interface ITexturePackerFrame {
  56464. /**
  56465. * The frame ID
  56466. */
  56467. id: number;
  56468. /**
  56469. * The frames Scale
  56470. */
  56471. scale: Vector2;
  56472. /**
  56473. * The Frames offset
  56474. */
  56475. offset: Vector2;
  56476. }
  56477. /**
  56478. * This is a support class for frame Data on texture packer sets.
  56479. */
  56480. export class TexturePackerFrame implements ITexturePackerFrame {
  56481. /**
  56482. * The frame ID
  56483. */
  56484. id: number;
  56485. /**
  56486. * The frames Scale
  56487. */
  56488. scale: Vector2;
  56489. /**
  56490. * The Frames offset
  56491. */
  56492. offset: Vector2;
  56493. /**
  56494. * Initializes a texture package frame.
  56495. * @param id The numerical frame identifier
  56496. * @param scale Scalar Vector2 for UV frame
  56497. * @param offset Vector2 for the frame position in UV units.
  56498. * @returns TexturePackerFrame
  56499. */
  56500. constructor(id: number, scale: Vector2, offset: Vector2);
  56501. }
  56502. }
  56503. declare module BABYLON {
  56504. /**
  56505. * Defines the basic options interface of a TexturePacker
  56506. */
  56507. export interface ITexturePackerOptions {
  56508. /**
  56509. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56510. */
  56511. map?: string[];
  56512. /**
  56513. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56514. */
  56515. uvsIn?: string;
  56516. /**
  56517. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56518. */
  56519. uvsOut?: string;
  56520. /**
  56521. * number representing the layout style. Defaults to LAYOUT_STRIP
  56522. */
  56523. layout?: number;
  56524. /**
  56525. * number of columns if using custom column count layout(2). This defaults to 4.
  56526. */
  56527. colnum?: number;
  56528. /**
  56529. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56530. */
  56531. updateInputMeshes?: boolean;
  56532. /**
  56533. * boolean flag to dispose all the source textures. Defaults to true.
  56534. */
  56535. disposeSources?: boolean;
  56536. /**
  56537. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56538. */
  56539. fillBlanks?: boolean;
  56540. /**
  56541. * string value representing the context fill style color. Defaults to 'black'.
  56542. */
  56543. customFillColor?: string;
  56544. /**
  56545. * Width and Height Value of each Frame in the TexturePacker Sets
  56546. */
  56547. frameSize?: number;
  56548. /**
  56549. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56550. */
  56551. paddingRatio?: number;
  56552. /**
  56553. * Number that declares the fill method for the padding gutter.
  56554. */
  56555. paddingMode?: number;
  56556. /**
  56557. * If in SUBUV_COLOR padding mode what color to use.
  56558. */
  56559. paddingColor?: Color3 | Color4;
  56560. }
  56561. /**
  56562. * Defines the basic interface of a TexturePacker JSON File
  56563. */
  56564. export interface ITexturePackerJSON {
  56565. /**
  56566. * The frame ID
  56567. */
  56568. name: string;
  56569. /**
  56570. * The base64 channel data
  56571. */
  56572. sets: any;
  56573. /**
  56574. * The options of the Packer
  56575. */
  56576. options: ITexturePackerOptions;
  56577. /**
  56578. * The frame data of the Packer
  56579. */
  56580. frames: Array<number>;
  56581. }
  56582. /**
  56583. * This is a support class that generates a series of packed texture sets.
  56584. * @see https://doc.babylonjs.com/babylon101/materials
  56585. */
  56586. export class TexturePacker {
  56587. /** Packer Layout Constant 0 */
  56588. static readonly LAYOUT_STRIP: number;
  56589. /** Packer Layout Constant 1 */
  56590. static readonly LAYOUT_POWER2: number;
  56591. /** Packer Layout Constant 2 */
  56592. static readonly LAYOUT_COLNUM: number;
  56593. /** Packer Layout Constant 0 */
  56594. static readonly SUBUV_WRAP: number;
  56595. /** Packer Layout Constant 1 */
  56596. static readonly SUBUV_EXTEND: number;
  56597. /** Packer Layout Constant 2 */
  56598. static readonly SUBUV_COLOR: number;
  56599. /** The Name of the Texture Package */
  56600. name: string;
  56601. /** The scene scope of the TexturePacker */
  56602. scene: Scene;
  56603. /** The Meshes to target */
  56604. meshes: AbstractMesh[];
  56605. /** Arguments passed with the Constructor */
  56606. options: ITexturePackerOptions;
  56607. /** The promise that is started upon initialization */
  56608. promise: Nullable<Promise<TexturePacker | string>>;
  56609. /** The Container object for the channel sets that are generated */
  56610. sets: object;
  56611. /** The Container array for the frames that are generated */
  56612. frames: TexturePackerFrame[];
  56613. /** The expected number of textures the system is parsing. */
  56614. private _expecting;
  56615. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56616. private _paddingValue;
  56617. /**
  56618. * Initializes a texture package series from an array of meshes or a single mesh.
  56619. * @param name The name of the package
  56620. * @param meshes The target meshes to compose the package from
  56621. * @param options The arguments that texture packer should follow while building.
  56622. * @param scene The scene which the textures are scoped to.
  56623. * @returns TexturePacker
  56624. */
  56625. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56626. /**
  56627. * Starts the package process
  56628. * @param resolve The promises resolution function
  56629. * @returns TexturePacker
  56630. */
  56631. private _createFrames;
  56632. /**
  56633. * Calculates the Size of the Channel Sets
  56634. * @returns Vector2
  56635. */
  56636. private _calculateSize;
  56637. /**
  56638. * Calculates the UV data for the frames.
  56639. * @param baseSize the base frameSize
  56640. * @param padding the base frame padding
  56641. * @param dtSize size of the Dynamic Texture for that channel
  56642. * @param dtUnits is 1/dtSize
  56643. * @param update flag to update the input meshes
  56644. */
  56645. private _calculateMeshUVFrames;
  56646. /**
  56647. * Calculates the frames Offset.
  56648. * @param index of the frame
  56649. * @returns Vector2
  56650. */
  56651. private _getFrameOffset;
  56652. /**
  56653. * Updates a Mesh to the frame data
  56654. * @param mesh that is the target
  56655. * @param frameID or the frame index
  56656. */
  56657. private _updateMeshUV;
  56658. /**
  56659. * Updates a Meshes materials to use the texture packer channels
  56660. * @param m is the mesh to target
  56661. * @param force all channels on the packer to be set.
  56662. */
  56663. private _updateTextureReferences;
  56664. /**
  56665. * Public method to set a Mesh to a frame
  56666. * @param m that is the target
  56667. * @param frameID or the frame index
  56668. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56669. */
  56670. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56671. /**
  56672. * Starts the async promise to compile the texture packer.
  56673. * @returns Promise<void>
  56674. */
  56675. processAsync(): Promise<void>;
  56676. /**
  56677. * Disposes all textures associated with this packer
  56678. */
  56679. dispose(): void;
  56680. /**
  56681. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56682. * @param imageType is the image type to use.
  56683. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56684. */
  56685. download(imageType?: string, quality?: number): void;
  56686. /**
  56687. * Public method to load a texturePacker JSON file.
  56688. * @param data of the JSON file in string format.
  56689. */
  56690. updateFromJSON(data: string): void;
  56691. }
  56692. }
  56693. declare module BABYLON {
  56694. /**
  56695. * Enum used to define the target of a block
  56696. */
  56697. export enum NodeMaterialBlockTargets {
  56698. /** Vertex shader */
  56699. Vertex = 1,
  56700. /** Fragment shader */
  56701. Fragment = 2,
  56702. /** Neutral */
  56703. Neutral = 4,
  56704. /** Vertex and Fragment */
  56705. VertexAndFragment = 3
  56706. }
  56707. }
  56708. declare module BABYLON {
  56709. /**
  56710. * Defines the kind of connection point for node based material
  56711. */
  56712. export enum NodeMaterialBlockConnectionPointTypes {
  56713. /** Float */
  56714. Float = 1,
  56715. /** Int */
  56716. Int = 2,
  56717. /** Vector2 */
  56718. Vector2 = 4,
  56719. /** Vector3 */
  56720. Vector3 = 8,
  56721. /** Vector4 */
  56722. Vector4 = 16,
  56723. /** Color3 */
  56724. Color3 = 32,
  56725. /** Color4 */
  56726. Color4 = 64,
  56727. /** Matrix */
  56728. Matrix = 128,
  56729. /** Detect type based on connection */
  56730. AutoDetect = 1024,
  56731. /** Output type that will be defined by input type */
  56732. BasedOnInput = 2048
  56733. }
  56734. }
  56735. declare module BABYLON {
  56736. /**
  56737. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56738. */
  56739. export enum NodeMaterialBlockConnectionPointMode {
  56740. /** Value is an uniform */
  56741. Uniform = 0,
  56742. /** Value is a mesh attribute */
  56743. Attribute = 1,
  56744. /** Value is a varying between vertex and fragment shaders */
  56745. Varying = 2,
  56746. /** Mode is undefined */
  56747. Undefined = 3
  56748. }
  56749. }
  56750. declare module BABYLON {
  56751. /**
  56752. * Enum used to define system values e.g. values automatically provided by the system
  56753. */
  56754. export enum NodeMaterialSystemValues {
  56755. /** World */
  56756. World = 1,
  56757. /** View */
  56758. View = 2,
  56759. /** Projection */
  56760. Projection = 3,
  56761. /** ViewProjection */
  56762. ViewProjection = 4,
  56763. /** WorldView */
  56764. WorldView = 5,
  56765. /** WorldViewProjection */
  56766. WorldViewProjection = 6,
  56767. /** CameraPosition */
  56768. CameraPosition = 7,
  56769. /** Fog Color */
  56770. FogColor = 8,
  56771. /** Delta time */
  56772. DeltaTime = 9
  56773. }
  56774. }
  56775. declare module BABYLON {
  56776. /**
  56777. * Root class for all node material optimizers
  56778. */
  56779. export class NodeMaterialOptimizer {
  56780. /**
  56781. * Function used to optimize a NodeMaterial graph
  56782. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56783. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56784. */
  56785. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56786. }
  56787. }
  56788. declare module BABYLON {
  56789. /**
  56790. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56791. */
  56792. export class TransformBlock extends NodeMaterialBlock {
  56793. /**
  56794. * Defines the value to use to complement W value to transform it to a Vector4
  56795. */
  56796. complementW: number;
  56797. /**
  56798. * Defines the value to use to complement z value to transform it to a Vector4
  56799. */
  56800. complementZ: number;
  56801. /**
  56802. * Creates a new TransformBlock
  56803. * @param name defines the block name
  56804. */
  56805. constructor(name: string);
  56806. /**
  56807. * Gets the current class name
  56808. * @returns the class name
  56809. */
  56810. getClassName(): string;
  56811. /**
  56812. * Gets the vector input
  56813. */
  56814. get vector(): NodeMaterialConnectionPoint;
  56815. /**
  56816. * Gets the output component
  56817. */
  56818. get output(): NodeMaterialConnectionPoint;
  56819. /**
  56820. * Gets the xyz output component
  56821. */
  56822. get xyz(): NodeMaterialConnectionPoint;
  56823. /**
  56824. * Gets the matrix transform input
  56825. */
  56826. get transform(): NodeMaterialConnectionPoint;
  56827. protected _buildBlock(state: NodeMaterialBuildState): this;
  56828. serialize(): any;
  56829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56830. protected _dumpPropertiesCode(): string;
  56831. }
  56832. }
  56833. declare module BABYLON {
  56834. /**
  56835. * Block used to output the vertex position
  56836. */
  56837. export class VertexOutputBlock extends NodeMaterialBlock {
  56838. /**
  56839. * Creates a new VertexOutputBlock
  56840. * @param name defines the block name
  56841. */
  56842. constructor(name: string);
  56843. /**
  56844. * Gets the current class name
  56845. * @returns the class name
  56846. */
  56847. getClassName(): string;
  56848. /**
  56849. * Gets the vector input component
  56850. */
  56851. get vector(): NodeMaterialConnectionPoint;
  56852. protected _buildBlock(state: NodeMaterialBuildState): this;
  56853. }
  56854. }
  56855. declare module BABYLON {
  56856. /**
  56857. * Block used to output the final color
  56858. */
  56859. export class FragmentOutputBlock extends NodeMaterialBlock {
  56860. /**
  56861. * Create a new FragmentOutputBlock
  56862. * @param name defines the block name
  56863. */
  56864. constructor(name: string);
  56865. /**
  56866. * Gets the current class name
  56867. * @returns the class name
  56868. */
  56869. getClassName(): string;
  56870. /**
  56871. * Gets the rgba input component
  56872. */
  56873. get rgba(): NodeMaterialConnectionPoint;
  56874. /**
  56875. * Gets the rgb input component
  56876. */
  56877. get rgb(): NodeMaterialConnectionPoint;
  56878. /**
  56879. * Gets the a input component
  56880. */
  56881. get a(): NodeMaterialConnectionPoint;
  56882. protected _buildBlock(state: NodeMaterialBuildState): this;
  56883. }
  56884. }
  56885. declare module BABYLON {
  56886. /**
  56887. * Block used to read a reflection texture from a sampler
  56888. */
  56889. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56890. private _define3DName;
  56891. private _defineCubicName;
  56892. private _defineExplicitName;
  56893. private _defineProjectionName;
  56894. private _defineLocalCubicName;
  56895. private _defineSphericalName;
  56896. private _definePlanarName;
  56897. private _defineEquirectangularName;
  56898. private _defineMirroredEquirectangularFixedName;
  56899. private _defineEquirectangularFixedName;
  56900. private _defineSkyboxName;
  56901. private _cubeSamplerName;
  56902. private _2DSamplerName;
  56903. private _positionUVWName;
  56904. private _directionWName;
  56905. private _reflectionCoordsName;
  56906. private _reflection2DCoordsName;
  56907. private _reflectionColorName;
  56908. private _reflectionMatrixName;
  56909. /**
  56910. * Gets or sets the texture associated with the node
  56911. */
  56912. texture: Nullable<BaseTexture>;
  56913. /**
  56914. * Create a new TextureBlock
  56915. * @param name defines the block name
  56916. */
  56917. constructor(name: string);
  56918. /**
  56919. * Gets the current class name
  56920. * @returns the class name
  56921. */
  56922. getClassName(): string;
  56923. /**
  56924. * Gets the world position input component
  56925. */
  56926. get position(): NodeMaterialConnectionPoint;
  56927. /**
  56928. * Gets the world position input component
  56929. */
  56930. get worldPosition(): NodeMaterialConnectionPoint;
  56931. /**
  56932. * Gets the world normal input component
  56933. */
  56934. get worldNormal(): NodeMaterialConnectionPoint;
  56935. /**
  56936. * Gets the world input component
  56937. */
  56938. get world(): NodeMaterialConnectionPoint;
  56939. /**
  56940. * Gets the camera (or eye) position component
  56941. */
  56942. get cameraPosition(): NodeMaterialConnectionPoint;
  56943. /**
  56944. * Gets the view input component
  56945. */
  56946. get view(): NodeMaterialConnectionPoint;
  56947. /**
  56948. * Gets the rgb output component
  56949. */
  56950. get rgb(): NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the r output component
  56953. */
  56954. get r(): NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the g output component
  56957. */
  56958. get g(): NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the b output component
  56961. */
  56962. get b(): NodeMaterialConnectionPoint;
  56963. autoConfigure(material: NodeMaterial): void;
  56964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56965. isReady(): boolean;
  56966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56967. private _injectVertexCode;
  56968. private _writeOutput;
  56969. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56970. protected _dumpPropertiesCode(): string;
  56971. serialize(): any;
  56972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56973. }
  56974. }
  56975. declare module BABYLON {
  56976. /**
  56977. * Interface used to configure the node material editor
  56978. */
  56979. export interface INodeMaterialEditorOptions {
  56980. /** Define the URl to load node editor script */
  56981. editorURL?: string;
  56982. }
  56983. /** @hidden */
  56984. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56985. NORMAL: boolean;
  56986. TANGENT: boolean;
  56987. UV1: boolean;
  56988. /** BONES */
  56989. NUM_BONE_INFLUENCERS: number;
  56990. BonesPerMesh: number;
  56991. BONETEXTURE: boolean;
  56992. /** MORPH TARGETS */
  56993. MORPHTARGETS: boolean;
  56994. MORPHTARGETS_NORMAL: boolean;
  56995. MORPHTARGETS_TANGENT: boolean;
  56996. MORPHTARGETS_UV: boolean;
  56997. NUM_MORPH_INFLUENCERS: number;
  56998. /** IMAGE PROCESSING */
  56999. IMAGEPROCESSING: boolean;
  57000. VIGNETTE: boolean;
  57001. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57002. VIGNETTEBLENDMODEOPAQUE: boolean;
  57003. TONEMAPPING: boolean;
  57004. TONEMAPPING_ACES: boolean;
  57005. CONTRAST: boolean;
  57006. EXPOSURE: boolean;
  57007. COLORCURVES: boolean;
  57008. COLORGRADING: boolean;
  57009. COLORGRADING3D: boolean;
  57010. SAMPLER3DGREENDEPTH: boolean;
  57011. SAMPLER3DBGRMAP: boolean;
  57012. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57013. /** MISC. */
  57014. BUMPDIRECTUV: number;
  57015. constructor();
  57016. setValue(name: string, value: boolean): void;
  57017. }
  57018. /**
  57019. * Class used to configure NodeMaterial
  57020. */
  57021. export interface INodeMaterialOptions {
  57022. /**
  57023. * Defines if blocks should emit comments
  57024. */
  57025. emitComments: boolean;
  57026. }
  57027. /**
  57028. * Class used to create a node based material built by assembling shader blocks
  57029. */
  57030. export class NodeMaterial extends PushMaterial {
  57031. private static _BuildIdGenerator;
  57032. private _options;
  57033. private _vertexCompilationState;
  57034. private _fragmentCompilationState;
  57035. private _sharedData;
  57036. private _buildId;
  57037. private _buildWasSuccessful;
  57038. private _cachedWorldViewMatrix;
  57039. private _cachedWorldViewProjectionMatrix;
  57040. private _optimizers;
  57041. private _animationFrame;
  57042. /** Define the Url to load node editor script */
  57043. static EditorURL: string;
  57044. /** Define the Url to load snippets */
  57045. static SnippetUrl: string;
  57046. private BJSNODEMATERIALEDITOR;
  57047. /** Get the inspector from bundle or global */
  57048. private _getGlobalNodeMaterialEditor;
  57049. /**
  57050. * Gets or sets data used by visual editor
  57051. * @see https://nme.babylonjs.com
  57052. */
  57053. editorData: any;
  57054. /**
  57055. * 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)
  57056. */
  57057. ignoreAlpha: boolean;
  57058. /**
  57059. * Defines the maximum number of lights that can be used in the material
  57060. */
  57061. maxSimultaneousLights: number;
  57062. /**
  57063. * Observable raised when the material is built
  57064. */
  57065. onBuildObservable: Observable<NodeMaterial>;
  57066. /**
  57067. * Gets or sets the root nodes of the material vertex shader
  57068. */
  57069. _vertexOutputNodes: NodeMaterialBlock[];
  57070. /**
  57071. * Gets or sets the root nodes of the material fragment (pixel) shader
  57072. */
  57073. _fragmentOutputNodes: NodeMaterialBlock[];
  57074. /** Gets or sets options to control the node material overall behavior */
  57075. get options(): INodeMaterialOptions;
  57076. set options(options: INodeMaterialOptions);
  57077. /**
  57078. * Default configuration related to image processing available in the standard Material.
  57079. */
  57080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57081. /**
  57082. * Gets the image processing configuration used either in this material.
  57083. */
  57084. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57085. /**
  57086. * Sets the Default image processing configuration used either in the this material.
  57087. *
  57088. * If sets to null, the scene one is in use.
  57089. */
  57090. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57091. /**
  57092. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57093. */
  57094. attachedBlocks: NodeMaterialBlock[];
  57095. /**
  57096. * Create a new node based material
  57097. * @param name defines the material name
  57098. * @param scene defines the hosting scene
  57099. * @param options defines creation option
  57100. */
  57101. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57102. /**
  57103. * Gets the current class name of the material e.g. "NodeMaterial"
  57104. * @returns the class name
  57105. */
  57106. getClassName(): string;
  57107. /**
  57108. * Keep track of the image processing observer to allow dispose and replace.
  57109. */
  57110. private _imageProcessingObserver;
  57111. /**
  57112. * Attaches a new image processing configuration to the Standard Material.
  57113. * @param configuration
  57114. */
  57115. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57116. /**
  57117. * Get a block by its name
  57118. * @param name defines the name of the block to retrieve
  57119. * @returns the required block or null if not found
  57120. */
  57121. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57122. /**
  57123. * Get a block by its name
  57124. * @param predicate defines the predicate used to find the good candidate
  57125. * @returns the required block or null if not found
  57126. */
  57127. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57128. /**
  57129. * Get an input block by its name
  57130. * @param predicate defines the predicate used to find the good candidate
  57131. * @returns the required input block or null if not found
  57132. */
  57133. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57134. /**
  57135. * Gets the list of input blocks attached to this material
  57136. * @returns an array of InputBlocks
  57137. */
  57138. getInputBlocks(): InputBlock[];
  57139. /**
  57140. * Adds a new optimizer to the list of optimizers
  57141. * @param optimizer defines the optimizers to add
  57142. * @returns the current material
  57143. */
  57144. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57145. /**
  57146. * Remove an optimizer from the list of optimizers
  57147. * @param optimizer defines the optimizers to remove
  57148. * @returns the current material
  57149. */
  57150. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57151. /**
  57152. * Add a new block to the list of output nodes
  57153. * @param node defines the node to add
  57154. * @returns the current material
  57155. */
  57156. addOutputNode(node: NodeMaterialBlock): this;
  57157. /**
  57158. * Remove a block from the list of root nodes
  57159. * @param node defines the node to remove
  57160. * @returns the current material
  57161. */
  57162. removeOutputNode(node: NodeMaterialBlock): this;
  57163. private _addVertexOutputNode;
  57164. private _removeVertexOutputNode;
  57165. private _addFragmentOutputNode;
  57166. private _removeFragmentOutputNode;
  57167. /**
  57168. * Specifies if the material will require alpha blending
  57169. * @returns a boolean specifying if alpha blending is needed
  57170. */
  57171. needAlphaBlending(): boolean;
  57172. /**
  57173. * Specifies if this material should be rendered in alpha test mode
  57174. * @returns a boolean specifying if an alpha test is needed.
  57175. */
  57176. needAlphaTesting(): boolean;
  57177. private _initializeBlock;
  57178. private _resetDualBlocks;
  57179. /**
  57180. * Remove a block from the current node material
  57181. * @param block defines the block to remove
  57182. */
  57183. removeBlock(block: NodeMaterialBlock): void;
  57184. /**
  57185. * Build the material and generates the inner effect
  57186. * @param verbose defines if the build should log activity
  57187. */
  57188. build(verbose?: boolean): void;
  57189. /**
  57190. * Runs an otpimization phase to try to improve the shader code
  57191. */
  57192. optimize(): void;
  57193. private _prepareDefinesForAttributes;
  57194. /**
  57195. * Get if the submesh is ready to be used and all its information available.
  57196. * Child classes can use it to update shaders
  57197. * @param mesh defines the mesh to check
  57198. * @param subMesh defines which submesh to check
  57199. * @param useInstances specifies that instances should be used
  57200. * @returns a boolean indicating that the submesh is ready or not
  57201. */
  57202. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57203. /**
  57204. * Get a string representing the shaders built by the current node graph
  57205. */
  57206. get compiledShaders(): string;
  57207. /**
  57208. * Binds the world matrix to the material
  57209. * @param world defines the world transformation matrix
  57210. */
  57211. bindOnlyWorldMatrix(world: Matrix): void;
  57212. /**
  57213. * Binds the submesh to this material by preparing the effect and shader to draw
  57214. * @param world defines the world transformation matrix
  57215. * @param mesh defines the mesh containing the submesh
  57216. * @param subMesh defines the submesh to bind the material to
  57217. */
  57218. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57219. /**
  57220. * Gets the active textures from the material
  57221. * @returns an array of textures
  57222. */
  57223. getActiveTextures(): BaseTexture[];
  57224. /**
  57225. * Gets the list of texture blocks
  57226. * @returns an array of texture blocks
  57227. */
  57228. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57229. /**
  57230. * Specifies if the material uses a texture
  57231. * @param texture defines the texture to check against the material
  57232. * @returns a boolean specifying if the material uses the texture
  57233. */
  57234. hasTexture(texture: BaseTexture): boolean;
  57235. /**
  57236. * Disposes the material
  57237. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57238. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57239. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57240. */
  57241. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57242. /** Creates the node editor window. */
  57243. private _createNodeEditor;
  57244. /**
  57245. * Launch the node material editor
  57246. * @param config Define the configuration of the editor
  57247. * @return a promise fulfilled when the node editor is visible
  57248. */
  57249. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57250. /**
  57251. * Clear the current material
  57252. */
  57253. clear(): void;
  57254. /**
  57255. * Clear the current material and set it to a default state
  57256. */
  57257. setToDefault(): void;
  57258. /**
  57259. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57260. * @param url defines the url to load from
  57261. * @returns a promise that will fullfil when the material is fully loaded
  57262. */
  57263. loadAsync(url: string): Promise<void>;
  57264. private _gatherBlocks;
  57265. /**
  57266. * Generate a string containing the code declaration required to create an equivalent of this material
  57267. * @returns a string
  57268. */
  57269. generateCode(): string;
  57270. /**
  57271. * Serializes this material in a JSON representation
  57272. * @returns the serialized material object
  57273. */
  57274. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57275. private _restoreConnections;
  57276. /**
  57277. * Clear the current graph and load a new one from a serialization object
  57278. * @param source defines the JSON representation of the material
  57279. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57280. */
  57281. loadFromSerialization(source: any, rootUrl?: string): void;
  57282. /**
  57283. * Creates a node material from parsed material data
  57284. * @param source defines the JSON representation of the material
  57285. * @param scene defines the hosting scene
  57286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57287. * @returns a new node material
  57288. */
  57289. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57290. /**
  57291. * Creates a node material from a snippet saved in a remote file
  57292. * @param name defines the name of the material to create
  57293. * @param url defines the url to load from
  57294. * @param scene defines the hosting scene
  57295. * @returns a promise that will resolve to the new node material
  57296. */
  57297. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57298. /**
  57299. * Creates a node material from a snippet saved by the node material editor
  57300. * @param snippetId defines the snippet to load
  57301. * @param scene defines the hosting scene
  57302. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57303. * @returns a promise that will resolve to the new node material
  57304. */
  57305. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57306. /**
  57307. * Creates a new node material set to default basic configuration
  57308. * @param name defines the name of the material
  57309. * @param scene defines the hosting scene
  57310. * @returns a new NodeMaterial
  57311. */
  57312. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57313. }
  57314. }
  57315. declare module BABYLON {
  57316. /**
  57317. * Block used to read a texture from a sampler
  57318. */
  57319. export class TextureBlock extends NodeMaterialBlock {
  57320. private _defineName;
  57321. private _linearDefineName;
  57322. private _tempTextureRead;
  57323. private _samplerName;
  57324. private _transformedUVName;
  57325. private _textureTransformName;
  57326. private _textureInfoName;
  57327. private _mainUVName;
  57328. private _mainUVDefineName;
  57329. /**
  57330. * Gets or sets the texture associated with the node
  57331. */
  57332. texture: Nullable<Texture>;
  57333. /**
  57334. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57335. */
  57336. convertToGammaSpace: boolean;
  57337. /**
  57338. * Create a new TextureBlock
  57339. * @param name defines the block name
  57340. */
  57341. constructor(name: string);
  57342. /**
  57343. * Gets the current class name
  57344. * @returns the class name
  57345. */
  57346. getClassName(): string;
  57347. /**
  57348. * Gets the uv input component
  57349. */
  57350. get uv(): NodeMaterialConnectionPoint;
  57351. /**
  57352. * Gets the rgba output component
  57353. */
  57354. get rgba(): NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the rgb output component
  57357. */
  57358. get rgb(): NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the r output component
  57361. */
  57362. get r(): NodeMaterialConnectionPoint;
  57363. /**
  57364. * Gets the g output component
  57365. */
  57366. get g(): NodeMaterialConnectionPoint;
  57367. /**
  57368. * Gets the b output component
  57369. */
  57370. get b(): NodeMaterialConnectionPoint;
  57371. /**
  57372. * Gets the a output component
  57373. */
  57374. get a(): NodeMaterialConnectionPoint;
  57375. get target(): NodeMaterialBlockTargets;
  57376. autoConfigure(material: NodeMaterial): void;
  57377. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57378. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57379. isReady(): boolean;
  57380. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57381. private get _isMixed();
  57382. private _injectVertexCode;
  57383. private _writeTextureRead;
  57384. private _writeOutput;
  57385. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57386. protected _dumpPropertiesCode(): string;
  57387. serialize(): any;
  57388. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57389. }
  57390. }
  57391. declare module BABYLON {
  57392. /**
  57393. * Class used to store shared data between 2 NodeMaterialBuildState
  57394. */
  57395. export class NodeMaterialBuildStateSharedData {
  57396. /**
  57397. * Gets the list of emitted varyings
  57398. */
  57399. temps: string[];
  57400. /**
  57401. * Gets the list of emitted varyings
  57402. */
  57403. varyings: string[];
  57404. /**
  57405. * Gets the varying declaration string
  57406. */
  57407. varyingDeclaration: string;
  57408. /**
  57409. * Input blocks
  57410. */
  57411. inputBlocks: InputBlock[];
  57412. /**
  57413. * Input blocks
  57414. */
  57415. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57416. /**
  57417. * Bindable blocks (Blocks that need to set data to the effect)
  57418. */
  57419. bindableBlocks: NodeMaterialBlock[];
  57420. /**
  57421. * List of blocks that can provide a compilation fallback
  57422. */
  57423. blocksWithFallbacks: NodeMaterialBlock[];
  57424. /**
  57425. * List of blocks that can provide a define update
  57426. */
  57427. blocksWithDefines: NodeMaterialBlock[];
  57428. /**
  57429. * List of blocks that can provide a repeatable content
  57430. */
  57431. repeatableContentBlocks: NodeMaterialBlock[];
  57432. /**
  57433. * List of blocks that can provide a dynamic list of uniforms
  57434. */
  57435. dynamicUniformBlocks: NodeMaterialBlock[];
  57436. /**
  57437. * List of blocks that can block the isReady function for the material
  57438. */
  57439. blockingBlocks: NodeMaterialBlock[];
  57440. /**
  57441. * Gets the list of animated inputs
  57442. */
  57443. animatedInputs: InputBlock[];
  57444. /**
  57445. * Build Id used to avoid multiple recompilations
  57446. */
  57447. buildId: number;
  57448. /** List of emitted variables */
  57449. variableNames: {
  57450. [key: string]: number;
  57451. };
  57452. /** List of emitted defines */
  57453. defineNames: {
  57454. [key: string]: number;
  57455. };
  57456. /** Should emit comments? */
  57457. emitComments: boolean;
  57458. /** Emit build activity */
  57459. verbose: boolean;
  57460. /** Gets or sets the hosting scene */
  57461. scene: Scene;
  57462. /**
  57463. * Gets the compilation hints emitted at compilation time
  57464. */
  57465. hints: {
  57466. needWorldViewMatrix: boolean;
  57467. needWorldViewProjectionMatrix: boolean;
  57468. needAlphaBlending: boolean;
  57469. needAlphaTesting: boolean;
  57470. };
  57471. /**
  57472. * List of compilation checks
  57473. */
  57474. checks: {
  57475. emitVertex: boolean;
  57476. emitFragment: boolean;
  57477. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57478. };
  57479. /** Creates a new shared data */
  57480. constructor();
  57481. /**
  57482. * Emits console errors and exceptions if there is a failing check
  57483. */
  57484. emitErrors(): void;
  57485. }
  57486. }
  57487. declare module BABYLON {
  57488. /**
  57489. * Class used to store node based material build state
  57490. */
  57491. export class NodeMaterialBuildState {
  57492. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57493. supportUniformBuffers: boolean;
  57494. /**
  57495. * Gets the list of emitted attributes
  57496. */
  57497. attributes: string[];
  57498. /**
  57499. * Gets the list of emitted uniforms
  57500. */
  57501. uniforms: string[];
  57502. /**
  57503. * Gets the list of emitted constants
  57504. */
  57505. constants: string[];
  57506. /**
  57507. * Gets the list of emitted samplers
  57508. */
  57509. samplers: string[];
  57510. /**
  57511. * Gets the list of emitted functions
  57512. */
  57513. functions: {
  57514. [key: string]: string;
  57515. };
  57516. /**
  57517. * Gets the list of emitted extensions
  57518. */
  57519. extensions: {
  57520. [key: string]: string;
  57521. };
  57522. /**
  57523. * Gets the target of the compilation state
  57524. */
  57525. target: NodeMaterialBlockTargets;
  57526. /**
  57527. * Gets the list of emitted counters
  57528. */
  57529. counters: {
  57530. [key: string]: number;
  57531. };
  57532. /**
  57533. * Shared data between multiple NodeMaterialBuildState instances
  57534. */
  57535. sharedData: NodeMaterialBuildStateSharedData;
  57536. /** @hidden */
  57537. _vertexState: NodeMaterialBuildState;
  57538. /** @hidden */
  57539. _attributeDeclaration: string;
  57540. /** @hidden */
  57541. _uniformDeclaration: string;
  57542. /** @hidden */
  57543. _constantDeclaration: string;
  57544. /** @hidden */
  57545. _samplerDeclaration: string;
  57546. /** @hidden */
  57547. _varyingTransfer: string;
  57548. private _repeatableContentAnchorIndex;
  57549. /** @hidden */
  57550. _builtCompilationString: string;
  57551. /**
  57552. * Gets the emitted compilation strings
  57553. */
  57554. compilationString: string;
  57555. /**
  57556. * Finalize the compilation strings
  57557. * @param state defines the current compilation state
  57558. */
  57559. finalize(state: NodeMaterialBuildState): void;
  57560. /** @hidden */
  57561. get _repeatableContentAnchor(): string;
  57562. /** @hidden */
  57563. _getFreeVariableName(prefix: string): string;
  57564. /** @hidden */
  57565. _getFreeDefineName(prefix: string): string;
  57566. /** @hidden */
  57567. _excludeVariableName(name: string): void;
  57568. /** @hidden */
  57569. _emit2DSampler(name: string): void;
  57570. /** @hidden */
  57571. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57572. /** @hidden */
  57573. _emitExtension(name: string, extension: string): void;
  57574. /** @hidden */
  57575. _emitFunction(name: string, code: string, comments: string): void;
  57576. /** @hidden */
  57577. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57578. replaceStrings?: {
  57579. search: RegExp;
  57580. replace: string;
  57581. }[];
  57582. repeatKey?: string;
  57583. }): string;
  57584. /** @hidden */
  57585. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57586. repeatKey?: string;
  57587. removeAttributes?: boolean;
  57588. removeUniforms?: boolean;
  57589. removeVaryings?: boolean;
  57590. removeIfDef?: boolean;
  57591. replaceStrings?: {
  57592. search: RegExp;
  57593. replace: string;
  57594. }[];
  57595. }, storeKey?: string): void;
  57596. /** @hidden */
  57597. _registerTempVariable(name: string): boolean;
  57598. /** @hidden */
  57599. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57600. /** @hidden */
  57601. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57602. /** @hidden */
  57603. _emitFloat(value: number): string;
  57604. }
  57605. }
  57606. declare module BABYLON {
  57607. /**
  57608. * Defines a block that can be used inside a node based material
  57609. */
  57610. export class NodeMaterialBlock {
  57611. private _buildId;
  57612. private _buildTarget;
  57613. private _target;
  57614. private _isFinalMerger;
  57615. private _isInput;
  57616. protected _isUnique: boolean;
  57617. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57618. inputsAreExclusive: boolean;
  57619. /** @hidden */
  57620. _codeVariableName: string;
  57621. /** @hidden */
  57622. _inputs: NodeMaterialConnectionPoint[];
  57623. /** @hidden */
  57624. _outputs: NodeMaterialConnectionPoint[];
  57625. /** @hidden */
  57626. _preparationId: number;
  57627. /**
  57628. * Gets or sets the name of the block
  57629. */
  57630. name: string;
  57631. /**
  57632. * Gets or sets the unique id of the node
  57633. */
  57634. uniqueId: number;
  57635. /**
  57636. * Gets or sets the comments associated with this block
  57637. */
  57638. comments: string;
  57639. /**
  57640. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57641. */
  57642. get isUnique(): boolean;
  57643. /**
  57644. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57645. */
  57646. get isFinalMerger(): boolean;
  57647. /**
  57648. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57649. */
  57650. get isInput(): boolean;
  57651. /**
  57652. * Gets or sets the build Id
  57653. */
  57654. get buildId(): number;
  57655. set buildId(value: number);
  57656. /**
  57657. * Gets or sets the target of the block
  57658. */
  57659. get target(): NodeMaterialBlockTargets;
  57660. set target(value: NodeMaterialBlockTargets);
  57661. /**
  57662. * Gets the list of input points
  57663. */
  57664. get inputs(): NodeMaterialConnectionPoint[];
  57665. /** Gets the list of output points */
  57666. get outputs(): NodeMaterialConnectionPoint[];
  57667. /**
  57668. * Find an input by its name
  57669. * @param name defines the name of the input to look for
  57670. * @returns the input or null if not found
  57671. */
  57672. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57673. /**
  57674. * Find an output by its name
  57675. * @param name defines the name of the outputto look for
  57676. * @returns the output or null if not found
  57677. */
  57678. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57679. /**
  57680. * Creates a new NodeMaterialBlock
  57681. * @param name defines the block name
  57682. * @param target defines the target of that block (Vertex by default)
  57683. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57684. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57685. */
  57686. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57687. /**
  57688. * Initialize the block and prepare the context for build
  57689. * @param state defines the state that will be used for the build
  57690. */
  57691. initialize(state: NodeMaterialBuildState): void;
  57692. /**
  57693. * Bind data to effect. Will only be called for blocks with isBindable === true
  57694. * @param effect defines the effect to bind data to
  57695. * @param nodeMaterial defines the hosting NodeMaterial
  57696. * @param mesh defines the mesh that will be rendered
  57697. */
  57698. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57699. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57700. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57701. protected _writeFloat(value: number): string;
  57702. /**
  57703. * Gets the current class name e.g. "NodeMaterialBlock"
  57704. * @returns the class name
  57705. */
  57706. getClassName(): string;
  57707. /**
  57708. * Register a new input. Must be called inside a block constructor
  57709. * @param name defines the connection point name
  57710. * @param type defines the connection point type
  57711. * @param isOptional defines a boolean indicating that this input can be omitted
  57712. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57713. * @returns the current block
  57714. */
  57715. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57716. /**
  57717. * Register a new output. Must be called inside a block constructor
  57718. * @param name defines the connection point name
  57719. * @param type defines the connection point type
  57720. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57721. * @returns the current block
  57722. */
  57723. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57724. /**
  57725. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57726. * @param forOutput defines an optional connection point to check compatibility with
  57727. * @returns the first available input or null
  57728. */
  57729. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57730. /**
  57731. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57732. * @param forBlock defines an optional block to check compatibility with
  57733. * @returns the first available input or null
  57734. */
  57735. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57736. /**
  57737. * Gets the sibling of the given output
  57738. * @param current defines the current output
  57739. * @returns the next output in the list or null
  57740. */
  57741. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57742. /**
  57743. * Connect current block with another block
  57744. * @param other defines the block to connect with
  57745. * @param options define the various options to help pick the right connections
  57746. * @returns the current block
  57747. */
  57748. connectTo(other: NodeMaterialBlock, options?: {
  57749. input?: string;
  57750. output?: string;
  57751. outputSwizzle?: string;
  57752. }): this | undefined;
  57753. protected _buildBlock(state: NodeMaterialBuildState): void;
  57754. /**
  57755. * Add uniforms, samplers and uniform buffers at compilation time
  57756. * @param state defines the state to update
  57757. * @param nodeMaterial defines the node material requesting the update
  57758. * @param defines defines the material defines to update
  57759. * @param uniformBuffers defines the list of uniform buffer names
  57760. */
  57761. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57762. /**
  57763. * Add potential fallbacks if shader compilation fails
  57764. * @param mesh defines the mesh to be rendered
  57765. * @param fallbacks defines the current prioritized list of fallbacks
  57766. */
  57767. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57768. /**
  57769. * Initialize defines for shader compilation
  57770. * @param mesh defines the mesh to be rendered
  57771. * @param nodeMaterial defines the node material requesting the update
  57772. * @param defines defines the material defines to update
  57773. * @param useInstances specifies that instances should be used
  57774. */
  57775. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57776. /**
  57777. * Update defines for shader compilation
  57778. * @param mesh defines the mesh to be rendered
  57779. * @param nodeMaterial defines the node material requesting the update
  57780. * @param defines defines the material defines to update
  57781. * @param useInstances specifies that instances should be used
  57782. */
  57783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57784. /**
  57785. * Lets the block try to connect some inputs automatically
  57786. * @param material defines the hosting NodeMaterial
  57787. */
  57788. autoConfigure(material: NodeMaterial): void;
  57789. /**
  57790. * Function called when a block is declared as repeatable content generator
  57791. * @param vertexShaderState defines the current compilation state for the vertex shader
  57792. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57793. * @param mesh defines the mesh to be rendered
  57794. * @param defines defines the material defines to update
  57795. */
  57796. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57797. /**
  57798. * Checks if the block is ready
  57799. * @param mesh defines the mesh to be rendered
  57800. * @param nodeMaterial defines the node material requesting the update
  57801. * @param defines defines the material defines to update
  57802. * @param useInstances specifies that instances should be used
  57803. * @returns true if the block is ready
  57804. */
  57805. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57806. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57807. private _processBuild;
  57808. /**
  57809. * Compile the current node and generate the shader code
  57810. * @param state defines the current compilation state (uniforms, samplers, current string)
  57811. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57812. * @returns true if already built
  57813. */
  57814. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57815. protected _inputRename(name: string): string;
  57816. protected _outputRename(name: string): string;
  57817. protected _dumpPropertiesCode(): string;
  57818. /** @hidden */
  57819. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57820. /** @hidden */
  57821. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57822. /**
  57823. * Clone the current block to a new identical block
  57824. * @param scene defines the hosting scene
  57825. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57826. * @returns a copy of the current block
  57827. */
  57828. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57829. /**
  57830. * Serializes this block in a JSON representation
  57831. * @returns the serialized block object
  57832. */
  57833. serialize(): any;
  57834. /** @hidden */
  57835. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57836. /**
  57837. * Release resources
  57838. */
  57839. dispose(): void;
  57840. }
  57841. }
  57842. declare module BABYLON {
  57843. /**
  57844. * Enum defining the type of animations supported by InputBlock
  57845. */
  57846. export enum AnimatedInputBlockTypes {
  57847. /** No animation */
  57848. None = 0,
  57849. /** Time based animation. Will only work for floats */
  57850. Time = 1
  57851. }
  57852. }
  57853. declare module BABYLON {
  57854. /**
  57855. * Block used to expose an input value
  57856. */
  57857. export class InputBlock extends NodeMaterialBlock {
  57858. private _mode;
  57859. private _associatedVariableName;
  57860. private _storedValue;
  57861. private _valueCallback;
  57862. private _type;
  57863. private _animationType;
  57864. /** Gets or set a value used to limit the range of float values */
  57865. min: number;
  57866. /** Gets or set a value used to limit the range of float values */
  57867. max: number;
  57868. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57869. isBoolean: boolean;
  57870. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57871. matrixMode: number;
  57872. /** @hidden */
  57873. _systemValue: Nullable<NodeMaterialSystemValues>;
  57874. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57875. visibleInInspector: boolean;
  57876. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57877. isConstant: boolean;
  57878. /** Gets or sets the group to use to display this block in the Inspector */
  57879. groupInInspector: string;
  57880. /** Gets an observable raised when the value is changed */
  57881. onValueChangedObservable: Observable<InputBlock>;
  57882. /**
  57883. * Gets or sets the connection point type (default is float)
  57884. */
  57885. get type(): NodeMaterialBlockConnectionPointTypes;
  57886. /**
  57887. * Creates a new InputBlock
  57888. * @param name defines the block name
  57889. * @param target defines the target of that block (Vertex by default)
  57890. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57891. */
  57892. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57893. /**
  57894. * Gets the output component
  57895. */
  57896. get output(): NodeMaterialConnectionPoint;
  57897. /**
  57898. * Set the source of this connection point to a vertex attribute
  57899. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57900. * @returns the current connection point
  57901. */
  57902. setAsAttribute(attributeName?: string): InputBlock;
  57903. /**
  57904. * Set the source of this connection point to a system value
  57905. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57906. * @returns the current connection point
  57907. */
  57908. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57909. /**
  57910. * Gets or sets the value of that point.
  57911. * Please note that this value will be ignored if valueCallback is defined
  57912. */
  57913. get value(): any;
  57914. set value(value: any);
  57915. /**
  57916. * Gets or sets a callback used to get the value of that point.
  57917. * Please note that setting this value will force the connection point to ignore the value property
  57918. */
  57919. get valueCallback(): () => any;
  57920. set valueCallback(value: () => any);
  57921. /**
  57922. * Gets or sets the associated variable name in the shader
  57923. */
  57924. get associatedVariableName(): string;
  57925. set associatedVariableName(value: string);
  57926. /** Gets or sets the type of animation applied to the input */
  57927. get animationType(): AnimatedInputBlockTypes;
  57928. set animationType(value: AnimatedInputBlockTypes);
  57929. /**
  57930. * Gets a boolean indicating that this connection point not defined yet
  57931. */
  57932. get isUndefined(): boolean;
  57933. /**
  57934. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57935. * In this case the connection point name must be the name of the uniform to use.
  57936. * Can only be set on inputs
  57937. */
  57938. get isUniform(): boolean;
  57939. set isUniform(value: boolean);
  57940. /**
  57941. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57942. * In this case the connection point name must be the name of the attribute to use
  57943. * Can only be set on inputs
  57944. */
  57945. get isAttribute(): boolean;
  57946. set isAttribute(value: boolean);
  57947. /**
  57948. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57949. * Can only be set on exit points
  57950. */
  57951. get isVarying(): boolean;
  57952. set isVarying(value: boolean);
  57953. /**
  57954. * Gets a boolean indicating that the current connection point is a system value
  57955. */
  57956. get isSystemValue(): boolean;
  57957. /**
  57958. * Gets or sets the current well known value or null if not defined as a system value
  57959. */
  57960. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57961. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57962. /**
  57963. * Gets the current class name
  57964. * @returns the class name
  57965. */
  57966. getClassName(): string;
  57967. /**
  57968. * Animate the input if animationType !== None
  57969. * @param scene defines the rendering scene
  57970. */
  57971. animate(scene: Scene): void;
  57972. private _emitDefine;
  57973. initialize(state: NodeMaterialBuildState): void;
  57974. /**
  57975. * Set the input block to its default value (based on its type)
  57976. */
  57977. setDefaultValue(): void;
  57978. private _emitConstant;
  57979. private _emit;
  57980. /** @hidden */
  57981. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57982. /** @hidden */
  57983. _transmit(effect: Effect, scene: Scene): void;
  57984. protected _buildBlock(state: NodeMaterialBuildState): void;
  57985. protected _dumpPropertiesCode(): string;
  57986. dispose(): void;
  57987. serialize(): any;
  57988. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57989. }
  57990. }
  57991. declare module BABYLON {
  57992. /**
  57993. * Enum used to define the compatibility state between two connection points
  57994. */
  57995. export enum NodeMaterialConnectionPointCompatibilityStates {
  57996. /** Points are compatibles */
  57997. Compatible = 0,
  57998. /** Points are incompatible because of their types */
  57999. TypeIncompatible = 1,
  58000. /** Points are incompatible because of their targets (vertex vs fragment) */
  58001. TargetIncompatible = 2
  58002. }
  58003. /**
  58004. * Defines the direction of a connection point
  58005. */
  58006. export enum NodeMaterialConnectionPointDirection {
  58007. /** Input */
  58008. Input = 0,
  58009. /** Output */
  58010. Output = 1
  58011. }
  58012. /**
  58013. * Defines a connection point for a block
  58014. */
  58015. export class NodeMaterialConnectionPoint {
  58016. /** @hidden */
  58017. _ownerBlock: NodeMaterialBlock;
  58018. /** @hidden */
  58019. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58020. private _endpoints;
  58021. private _associatedVariableName;
  58022. private _direction;
  58023. /** @hidden */
  58024. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58025. /** @hidden */
  58026. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58027. private _type;
  58028. /** @hidden */
  58029. _enforceAssociatedVariableName: boolean;
  58030. /** Gets the direction of the point */
  58031. get direction(): NodeMaterialConnectionPointDirection;
  58032. /**
  58033. * Gets or sets the additional types supported by this connection point
  58034. */
  58035. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58036. /**
  58037. * Gets or sets the additional types excluded by this connection point
  58038. */
  58039. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58040. /**
  58041. * Observable triggered when this point is connected
  58042. */
  58043. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58044. /**
  58045. * Gets or sets the associated variable name in the shader
  58046. */
  58047. get associatedVariableName(): string;
  58048. set associatedVariableName(value: string);
  58049. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58050. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58051. /**
  58052. * Gets or sets the connection point type (default is float)
  58053. */
  58054. get type(): NodeMaterialBlockConnectionPointTypes;
  58055. set type(value: NodeMaterialBlockConnectionPointTypes);
  58056. /**
  58057. * Gets or sets the connection point name
  58058. */
  58059. name: string;
  58060. /**
  58061. * Gets or sets a boolean indicating that this connection point can be omitted
  58062. */
  58063. isOptional: boolean;
  58064. /**
  58065. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58066. */
  58067. define: string;
  58068. /** @hidden */
  58069. _prioritizeVertex: boolean;
  58070. private _target;
  58071. /** Gets or sets the target of that connection point */
  58072. get target(): NodeMaterialBlockTargets;
  58073. set target(value: NodeMaterialBlockTargets);
  58074. /**
  58075. * Gets a boolean indicating that the current point is connected
  58076. */
  58077. get isConnected(): boolean;
  58078. /**
  58079. * Gets a boolean indicating that the current point is connected to an input block
  58080. */
  58081. get isConnectedToInputBlock(): boolean;
  58082. /**
  58083. * Gets a the connected input block (if any)
  58084. */
  58085. get connectInputBlock(): Nullable<InputBlock>;
  58086. /** Get the other side of the connection (if any) */
  58087. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58088. /** Get the block that owns this connection point */
  58089. get ownerBlock(): NodeMaterialBlock;
  58090. /** Get the block connected on the other side of this connection (if any) */
  58091. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58092. /** Get the block connected on the endpoints of this connection (if any) */
  58093. get connectedBlocks(): Array<NodeMaterialBlock>;
  58094. /** Gets the list of connected endpoints */
  58095. get endpoints(): NodeMaterialConnectionPoint[];
  58096. /** Gets a boolean indicating if that output point is connected to at least one input */
  58097. get hasEndpoints(): boolean;
  58098. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58099. get isConnectedInVertexShader(): boolean;
  58100. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58101. get isConnectedInFragmentShader(): boolean;
  58102. /**
  58103. * Creates a new connection point
  58104. * @param name defines the connection point name
  58105. * @param ownerBlock defines the block hosting this connection point
  58106. * @param direction defines the direction of the connection point
  58107. */
  58108. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58109. /**
  58110. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58111. * @returns the class name
  58112. */
  58113. getClassName(): string;
  58114. /**
  58115. * Gets a boolean indicating if the current point can be connected to another point
  58116. * @param connectionPoint defines the other connection point
  58117. * @returns a boolean
  58118. */
  58119. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58120. /**
  58121. * Gets a number indicating if the current point can be connected to another point
  58122. * @param connectionPoint defines the other connection point
  58123. * @returns a number defining the compatibility state
  58124. */
  58125. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58126. /**
  58127. * Connect this point to another connection point
  58128. * @param connectionPoint defines the other connection point
  58129. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58130. * @returns the current connection point
  58131. */
  58132. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58133. /**
  58134. * Disconnect this point from one of his endpoint
  58135. * @param endpoint defines the other connection point
  58136. * @returns the current connection point
  58137. */
  58138. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58139. /**
  58140. * Serializes this point in a JSON representation
  58141. * @returns the serialized point object
  58142. */
  58143. serialize(): any;
  58144. /**
  58145. * Release resources
  58146. */
  58147. dispose(): void;
  58148. }
  58149. }
  58150. declare module BABYLON {
  58151. /**
  58152. * Block used to add support for vertex skinning (bones)
  58153. */
  58154. export class BonesBlock extends NodeMaterialBlock {
  58155. /**
  58156. * Creates a new BonesBlock
  58157. * @param name defines the block name
  58158. */
  58159. constructor(name: string);
  58160. /**
  58161. * Initialize the block and prepare the context for build
  58162. * @param state defines the state that will be used for the build
  58163. */
  58164. initialize(state: NodeMaterialBuildState): void;
  58165. /**
  58166. * Gets the current class name
  58167. * @returns the class name
  58168. */
  58169. getClassName(): string;
  58170. /**
  58171. * Gets the matrix indices input component
  58172. */
  58173. get matricesIndices(): NodeMaterialConnectionPoint;
  58174. /**
  58175. * Gets the matrix weights input component
  58176. */
  58177. get matricesWeights(): NodeMaterialConnectionPoint;
  58178. /**
  58179. * Gets the extra matrix indices input component
  58180. */
  58181. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58182. /**
  58183. * Gets the extra matrix weights input component
  58184. */
  58185. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58186. /**
  58187. * Gets the world input component
  58188. */
  58189. get world(): NodeMaterialConnectionPoint;
  58190. /**
  58191. * Gets the output component
  58192. */
  58193. get output(): NodeMaterialConnectionPoint;
  58194. autoConfigure(material: NodeMaterial): void;
  58195. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58198. protected _buildBlock(state: NodeMaterialBuildState): this;
  58199. }
  58200. }
  58201. declare module BABYLON {
  58202. /**
  58203. * Block used to add support for instances
  58204. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58205. */
  58206. export class InstancesBlock extends NodeMaterialBlock {
  58207. /**
  58208. * Creates a new InstancesBlock
  58209. * @param name defines the block name
  58210. */
  58211. constructor(name: string);
  58212. /**
  58213. * Gets the current class name
  58214. * @returns the class name
  58215. */
  58216. getClassName(): string;
  58217. /**
  58218. * Gets the first world row input component
  58219. */
  58220. get world0(): NodeMaterialConnectionPoint;
  58221. /**
  58222. * Gets the second world row input component
  58223. */
  58224. get world1(): NodeMaterialConnectionPoint;
  58225. /**
  58226. * Gets the third world row input component
  58227. */
  58228. get world2(): NodeMaterialConnectionPoint;
  58229. /**
  58230. * Gets the forth world row input component
  58231. */
  58232. get world3(): NodeMaterialConnectionPoint;
  58233. /**
  58234. * Gets the world input component
  58235. */
  58236. get world(): NodeMaterialConnectionPoint;
  58237. /**
  58238. * Gets the output component
  58239. */
  58240. get output(): NodeMaterialConnectionPoint;
  58241. /**
  58242. * Gets the isntanceID component
  58243. */
  58244. get instanceID(): NodeMaterialConnectionPoint;
  58245. autoConfigure(material: NodeMaterial): void;
  58246. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58247. protected _buildBlock(state: NodeMaterialBuildState): this;
  58248. }
  58249. }
  58250. declare module BABYLON {
  58251. /**
  58252. * Block used to add morph targets support to vertex shader
  58253. */
  58254. export class MorphTargetsBlock extends NodeMaterialBlock {
  58255. private _repeatableContentAnchor;
  58256. /**
  58257. * Create a new MorphTargetsBlock
  58258. * @param name defines the block name
  58259. */
  58260. constructor(name: string);
  58261. /**
  58262. * Gets the current class name
  58263. * @returns the class name
  58264. */
  58265. getClassName(): string;
  58266. /**
  58267. * Gets the position input component
  58268. */
  58269. get position(): NodeMaterialConnectionPoint;
  58270. /**
  58271. * Gets the normal input component
  58272. */
  58273. get normal(): NodeMaterialConnectionPoint;
  58274. /**
  58275. * Gets the tangent input component
  58276. */
  58277. get tangent(): NodeMaterialConnectionPoint;
  58278. /**
  58279. * Gets the tangent input component
  58280. */
  58281. get uv(): NodeMaterialConnectionPoint;
  58282. /**
  58283. * Gets the position output component
  58284. */
  58285. get positionOutput(): NodeMaterialConnectionPoint;
  58286. /**
  58287. * Gets the normal output component
  58288. */
  58289. get normalOutput(): NodeMaterialConnectionPoint;
  58290. /**
  58291. * Gets the tangent output component
  58292. */
  58293. get tangentOutput(): NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the tangent output component
  58296. */
  58297. get uvOutput(): NodeMaterialConnectionPoint;
  58298. initialize(state: NodeMaterialBuildState): void;
  58299. autoConfigure(material: NodeMaterial): void;
  58300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58302. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58303. protected _buildBlock(state: NodeMaterialBuildState): this;
  58304. }
  58305. }
  58306. declare module BABYLON {
  58307. /**
  58308. * Block used to get data information from a light
  58309. */
  58310. export class LightInformationBlock extends NodeMaterialBlock {
  58311. private _lightDataUniformName;
  58312. private _lightColorUniformName;
  58313. private _lightTypeDefineName;
  58314. /**
  58315. * Gets or sets the light associated with this block
  58316. */
  58317. light: Nullable<Light>;
  58318. /**
  58319. * Creates a new LightInformationBlock
  58320. * @param name defines the block name
  58321. */
  58322. constructor(name: string);
  58323. /**
  58324. * Gets the current class name
  58325. * @returns the class name
  58326. */
  58327. getClassName(): string;
  58328. /**
  58329. * Gets the world position input component
  58330. */
  58331. get worldPosition(): NodeMaterialConnectionPoint;
  58332. /**
  58333. * Gets the direction output component
  58334. */
  58335. get direction(): NodeMaterialConnectionPoint;
  58336. /**
  58337. * Gets the direction output component
  58338. */
  58339. get color(): NodeMaterialConnectionPoint;
  58340. /**
  58341. * Gets the direction output component
  58342. */
  58343. get intensity(): NodeMaterialConnectionPoint;
  58344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58346. protected _buildBlock(state: NodeMaterialBuildState): this;
  58347. serialize(): any;
  58348. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58349. }
  58350. }
  58351. declare module BABYLON {
  58352. /**
  58353. * Block used to add image processing support to fragment shader
  58354. */
  58355. export class ImageProcessingBlock extends NodeMaterialBlock {
  58356. /**
  58357. * Create a new ImageProcessingBlock
  58358. * @param name defines the block name
  58359. */
  58360. constructor(name: string);
  58361. /**
  58362. * Gets the current class name
  58363. * @returns the class name
  58364. */
  58365. getClassName(): string;
  58366. /**
  58367. * Gets the color input component
  58368. */
  58369. get color(): NodeMaterialConnectionPoint;
  58370. /**
  58371. * Gets the output component
  58372. */
  58373. get output(): NodeMaterialConnectionPoint;
  58374. /**
  58375. * Initialize the block and prepare the context for build
  58376. * @param state defines the state that will be used for the build
  58377. */
  58378. initialize(state: NodeMaterialBuildState): void;
  58379. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58381. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58382. protected _buildBlock(state: NodeMaterialBuildState): this;
  58383. }
  58384. }
  58385. declare module BABYLON {
  58386. /**
  58387. * Block used to pertub normals based on a normal map
  58388. */
  58389. export class PerturbNormalBlock extends NodeMaterialBlock {
  58390. private _tangentSpaceParameterName;
  58391. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58392. invertX: boolean;
  58393. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58394. invertY: boolean;
  58395. /**
  58396. * Create a new PerturbNormalBlock
  58397. * @param name defines the block name
  58398. */
  58399. constructor(name: string);
  58400. /**
  58401. * Gets the current class name
  58402. * @returns the class name
  58403. */
  58404. getClassName(): string;
  58405. /**
  58406. * Gets the world position input component
  58407. */
  58408. get worldPosition(): NodeMaterialConnectionPoint;
  58409. /**
  58410. * Gets the world normal input component
  58411. */
  58412. get worldNormal(): NodeMaterialConnectionPoint;
  58413. /**
  58414. * Gets the world tangent input component
  58415. */
  58416. get worldTangent(): NodeMaterialConnectionPoint;
  58417. /**
  58418. * Gets the uv input component
  58419. */
  58420. get uv(): NodeMaterialConnectionPoint;
  58421. /**
  58422. * Gets the normal map color input component
  58423. */
  58424. get normalMapColor(): NodeMaterialConnectionPoint;
  58425. /**
  58426. * Gets the strength input component
  58427. */
  58428. get strength(): NodeMaterialConnectionPoint;
  58429. /**
  58430. * Gets the output component
  58431. */
  58432. get output(): NodeMaterialConnectionPoint;
  58433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58435. autoConfigure(material: NodeMaterial): void;
  58436. protected _buildBlock(state: NodeMaterialBuildState): this;
  58437. protected _dumpPropertiesCode(): string;
  58438. serialize(): any;
  58439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58440. }
  58441. }
  58442. declare module BABYLON {
  58443. /**
  58444. * Block used to discard a pixel if a value is smaller than a cutoff
  58445. */
  58446. export class DiscardBlock extends NodeMaterialBlock {
  58447. /**
  58448. * Create a new DiscardBlock
  58449. * @param name defines the block name
  58450. */
  58451. constructor(name: string);
  58452. /**
  58453. * Gets the current class name
  58454. * @returns the class name
  58455. */
  58456. getClassName(): string;
  58457. /**
  58458. * Gets the color input component
  58459. */
  58460. get value(): NodeMaterialConnectionPoint;
  58461. /**
  58462. * Gets the cutoff input component
  58463. */
  58464. get cutoff(): NodeMaterialConnectionPoint;
  58465. protected _buildBlock(state: NodeMaterialBuildState): this;
  58466. }
  58467. }
  58468. declare module BABYLON {
  58469. /**
  58470. * Block used to test if the fragment shader is front facing
  58471. */
  58472. export class FrontFacingBlock extends NodeMaterialBlock {
  58473. /**
  58474. * Creates a new FrontFacingBlock
  58475. * @param name defines the block name
  58476. */
  58477. constructor(name: string);
  58478. /**
  58479. * Gets the current class name
  58480. * @returns the class name
  58481. */
  58482. getClassName(): string;
  58483. /**
  58484. * Gets the output component
  58485. */
  58486. get output(): NodeMaterialConnectionPoint;
  58487. protected _buildBlock(state: NodeMaterialBuildState): this;
  58488. }
  58489. }
  58490. declare module BABYLON {
  58491. /**
  58492. * Block used to get the derivative value on x and y of a given input
  58493. */
  58494. export class DerivativeBlock extends NodeMaterialBlock {
  58495. /**
  58496. * Create a new DerivativeBlock
  58497. * @param name defines the block name
  58498. */
  58499. constructor(name: string);
  58500. /**
  58501. * Gets the current class name
  58502. * @returns the class name
  58503. */
  58504. getClassName(): string;
  58505. /**
  58506. * Gets the input component
  58507. */
  58508. get input(): NodeMaterialConnectionPoint;
  58509. /**
  58510. * Gets the derivative output on x
  58511. */
  58512. get dx(): NodeMaterialConnectionPoint;
  58513. /**
  58514. * Gets the derivative output on y
  58515. */
  58516. get dy(): NodeMaterialConnectionPoint;
  58517. protected _buildBlock(state: NodeMaterialBuildState): this;
  58518. }
  58519. }
  58520. declare module BABYLON {
  58521. /**
  58522. * Block used to add support for scene fog
  58523. */
  58524. export class FogBlock extends NodeMaterialBlock {
  58525. private _fogDistanceName;
  58526. private _fogParameters;
  58527. /**
  58528. * Create a new FogBlock
  58529. * @param name defines the block name
  58530. */
  58531. constructor(name: string);
  58532. /**
  58533. * Gets the current class name
  58534. * @returns the class name
  58535. */
  58536. getClassName(): string;
  58537. /**
  58538. * Gets the world position input component
  58539. */
  58540. get worldPosition(): NodeMaterialConnectionPoint;
  58541. /**
  58542. * Gets the view input component
  58543. */
  58544. get view(): NodeMaterialConnectionPoint;
  58545. /**
  58546. * Gets the color input component
  58547. */
  58548. get input(): NodeMaterialConnectionPoint;
  58549. /**
  58550. * Gets the fog color input component
  58551. */
  58552. get fogColor(): NodeMaterialConnectionPoint;
  58553. /**
  58554. * Gets the output component
  58555. */
  58556. get output(): NodeMaterialConnectionPoint;
  58557. autoConfigure(material: NodeMaterial): void;
  58558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58560. protected _buildBlock(state: NodeMaterialBuildState): this;
  58561. }
  58562. }
  58563. declare module BABYLON {
  58564. /**
  58565. * Block used to add light in the fragment shader
  58566. */
  58567. export class LightBlock extends NodeMaterialBlock {
  58568. private _lightId;
  58569. /**
  58570. * Gets or sets the light associated with this block
  58571. */
  58572. light: Nullable<Light>;
  58573. /**
  58574. * Create a new LightBlock
  58575. * @param name defines the block name
  58576. */
  58577. constructor(name: string);
  58578. /**
  58579. * Gets the current class name
  58580. * @returns the class name
  58581. */
  58582. getClassName(): string;
  58583. /**
  58584. * Gets the world position input component
  58585. */
  58586. get worldPosition(): NodeMaterialConnectionPoint;
  58587. /**
  58588. * Gets the world normal input component
  58589. */
  58590. get worldNormal(): NodeMaterialConnectionPoint;
  58591. /**
  58592. * Gets the camera (or eye) position component
  58593. */
  58594. get cameraPosition(): NodeMaterialConnectionPoint;
  58595. /**
  58596. * Gets the glossiness component
  58597. */
  58598. get glossiness(): NodeMaterialConnectionPoint;
  58599. /**
  58600. * Gets the glossinness power component
  58601. */
  58602. get glossPower(): NodeMaterialConnectionPoint;
  58603. /**
  58604. * Gets the diffuse color component
  58605. */
  58606. get diffuseColor(): NodeMaterialConnectionPoint;
  58607. /**
  58608. * Gets the specular color component
  58609. */
  58610. get specularColor(): NodeMaterialConnectionPoint;
  58611. /**
  58612. * Gets the diffuse output component
  58613. */
  58614. get diffuseOutput(): NodeMaterialConnectionPoint;
  58615. /**
  58616. * Gets the specular output component
  58617. */
  58618. get specularOutput(): NodeMaterialConnectionPoint;
  58619. /**
  58620. * Gets the shadow output component
  58621. */
  58622. get shadow(): NodeMaterialConnectionPoint;
  58623. autoConfigure(material: NodeMaterial): void;
  58624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58625. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58627. private _injectVertexCode;
  58628. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58629. serialize(): any;
  58630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58631. }
  58632. }
  58633. declare module BABYLON {
  58634. /**
  58635. * Block used to multiply 2 values
  58636. */
  58637. export class MultiplyBlock extends NodeMaterialBlock {
  58638. /**
  58639. * Creates a new MultiplyBlock
  58640. * @param name defines the block name
  58641. */
  58642. constructor(name: string);
  58643. /**
  58644. * Gets the current class name
  58645. * @returns the class name
  58646. */
  58647. getClassName(): string;
  58648. /**
  58649. * Gets the left operand input component
  58650. */
  58651. get left(): NodeMaterialConnectionPoint;
  58652. /**
  58653. * Gets the right operand input component
  58654. */
  58655. get right(): NodeMaterialConnectionPoint;
  58656. /**
  58657. * Gets the output component
  58658. */
  58659. get output(): NodeMaterialConnectionPoint;
  58660. protected _buildBlock(state: NodeMaterialBuildState): this;
  58661. }
  58662. }
  58663. declare module BABYLON {
  58664. /**
  58665. * Block used to add 2 vectors
  58666. */
  58667. export class AddBlock extends NodeMaterialBlock {
  58668. /**
  58669. * Creates a new AddBlock
  58670. * @param name defines the block name
  58671. */
  58672. constructor(name: string);
  58673. /**
  58674. * Gets the current class name
  58675. * @returns the class name
  58676. */
  58677. getClassName(): string;
  58678. /**
  58679. * Gets the left operand input component
  58680. */
  58681. get left(): NodeMaterialConnectionPoint;
  58682. /**
  58683. * Gets the right operand input component
  58684. */
  58685. get right(): NodeMaterialConnectionPoint;
  58686. /**
  58687. * Gets the output component
  58688. */
  58689. get output(): NodeMaterialConnectionPoint;
  58690. protected _buildBlock(state: NodeMaterialBuildState): this;
  58691. }
  58692. }
  58693. declare module BABYLON {
  58694. /**
  58695. * Block used to scale a vector by a float
  58696. */
  58697. export class ScaleBlock extends NodeMaterialBlock {
  58698. /**
  58699. * Creates a new ScaleBlock
  58700. * @param name defines the block name
  58701. */
  58702. constructor(name: string);
  58703. /**
  58704. * Gets the current class name
  58705. * @returns the class name
  58706. */
  58707. getClassName(): string;
  58708. /**
  58709. * Gets the input component
  58710. */
  58711. get input(): NodeMaterialConnectionPoint;
  58712. /**
  58713. * Gets the factor input component
  58714. */
  58715. get factor(): NodeMaterialConnectionPoint;
  58716. /**
  58717. * Gets the output component
  58718. */
  58719. get output(): NodeMaterialConnectionPoint;
  58720. protected _buildBlock(state: NodeMaterialBuildState): this;
  58721. }
  58722. }
  58723. declare module BABYLON {
  58724. /**
  58725. * Block used to clamp a float
  58726. */
  58727. export class ClampBlock extends NodeMaterialBlock {
  58728. /** Gets or sets the minimum range */
  58729. minimum: number;
  58730. /** Gets or sets the maximum range */
  58731. maximum: number;
  58732. /**
  58733. * Creates a new ClampBlock
  58734. * @param name defines the block name
  58735. */
  58736. constructor(name: string);
  58737. /**
  58738. * Gets the current class name
  58739. * @returns the class name
  58740. */
  58741. getClassName(): string;
  58742. /**
  58743. * Gets the value input component
  58744. */
  58745. get value(): NodeMaterialConnectionPoint;
  58746. /**
  58747. * Gets the output component
  58748. */
  58749. get output(): NodeMaterialConnectionPoint;
  58750. protected _buildBlock(state: NodeMaterialBuildState): this;
  58751. protected _dumpPropertiesCode(): string;
  58752. serialize(): any;
  58753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58754. }
  58755. }
  58756. declare module BABYLON {
  58757. /**
  58758. * Block used to apply a cross product between 2 vectors
  58759. */
  58760. export class CrossBlock extends NodeMaterialBlock {
  58761. /**
  58762. * Creates a new CrossBlock
  58763. * @param name defines the block name
  58764. */
  58765. constructor(name: string);
  58766. /**
  58767. * Gets the current class name
  58768. * @returns the class name
  58769. */
  58770. getClassName(): string;
  58771. /**
  58772. * Gets the left operand input component
  58773. */
  58774. get left(): NodeMaterialConnectionPoint;
  58775. /**
  58776. * Gets the right operand input component
  58777. */
  58778. get right(): NodeMaterialConnectionPoint;
  58779. /**
  58780. * Gets the output component
  58781. */
  58782. get output(): NodeMaterialConnectionPoint;
  58783. protected _buildBlock(state: NodeMaterialBuildState): this;
  58784. }
  58785. }
  58786. declare module BABYLON {
  58787. /**
  58788. * Block used to apply a dot product between 2 vectors
  58789. */
  58790. export class DotBlock extends NodeMaterialBlock {
  58791. /**
  58792. * Creates a new DotBlock
  58793. * @param name defines the block name
  58794. */
  58795. constructor(name: string);
  58796. /**
  58797. * Gets the current class name
  58798. * @returns the class name
  58799. */
  58800. getClassName(): string;
  58801. /**
  58802. * Gets the left operand input component
  58803. */
  58804. get left(): NodeMaterialConnectionPoint;
  58805. /**
  58806. * Gets the right operand input component
  58807. */
  58808. get right(): NodeMaterialConnectionPoint;
  58809. /**
  58810. * Gets the output component
  58811. */
  58812. get output(): NodeMaterialConnectionPoint;
  58813. protected _buildBlock(state: NodeMaterialBuildState): this;
  58814. }
  58815. }
  58816. declare module BABYLON {
  58817. /**
  58818. * Block used to remap a float from a range to a new one
  58819. */
  58820. export class RemapBlock extends NodeMaterialBlock {
  58821. /**
  58822. * Gets or sets the source range
  58823. */
  58824. sourceRange: Vector2;
  58825. /**
  58826. * Gets or sets the target range
  58827. */
  58828. targetRange: Vector2;
  58829. /**
  58830. * Creates a new RemapBlock
  58831. * @param name defines the block name
  58832. */
  58833. constructor(name: string);
  58834. /**
  58835. * Gets the current class name
  58836. * @returns the class name
  58837. */
  58838. getClassName(): string;
  58839. /**
  58840. * Gets the input component
  58841. */
  58842. get input(): NodeMaterialConnectionPoint;
  58843. /**
  58844. * Gets the source min input component
  58845. */
  58846. get sourceMin(): NodeMaterialConnectionPoint;
  58847. /**
  58848. * Gets the source max input component
  58849. */
  58850. get sourceMax(): NodeMaterialConnectionPoint;
  58851. /**
  58852. * Gets the target min input component
  58853. */
  58854. get targetMin(): NodeMaterialConnectionPoint;
  58855. /**
  58856. * Gets the target max input component
  58857. */
  58858. get targetMax(): NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the output component
  58861. */
  58862. get output(): NodeMaterialConnectionPoint;
  58863. protected _buildBlock(state: NodeMaterialBuildState): this;
  58864. protected _dumpPropertiesCode(): string;
  58865. serialize(): any;
  58866. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58867. }
  58868. }
  58869. declare module BABYLON {
  58870. /**
  58871. * Block used to normalize a vector
  58872. */
  58873. export class NormalizeBlock extends NodeMaterialBlock {
  58874. /**
  58875. * Creates a new NormalizeBlock
  58876. * @param name defines the block name
  58877. */
  58878. constructor(name: string);
  58879. /**
  58880. * Gets the current class name
  58881. * @returns the class name
  58882. */
  58883. getClassName(): string;
  58884. /**
  58885. * Gets the input component
  58886. */
  58887. get input(): NodeMaterialConnectionPoint;
  58888. /**
  58889. * Gets the output component
  58890. */
  58891. get output(): NodeMaterialConnectionPoint;
  58892. protected _buildBlock(state: NodeMaterialBuildState): this;
  58893. }
  58894. }
  58895. declare module BABYLON {
  58896. /**
  58897. * Operations supported by the Trigonometry block
  58898. */
  58899. export enum TrigonometryBlockOperations {
  58900. /** Cos */
  58901. Cos = 0,
  58902. /** Sin */
  58903. Sin = 1,
  58904. /** Abs */
  58905. Abs = 2,
  58906. /** Exp */
  58907. Exp = 3,
  58908. /** Exp2 */
  58909. Exp2 = 4,
  58910. /** Round */
  58911. Round = 5,
  58912. /** Floor */
  58913. Floor = 6,
  58914. /** Ceiling */
  58915. Ceiling = 7,
  58916. /** Square root */
  58917. Sqrt = 8,
  58918. /** Log */
  58919. Log = 9,
  58920. /** Tangent */
  58921. Tan = 10,
  58922. /** Arc tangent */
  58923. ArcTan = 11,
  58924. /** Arc cosinus */
  58925. ArcCos = 12,
  58926. /** Arc sinus */
  58927. ArcSin = 13,
  58928. /** Fraction */
  58929. Fract = 14,
  58930. /** Sign */
  58931. Sign = 15,
  58932. /** To radians (from degrees) */
  58933. Radians = 16,
  58934. /** To degrees (from radians) */
  58935. Degrees = 17
  58936. }
  58937. /**
  58938. * Block used to apply trigonometry operation to floats
  58939. */
  58940. export class TrigonometryBlock extends NodeMaterialBlock {
  58941. /**
  58942. * Gets or sets the operation applied by the block
  58943. */
  58944. operation: TrigonometryBlockOperations;
  58945. /**
  58946. * Creates a new TrigonometryBlock
  58947. * @param name defines the block name
  58948. */
  58949. constructor(name: string);
  58950. /**
  58951. * Gets the current class name
  58952. * @returns the class name
  58953. */
  58954. getClassName(): string;
  58955. /**
  58956. * Gets the input component
  58957. */
  58958. get input(): NodeMaterialConnectionPoint;
  58959. /**
  58960. * Gets the output component
  58961. */
  58962. get output(): NodeMaterialConnectionPoint;
  58963. protected _buildBlock(state: NodeMaterialBuildState): this;
  58964. serialize(): any;
  58965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58966. protected _dumpPropertiesCode(): string;
  58967. }
  58968. }
  58969. declare module BABYLON {
  58970. /**
  58971. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58972. */
  58973. export class ColorMergerBlock extends NodeMaterialBlock {
  58974. /**
  58975. * Create a new ColorMergerBlock
  58976. * @param name defines the block name
  58977. */
  58978. constructor(name: string);
  58979. /**
  58980. * Gets the current class name
  58981. * @returns the class name
  58982. */
  58983. getClassName(): string;
  58984. /**
  58985. * Gets the rgb component (input)
  58986. */
  58987. get rgbIn(): NodeMaterialConnectionPoint;
  58988. /**
  58989. * Gets the r component (input)
  58990. */
  58991. get r(): NodeMaterialConnectionPoint;
  58992. /**
  58993. * Gets the g component (input)
  58994. */
  58995. get g(): NodeMaterialConnectionPoint;
  58996. /**
  58997. * Gets the b component (input)
  58998. */
  58999. get b(): NodeMaterialConnectionPoint;
  59000. /**
  59001. * Gets the a component (input)
  59002. */
  59003. get a(): NodeMaterialConnectionPoint;
  59004. /**
  59005. * Gets the rgba component (output)
  59006. */
  59007. get rgba(): NodeMaterialConnectionPoint;
  59008. /**
  59009. * Gets the rgb component (output)
  59010. */
  59011. get rgbOut(): NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the rgb component (output)
  59014. * @deprecated Please use rgbOut instead.
  59015. */
  59016. get rgb(): NodeMaterialConnectionPoint;
  59017. protected _buildBlock(state: NodeMaterialBuildState): this;
  59018. }
  59019. }
  59020. declare module BABYLON {
  59021. /**
  59022. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59023. */
  59024. export class VectorMergerBlock extends NodeMaterialBlock {
  59025. /**
  59026. * Create a new VectorMergerBlock
  59027. * @param name defines the block name
  59028. */
  59029. constructor(name: string);
  59030. /**
  59031. * Gets the current class name
  59032. * @returns the class name
  59033. */
  59034. getClassName(): string;
  59035. /**
  59036. * Gets the xyz component (input)
  59037. */
  59038. get xyzIn(): NodeMaterialConnectionPoint;
  59039. /**
  59040. * Gets the xy component (input)
  59041. */
  59042. get xyIn(): NodeMaterialConnectionPoint;
  59043. /**
  59044. * Gets the x component (input)
  59045. */
  59046. get x(): NodeMaterialConnectionPoint;
  59047. /**
  59048. * Gets the y component (input)
  59049. */
  59050. get y(): NodeMaterialConnectionPoint;
  59051. /**
  59052. * Gets the z component (input)
  59053. */
  59054. get z(): NodeMaterialConnectionPoint;
  59055. /**
  59056. * Gets the w component (input)
  59057. */
  59058. get w(): NodeMaterialConnectionPoint;
  59059. /**
  59060. * Gets the xyzw component (output)
  59061. */
  59062. get xyzw(): NodeMaterialConnectionPoint;
  59063. /**
  59064. * Gets the xyz component (output)
  59065. */
  59066. get xyzOut(): NodeMaterialConnectionPoint;
  59067. /**
  59068. * Gets the xy component (output)
  59069. */
  59070. get xyOut(): NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the xy component (output)
  59073. * @deprecated Please use xyOut instead.
  59074. */
  59075. get xy(): NodeMaterialConnectionPoint;
  59076. /**
  59077. * Gets the xyz component (output)
  59078. * @deprecated Please use xyzOut instead.
  59079. */
  59080. get xyz(): NodeMaterialConnectionPoint;
  59081. protected _buildBlock(state: NodeMaterialBuildState): this;
  59082. }
  59083. }
  59084. declare module BABYLON {
  59085. /**
  59086. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59087. */
  59088. export class ColorSplitterBlock extends NodeMaterialBlock {
  59089. /**
  59090. * Create a new ColorSplitterBlock
  59091. * @param name defines the block name
  59092. */
  59093. constructor(name: string);
  59094. /**
  59095. * Gets the current class name
  59096. * @returns the class name
  59097. */
  59098. getClassName(): string;
  59099. /**
  59100. * Gets the rgba component (input)
  59101. */
  59102. get rgba(): NodeMaterialConnectionPoint;
  59103. /**
  59104. * Gets the rgb component (input)
  59105. */
  59106. get rgbIn(): NodeMaterialConnectionPoint;
  59107. /**
  59108. * Gets the rgb component (output)
  59109. */
  59110. get rgbOut(): NodeMaterialConnectionPoint;
  59111. /**
  59112. * Gets the r component (output)
  59113. */
  59114. get r(): NodeMaterialConnectionPoint;
  59115. /**
  59116. * Gets the g component (output)
  59117. */
  59118. get g(): NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the b component (output)
  59121. */
  59122. get b(): NodeMaterialConnectionPoint;
  59123. /**
  59124. * Gets the a component (output)
  59125. */
  59126. get a(): NodeMaterialConnectionPoint;
  59127. protected _inputRename(name: string): string;
  59128. protected _outputRename(name: string): string;
  59129. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59130. }
  59131. }
  59132. declare module BABYLON {
  59133. /**
  59134. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59135. */
  59136. export class VectorSplitterBlock extends NodeMaterialBlock {
  59137. /**
  59138. * Create a new VectorSplitterBlock
  59139. * @param name defines the block name
  59140. */
  59141. constructor(name: string);
  59142. /**
  59143. * Gets the current class name
  59144. * @returns the class name
  59145. */
  59146. getClassName(): string;
  59147. /**
  59148. * Gets the xyzw component (input)
  59149. */
  59150. get xyzw(): NodeMaterialConnectionPoint;
  59151. /**
  59152. * Gets the xyz component (input)
  59153. */
  59154. get xyzIn(): NodeMaterialConnectionPoint;
  59155. /**
  59156. * Gets the xy component (input)
  59157. */
  59158. get xyIn(): NodeMaterialConnectionPoint;
  59159. /**
  59160. * Gets the xyz component (output)
  59161. */
  59162. get xyzOut(): NodeMaterialConnectionPoint;
  59163. /**
  59164. * Gets the xy component (output)
  59165. */
  59166. get xyOut(): NodeMaterialConnectionPoint;
  59167. /**
  59168. * Gets the x component (output)
  59169. */
  59170. get x(): NodeMaterialConnectionPoint;
  59171. /**
  59172. * Gets the y component (output)
  59173. */
  59174. get y(): NodeMaterialConnectionPoint;
  59175. /**
  59176. * Gets the z component (output)
  59177. */
  59178. get z(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the w component (output)
  59181. */
  59182. get w(): NodeMaterialConnectionPoint;
  59183. protected _inputRename(name: string): string;
  59184. protected _outputRename(name: string): string;
  59185. protected _buildBlock(state: NodeMaterialBuildState): this;
  59186. }
  59187. }
  59188. declare module BABYLON {
  59189. /**
  59190. * Block used to lerp between 2 values
  59191. */
  59192. export class LerpBlock extends NodeMaterialBlock {
  59193. /**
  59194. * Creates a new LerpBlock
  59195. * @param name defines the block name
  59196. */
  59197. constructor(name: string);
  59198. /**
  59199. * Gets the current class name
  59200. * @returns the class name
  59201. */
  59202. getClassName(): string;
  59203. /**
  59204. * Gets the left operand input component
  59205. */
  59206. get left(): NodeMaterialConnectionPoint;
  59207. /**
  59208. * Gets the right operand input component
  59209. */
  59210. get right(): NodeMaterialConnectionPoint;
  59211. /**
  59212. * Gets the gradient operand input component
  59213. */
  59214. get gradient(): NodeMaterialConnectionPoint;
  59215. /**
  59216. * Gets the output component
  59217. */
  59218. get output(): NodeMaterialConnectionPoint;
  59219. protected _buildBlock(state: NodeMaterialBuildState): this;
  59220. }
  59221. }
  59222. declare module BABYLON {
  59223. /**
  59224. * Block used to divide 2 vectors
  59225. */
  59226. export class DivideBlock extends NodeMaterialBlock {
  59227. /**
  59228. * Creates a new DivideBlock
  59229. * @param name defines the block name
  59230. */
  59231. constructor(name: string);
  59232. /**
  59233. * Gets the current class name
  59234. * @returns the class name
  59235. */
  59236. getClassName(): string;
  59237. /**
  59238. * Gets the left operand input component
  59239. */
  59240. get left(): NodeMaterialConnectionPoint;
  59241. /**
  59242. * Gets the right operand input component
  59243. */
  59244. get right(): NodeMaterialConnectionPoint;
  59245. /**
  59246. * Gets the output component
  59247. */
  59248. get output(): NodeMaterialConnectionPoint;
  59249. protected _buildBlock(state: NodeMaterialBuildState): this;
  59250. }
  59251. }
  59252. declare module BABYLON {
  59253. /**
  59254. * Block used to subtract 2 vectors
  59255. */
  59256. export class SubtractBlock extends NodeMaterialBlock {
  59257. /**
  59258. * Creates a new SubtractBlock
  59259. * @param name defines the block name
  59260. */
  59261. constructor(name: string);
  59262. /**
  59263. * Gets the current class name
  59264. * @returns the class name
  59265. */
  59266. getClassName(): string;
  59267. /**
  59268. * Gets the left operand input component
  59269. */
  59270. get left(): NodeMaterialConnectionPoint;
  59271. /**
  59272. * Gets the right operand input component
  59273. */
  59274. get right(): NodeMaterialConnectionPoint;
  59275. /**
  59276. * Gets the output component
  59277. */
  59278. get output(): NodeMaterialConnectionPoint;
  59279. protected _buildBlock(state: NodeMaterialBuildState): this;
  59280. }
  59281. }
  59282. declare module BABYLON {
  59283. /**
  59284. * Block used to step a value
  59285. */
  59286. export class StepBlock extends NodeMaterialBlock {
  59287. /**
  59288. * Creates a new StepBlock
  59289. * @param name defines the block name
  59290. */
  59291. constructor(name: string);
  59292. /**
  59293. * Gets the current class name
  59294. * @returns the class name
  59295. */
  59296. getClassName(): string;
  59297. /**
  59298. * Gets the value operand input component
  59299. */
  59300. get value(): NodeMaterialConnectionPoint;
  59301. /**
  59302. * Gets the edge operand input component
  59303. */
  59304. get edge(): NodeMaterialConnectionPoint;
  59305. /**
  59306. * Gets the output component
  59307. */
  59308. get output(): NodeMaterialConnectionPoint;
  59309. protected _buildBlock(state: NodeMaterialBuildState): this;
  59310. }
  59311. }
  59312. declare module BABYLON {
  59313. /**
  59314. * Block used to get the opposite (1 - x) of a value
  59315. */
  59316. export class OneMinusBlock extends NodeMaterialBlock {
  59317. /**
  59318. * Creates a new OneMinusBlock
  59319. * @param name defines the block name
  59320. */
  59321. constructor(name: string);
  59322. /**
  59323. * Gets the current class name
  59324. * @returns the class name
  59325. */
  59326. getClassName(): string;
  59327. /**
  59328. * Gets the input component
  59329. */
  59330. get input(): NodeMaterialConnectionPoint;
  59331. /**
  59332. * Gets the output component
  59333. */
  59334. get output(): NodeMaterialConnectionPoint;
  59335. protected _buildBlock(state: NodeMaterialBuildState): this;
  59336. }
  59337. }
  59338. declare module BABYLON {
  59339. /**
  59340. * Block used to get the view direction
  59341. */
  59342. export class ViewDirectionBlock extends NodeMaterialBlock {
  59343. /**
  59344. * Creates a new ViewDirectionBlock
  59345. * @param name defines the block name
  59346. */
  59347. constructor(name: string);
  59348. /**
  59349. * Gets the current class name
  59350. * @returns the class name
  59351. */
  59352. getClassName(): string;
  59353. /**
  59354. * Gets the world position component
  59355. */
  59356. get worldPosition(): NodeMaterialConnectionPoint;
  59357. /**
  59358. * Gets the camera position component
  59359. */
  59360. get cameraPosition(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the output component
  59363. */
  59364. get output(): NodeMaterialConnectionPoint;
  59365. autoConfigure(material: NodeMaterial): void;
  59366. protected _buildBlock(state: NodeMaterialBuildState): this;
  59367. }
  59368. }
  59369. declare module BABYLON {
  59370. /**
  59371. * Block used to compute fresnel value
  59372. */
  59373. export class FresnelBlock extends NodeMaterialBlock {
  59374. /**
  59375. * Create a new FresnelBlock
  59376. * @param name defines the block name
  59377. */
  59378. constructor(name: string);
  59379. /**
  59380. * Gets the current class name
  59381. * @returns the class name
  59382. */
  59383. getClassName(): string;
  59384. /**
  59385. * Gets the world normal input component
  59386. */
  59387. get worldNormal(): NodeMaterialConnectionPoint;
  59388. /**
  59389. * Gets the view direction input component
  59390. */
  59391. get viewDirection(): NodeMaterialConnectionPoint;
  59392. /**
  59393. * Gets the bias input component
  59394. */
  59395. get bias(): NodeMaterialConnectionPoint;
  59396. /**
  59397. * Gets the camera (or eye) position component
  59398. */
  59399. get power(): NodeMaterialConnectionPoint;
  59400. /**
  59401. * Gets the fresnel output component
  59402. */
  59403. get fresnel(): NodeMaterialConnectionPoint;
  59404. autoConfigure(material: NodeMaterial): void;
  59405. protected _buildBlock(state: NodeMaterialBuildState): this;
  59406. }
  59407. }
  59408. declare module BABYLON {
  59409. /**
  59410. * Block used to get the max of 2 values
  59411. */
  59412. export class MaxBlock extends NodeMaterialBlock {
  59413. /**
  59414. * Creates a new MaxBlock
  59415. * @param name defines the block name
  59416. */
  59417. constructor(name: string);
  59418. /**
  59419. * Gets the current class name
  59420. * @returns the class name
  59421. */
  59422. getClassName(): string;
  59423. /**
  59424. * Gets the left operand input component
  59425. */
  59426. get left(): NodeMaterialConnectionPoint;
  59427. /**
  59428. * Gets the right operand input component
  59429. */
  59430. get right(): NodeMaterialConnectionPoint;
  59431. /**
  59432. * Gets the output component
  59433. */
  59434. get output(): NodeMaterialConnectionPoint;
  59435. protected _buildBlock(state: NodeMaterialBuildState): this;
  59436. }
  59437. }
  59438. declare module BABYLON {
  59439. /**
  59440. * Block used to get the min of 2 values
  59441. */
  59442. export class MinBlock extends NodeMaterialBlock {
  59443. /**
  59444. * Creates a new MinBlock
  59445. * @param name defines the block name
  59446. */
  59447. constructor(name: string);
  59448. /**
  59449. * Gets the current class name
  59450. * @returns the class name
  59451. */
  59452. getClassName(): string;
  59453. /**
  59454. * Gets the left operand input component
  59455. */
  59456. get left(): NodeMaterialConnectionPoint;
  59457. /**
  59458. * Gets the right operand input component
  59459. */
  59460. get right(): NodeMaterialConnectionPoint;
  59461. /**
  59462. * Gets the output component
  59463. */
  59464. get output(): NodeMaterialConnectionPoint;
  59465. protected _buildBlock(state: NodeMaterialBuildState): this;
  59466. }
  59467. }
  59468. declare module BABYLON {
  59469. /**
  59470. * Block used to get the distance between 2 values
  59471. */
  59472. export class DistanceBlock extends NodeMaterialBlock {
  59473. /**
  59474. * Creates a new DistanceBlock
  59475. * @param name defines the block name
  59476. */
  59477. constructor(name: string);
  59478. /**
  59479. * Gets the current class name
  59480. * @returns the class name
  59481. */
  59482. getClassName(): string;
  59483. /**
  59484. * Gets the left operand input component
  59485. */
  59486. get left(): NodeMaterialConnectionPoint;
  59487. /**
  59488. * Gets the right operand input component
  59489. */
  59490. get right(): NodeMaterialConnectionPoint;
  59491. /**
  59492. * Gets the output component
  59493. */
  59494. get output(): NodeMaterialConnectionPoint;
  59495. protected _buildBlock(state: NodeMaterialBuildState): this;
  59496. }
  59497. }
  59498. declare module BABYLON {
  59499. /**
  59500. * Block used to get the length of a vector
  59501. */
  59502. export class LengthBlock extends NodeMaterialBlock {
  59503. /**
  59504. * Creates a new LengthBlock
  59505. * @param name defines the block name
  59506. */
  59507. constructor(name: string);
  59508. /**
  59509. * Gets the current class name
  59510. * @returns the class name
  59511. */
  59512. getClassName(): string;
  59513. /**
  59514. * Gets the value input component
  59515. */
  59516. get value(): NodeMaterialConnectionPoint;
  59517. /**
  59518. * Gets the output component
  59519. */
  59520. get output(): NodeMaterialConnectionPoint;
  59521. protected _buildBlock(state: NodeMaterialBuildState): this;
  59522. }
  59523. }
  59524. declare module BABYLON {
  59525. /**
  59526. * Block used to get negative version of a value (i.e. x * -1)
  59527. */
  59528. export class NegateBlock extends NodeMaterialBlock {
  59529. /**
  59530. * Creates a new NegateBlock
  59531. * @param name defines the block name
  59532. */
  59533. constructor(name: string);
  59534. /**
  59535. * Gets the current class name
  59536. * @returns the class name
  59537. */
  59538. getClassName(): string;
  59539. /**
  59540. * Gets the value input component
  59541. */
  59542. get value(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the output component
  59545. */
  59546. get output(): NodeMaterialConnectionPoint;
  59547. protected _buildBlock(state: NodeMaterialBuildState): this;
  59548. }
  59549. }
  59550. declare module BABYLON {
  59551. /**
  59552. * Block used to get the value of the first parameter raised to the power of the second
  59553. */
  59554. export class PowBlock extends NodeMaterialBlock {
  59555. /**
  59556. * Creates a new PowBlock
  59557. * @param name defines the block name
  59558. */
  59559. constructor(name: string);
  59560. /**
  59561. * Gets the current class name
  59562. * @returns the class name
  59563. */
  59564. getClassName(): string;
  59565. /**
  59566. * Gets the value operand input component
  59567. */
  59568. get value(): NodeMaterialConnectionPoint;
  59569. /**
  59570. * Gets the power operand input component
  59571. */
  59572. get power(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the output component
  59575. */
  59576. get output(): NodeMaterialConnectionPoint;
  59577. protected _buildBlock(state: NodeMaterialBuildState): this;
  59578. }
  59579. }
  59580. declare module BABYLON {
  59581. /**
  59582. * Block used to get a random number
  59583. */
  59584. export class RandomNumberBlock extends NodeMaterialBlock {
  59585. /**
  59586. * Creates a new RandomNumberBlock
  59587. * @param name defines the block name
  59588. */
  59589. constructor(name: string);
  59590. /**
  59591. * Gets the current class name
  59592. * @returns the class name
  59593. */
  59594. getClassName(): string;
  59595. /**
  59596. * Gets the seed input component
  59597. */
  59598. get seed(): NodeMaterialConnectionPoint;
  59599. /**
  59600. * Gets the output component
  59601. */
  59602. get output(): NodeMaterialConnectionPoint;
  59603. protected _buildBlock(state: NodeMaterialBuildState): this;
  59604. }
  59605. }
  59606. declare module BABYLON {
  59607. /**
  59608. * Block used to compute arc tangent of 2 values
  59609. */
  59610. export class ArcTan2Block extends NodeMaterialBlock {
  59611. /**
  59612. * Creates a new ArcTan2Block
  59613. * @param name defines the block name
  59614. */
  59615. constructor(name: string);
  59616. /**
  59617. * Gets the current class name
  59618. * @returns the class name
  59619. */
  59620. getClassName(): string;
  59621. /**
  59622. * Gets the x operand input component
  59623. */
  59624. get x(): NodeMaterialConnectionPoint;
  59625. /**
  59626. * Gets the y operand input component
  59627. */
  59628. get y(): NodeMaterialConnectionPoint;
  59629. /**
  59630. * Gets the output component
  59631. */
  59632. get output(): NodeMaterialConnectionPoint;
  59633. protected _buildBlock(state: NodeMaterialBuildState): this;
  59634. }
  59635. }
  59636. declare module BABYLON {
  59637. /**
  59638. * Block used to smooth step a value
  59639. */
  59640. export class SmoothStepBlock extends NodeMaterialBlock {
  59641. /**
  59642. * Creates a new SmoothStepBlock
  59643. * @param name defines the block name
  59644. */
  59645. constructor(name: string);
  59646. /**
  59647. * Gets the current class name
  59648. * @returns the class name
  59649. */
  59650. getClassName(): string;
  59651. /**
  59652. * Gets the value operand input component
  59653. */
  59654. get value(): NodeMaterialConnectionPoint;
  59655. /**
  59656. * Gets the first edge operand input component
  59657. */
  59658. get edge0(): NodeMaterialConnectionPoint;
  59659. /**
  59660. * Gets the second edge operand input component
  59661. */
  59662. get edge1(): NodeMaterialConnectionPoint;
  59663. /**
  59664. * Gets the output component
  59665. */
  59666. get output(): NodeMaterialConnectionPoint;
  59667. protected _buildBlock(state: NodeMaterialBuildState): this;
  59668. }
  59669. }
  59670. declare module BABYLON {
  59671. /**
  59672. * Block used to get the reciprocal (1 / x) of a value
  59673. */
  59674. export class ReciprocalBlock extends NodeMaterialBlock {
  59675. /**
  59676. * Creates a new ReciprocalBlock
  59677. * @param name defines the block name
  59678. */
  59679. constructor(name: string);
  59680. /**
  59681. * Gets the current class name
  59682. * @returns the class name
  59683. */
  59684. getClassName(): string;
  59685. /**
  59686. * Gets the input component
  59687. */
  59688. get input(): NodeMaterialConnectionPoint;
  59689. /**
  59690. * Gets the output component
  59691. */
  59692. get output(): NodeMaterialConnectionPoint;
  59693. protected _buildBlock(state: NodeMaterialBuildState): this;
  59694. }
  59695. }
  59696. declare module BABYLON {
  59697. /**
  59698. * Block used to replace a color by another one
  59699. */
  59700. export class ReplaceColorBlock extends NodeMaterialBlock {
  59701. /**
  59702. * Creates a new ReplaceColorBlock
  59703. * @param name defines the block name
  59704. */
  59705. constructor(name: string);
  59706. /**
  59707. * Gets the current class name
  59708. * @returns the class name
  59709. */
  59710. getClassName(): string;
  59711. /**
  59712. * Gets the value input component
  59713. */
  59714. get value(): NodeMaterialConnectionPoint;
  59715. /**
  59716. * Gets the reference input component
  59717. */
  59718. get reference(): NodeMaterialConnectionPoint;
  59719. /**
  59720. * Gets the distance input component
  59721. */
  59722. get distance(): NodeMaterialConnectionPoint;
  59723. /**
  59724. * Gets the replacement input component
  59725. */
  59726. get replacement(): NodeMaterialConnectionPoint;
  59727. /**
  59728. * Gets the output component
  59729. */
  59730. get output(): NodeMaterialConnectionPoint;
  59731. protected _buildBlock(state: NodeMaterialBuildState): this;
  59732. }
  59733. }
  59734. declare module BABYLON {
  59735. /**
  59736. * Block used to posterize a value
  59737. * @see https://en.wikipedia.org/wiki/Posterization
  59738. */
  59739. export class PosterizeBlock extends NodeMaterialBlock {
  59740. /**
  59741. * Creates a new PosterizeBlock
  59742. * @param name defines the block name
  59743. */
  59744. constructor(name: string);
  59745. /**
  59746. * Gets the current class name
  59747. * @returns the class name
  59748. */
  59749. getClassName(): string;
  59750. /**
  59751. * Gets the value input component
  59752. */
  59753. get value(): NodeMaterialConnectionPoint;
  59754. /**
  59755. * Gets the steps input component
  59756. */
  59757. get steps(): NodeMaterialConnectionPoint;
  59758. /**
  59759. * Gets the output component
  59760. */
  59761. get output(): NodeMaterialConnectionPoint;
  59762. protected _buildBlock(state: NodeMaterialBuildState): this;
  59763. }
  59764. }
  59765. declare module BABYLON {
  59766. /**
  59767. * Operations supported by the Wave block
  59768. */
  59769. export enum WaveBlockKind {
  59770. /** SawTooth */
  59771. SawTooth = 0,
  59772. /** Square */
  59773. Square = 1,
  59774. /** Triangle */
  59775. Triangle = 2
  59776. }
  59777. /**
  59778. * Block used to apply wave operation to floats
  59779. */
  59780. export class WaveBlock extends NodeMaterialBlock {
  59781. /**
  59782. * Gets or sets the kibnd of wave to be applied by the block
  59783. */
  59784. kind: WaveBlockKind;
  59785. /**
  59786. * Creates a new WaveBlock
  59787. * @param name defines the block name
  59788. */
  59789. constructor(name: string);
  59790. /**
  59791. * Gets the current class name
  59792. * @returns the class name
  59793. */
  59794. getClassName(): string;
  59795. /**
  59796. * Gets the input component
  59797. */
  59798. get input(): NodeMaterialConnectionPoint;
  59799. /**
  59800. * Gets the output component
  59801. */
  59802. get output(): NodeMaterialConnectionPoint;
  59803. protected _buildBlock(state: NodeMaterialBuildState): this;
  59804. serialize(): any;
  59805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59806. }
  59807. }
  59808. declare module BABYLON {
  59809. /**
  59810. * Class used to store a color step for the GradientBlock
  59811. */
  59812. export class GradientBlockColorStep {
  59813. /**
  59814. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59815. */
  59816. step: number;
  59817. /**
  59818. * Gets or sets the color associated with this step
  59819. */
  59820. color: Color3;
  59821. /**
  59822. * Creates a new GradientBlockColorStep
  59823. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59824. * @param color defines the color associated with this step
  59825. */
  59826. constructor(
  59827. /**
  59828. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59829. */
  59830. step: number,
  59831. /**
  59832. * Gets or sets the color associated with this step
  59833. */
  59834. color: Color3);
  59835. }
  59836. /**
  59837. * Block used to return a color from a gradient based on an input value between 0 and 1
  59838. */
  59839. export class GradientBlock extends NodeMaterialBlock {
  59840. /**
  59841. * Gets or sets the list of color steps
  59842. */
  59843. colorSteps: GradientBlockColorStep[];
  59844. /**
  59845. * Creates a new GradientBlock
  59846. * @param name defines the block name
  59847. */
  59848. constructor(name: string);
  59849. /**
  59850. * Gets the current class name
  59851. * @returns the class name
  59852. */
  59853. getClassName(): string;
  59854. /**
  59855. * Gets the gradient input component
  59856. */
  59857. get gradient(): NodeMaterialConnectionPoint;
  59858. /**
  59859. * Gets the output component
  59860. */
  59861. get output(): NodeMaterialConnectionPoint;
  59862. private _writeColorConstant;
  59863. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59864. serialize(): any;
  59865. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59866. protected _dumpPropertiesCode(): string;
  59867. }
  59868. }
  59869. declare module BABYLON {
  59870. /**
  59871. * Block used to normalize lerp between 2 values
  59872. */
  59873. export class NLerpBlock extends NodeMaterialBlock {
  59874. /**
  59875. * Creates a new NLerpBlock
  59876. * @param name defines the block name
  59877. */
  59878. constructor(name: string);
  59879. /**
  59880. * Gets the current class name
  59881. * @returns the class name
  59882. */
  59883. getClassName(): string;
  59884. /**
  59885. * Gets the left operand input component
  59886. */
  59887. get left(): NodeMaterialConnectionPoint;
  59888. /**
  59889. * Gets the right operand input component
  59890. */
  59891. get right(): NodeMaterialConnectionPoint;
  59892. /**
  59893. * Gets the gradient operand input component
  59894. */
  59895. get gradient(): NodeMaterialConnectionPoint;
  59896. /**
  59897. * Gets the output component
  59898. */
  59899. get output(): NodeMaterialConnectionPoint;
  59900. protected _buildBlock(state: NodeMaterialBuildState): this;
  59901. }
  59902. }
  59903. declare module BABYLON {
  59904. /**
  59905. * block used to Generate a Worley Noise 3D Noise Pattern
  59906. */
  59907. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59908. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59909. manhattanDistance: boolean;
  59910. /**
  59911. * Creates a new WorleyNoise3DBlock
  59912. * @param name defines the block name
  59913. */
  59914. constructor(name: string);
  59915. /**
  59916. * Gets the current class name
  59917. * @returns the class name
  59918. */
  59919. getClassName(): string;
  59920. /**
  59921. * Gets the seed input component
  59922. */
  59923. get seed(): NodeMaterialConnectionPoint;
  59924. /**
  59925. * Gets the jitter input component
  59926. */
  59927. get jitter(): NodeMaterialConnectionPoint;
  59928. /**
  59929. * Gets the output component
  59930. */
  59931. get output(): NodeMaterialConnectionPoint;
  59932. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59933. /**
  59934. * Exposes the properties to the UI?
  59935. */
  59936. protected _dumpPropertiesCode(): string;
  59937. /**
  59938. * Exposes the properties to the Seralize?
  59939. */
  59940. serialize(): any;
  59941. /**
  59942. * Exposes the properties to the deseralize?
  59943. */
  59944. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59945. }
  59946. }
  59947. declare module BABYLON {
  59948. /**
  59949. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59950. */
  59951. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59952. /**
  59953. * Creates a new SimplexPerlin3DBlock
  59954. * @param name defines the block name
  59955. */
  59956. constructor(name: string);
  59957. /**
  59958. * Gets the current class name
  59959. * @returns the class name
  59960. */
  59961. getClassName(): string;
  59962. /**
  59963. * Gets the seed operand input component
  59964. */
  59965. get seed(): NodeMaterialConnectionPoint;
  59966. /**
  59967. * Gets the output component
  59968. */
  59969. get output(): NodeMaterialConnectionPoint;
  59970. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59971. }
  59972. }
  59973. declare module BABYLON {
  59974. /**
  59975. * Block used to blend normals
  59976. */
  59977. export class NormalBlendBlock extends NodeMaterialBlock {
  59978. /**
  59979. * Creates a new NormalBlendBlock
  59980. * @param name defines the block name
  59981. */
  59982. constructor(name: string);
  59983. /**
  59984. * Gets the current class name
  59985. * @returns the class name
  59986. */
  59987. getClassName(): string;
  59988. /**
  59989. * Gets the first input component
  59990. */
  59991. get normalMap0(): NodeMaterialConnectionPoint;
  59992. /**
  59993. * Gets the second input component
  59994. */
  59995. get normalMap1(): NodeMaterialConnectionPoint;
  59996. /**
  59997. * Gets the output component
  59998. */
  59999. get output(): NodeMaterialConnectionPoint;
  60000. protected _buildBlock(state: NodeMaterialBuildState): this;
  60001. }
  60002. }
  60003. declare module BABYLON {
  60004. /**
  60005. * Block used to rotate a 2d vector by a given angle
  60006. */
  60007. export class Rotate2dBlock extends NodeMaterialBlock {
  60008. /**
  60009. * Creates a new Rotate2dBlock
  60010. * @param name defines the block name
  60011. */
  60012. constructor(name: string);
  60013. /**
  60014. * Gets the current class name
  60015. * @returns the class name
  60016. */
  60017. getClassName(): string;
  60018. /**
  60019. * Gets the input vector
  60020. */
  60021. get input(): NodeMaterialConnectionPoint;
  60022. /**
  60023. * Gets the input angle
  60024. */
  60025. get angle(): NodeMaterialConnectionPoint;
  60026. /**
  60027. * Gets the output component
  60028. */
  60029. get output(): NodeMaterialConnectionPoint;
  60030. autoConfigure(material: NodeMaterial): void;
  60031. protected _buildBlock(state: NodeMaterialBuildState): this;
  60032. }
  60033. }
  60034. declare module BABYLON {
  60035. /**
  60036. * Block used to get the reflected vector from a direction and a normal
  60037. */
  60038. export class ReflectBlock extends NodeMaterialBlock {
  60039. /**
  60040. * Creates a new ReflectBlock
  60041. * @param name defines the block name
  60042. */
  60043. constructor(name: string);
  60044. /**
  60045. * Gets the current class name
  60046. * @returns the class name
  60047. */
  60048. getClassName(): string;
  60049. /**
  60050. * Gets the incident component
  60051. */
  60052. get incident(): NodeMaterialConnectionPoint;
  60053. /**
  60054. * Gets the normal component
  60055. */
  60056. get normal(): NodeMaterialConnectionPoint;
  60057. /**
  60058. * Gets the output component
  60059. */
  60060. get output(): NodeMaterialConnectionPoint;
  60061. protected _buildBlock(state: NodeMaterialBuildState): this;
  60062. }
  60063. }
  60064. declare module BABYLON {
  60065. /**
  60066. * Block used to get the refracted vector from a direction and a normal
  60067. */
  60068. export class RefractBlock extends NodeMaterialBlock {
  60069. /**
  60070. * Creates a new RefractBlock
  60071. * @param name defines the block name
  60072. */
  60073. constructor(name: string);
  60074. /**
  60075. * Gets the current class name
  60076. * @returns the class name
  60077. */
  60078. getClassName(): string;
  60079. /**
  60080. * Gets the incident component
  60081. */
  60082. get incident(): NodeMaterialConnectionPoint;
  60083. /**
  60084. * Gets the normal component
  60085. */
  60086. get normal(): NodeMaterialConnectionPoint;
  60087. /**
  60088. * Gets the index of refraction component
  60089. */
  60090. get ior(): NodeMaterialConnectionPoint;
  60091. /**
  60092. * Gets the output component
  60093. */
  60094. get output(): NodeMaterialConnectionPoint;
  60095. protected _buildBlock(state: NodeMaterialBuildState): this;
  60096. }
  60097. }
  60098. declare module BABYLON {
  60099. /**
  60100. * Block used to desaturate a color
  60101. */
  60102. export class DesaturateBlock extends NodeMaterialBlock {
  60103. /**
  60104. * Creates a new DesaturateBlock
  60105. * @param name defines the block name
  60106. */
  60107. constructor(name: string);
  60108. /**
  60109. * Gets the current class name
  60110. * @returns the class name
  60111. */
  60112. getClassName(): string;
  60113. /**
  60114. * Gets the color operand input component
  60115. */
  60116. get color(): NodeMaterialConnectionPoint;
  60117. /**
  60118. * Gets the level operand input component
  60119. */
  60120. get level(): NodeMaterialConnectionPoint;
  60121. /**
  60122. * Gets the output component
  60123. */
  60124. get output(): NodeMaterialConnectionPoint;
  60125. protected _buildBlock(state: NodeMaterialBuildState): this;
  60126. }
  60127. }
  60128. declare module BABYLON {
  60129. /**
  60130. * Effect Render Options
  60131. */
  60132. export interface IEffectRendererOptions {
  60133. /**
  60134. * Defines the vertices positions.
  60135. */
  60136. positions?: number[];
  60137. /**
  60138. * Defines the indices.
  60139. */
  60140. indices?: number[];
  60141. }
  60142. /**
  60143. * Helper class to render one or more effects
  60144. */
  60145. export class EffectRenderer {
  60146. private engine;
  60147. private static _DefaultOptions;
  60148. private _vertexBuffers;
  60149. private _indexBuffer;
  60150. private _ringBufferIndex;
  60151. private _ringScreenBuffer;
  60152. private _fullscreenViewport;
  60153. private _getNextFrameBuffer;
  60154. /**
  60155. * Creates an effect renderer
  60156. * @param engine the engine to use for rendering
  60157. * @param options defines the options of the effect renderer
  60158. */
  60159. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60160. /**
  60161. * Sets the current viewport in normalized coordinates 0-1
  60162. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60163. */
  60164. setViewport(viewport?: Viewport): void;
  60165. /**
  60166. * Binds the embedded attributes buffer to the effect.
  60167. * @param effect Defines the effect to bind the attributes for
  60168. */
  60169. bindBuffers(effect: Effect): void;
  60170. /**
  60171. * Sets the current effect wrapper to use during draw.
  60172. * The effect needs to be ready before calling this api.
  60173. * This also sets the default full screen position attribute.
  60174. * @param effectWrapper Defines the effect to draw with
  60175. */
  60176. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60177. /**
  60178. * Draws a full screen quad.
  60179. */
  60180. draw(): void;
  60181. /**
  60182. * renders one or more effects to a specified texture
  60183. * @param effectWrappers list of effects to renderer
  60184. * @param outputTexture texture to draw to, if null it will render to the screen
  60185. */
  60186. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60187. /**
  60188. * Disposes of the effect renderer
  60189. */
  60190. dispose(): void;
  60191. }
  60192. /**
  60193. * Options to create an EffectWrapper
  60194. */
  60195. interface EffectWrapperCreationOptions {
  60196. /**
  60197. * Engine to use to create the effect
  60198. */
  60199. engine: ThinEngine;
  60200. /**
  60201. * Fragment shader for the effect
  60202. */
  60203. fragmentShader: string;
  60204. /**
  60205. * Vertex shader for the effect
  60206. */
  60207. vertexShader?: string;
  60208. /**
  60209. * Attributes to use in the shader
  60210. */
  60211. attributeNames?: Array<string>;
  60212. /**
  60213. * Uniforms to use in the shader
  60214. */
  60215. uniformNames?: Array<string>;
  60216. /**
  60217. * Texture sampler names to use in the shader
  60218. */
  60219. samplerNames?: Array<string>;
  60220. /**
  60221. * The friendly name of the effect displayed in Spector.
  60222. */
  60223. name?: string;
  60224. }
  60225. /**
  60226. * Wraps an effect to be used for rendering
  60227. */
  60228. export class EffectWrapper {
  60229. /**
  60230. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60231. */
  60232. onApplyObservable: Observable<{}>;
  60233. /**
  60234. * The underlying effect
  60235. */
  60236. effect: Effect;
  60237. /**
  60238. * Creates an effect to be renderer
  60239. * @param creationOptions options to create the effect
  60240. */
  60241. constructor(creationOptions: EffectWrapperCreationOptions);
  60242. /**
  60243. * Disposes of the effect wrapper
  60244. */
  60245. dispose(): void;
  60246. }
  60247. }
  60248. declare module BABYLON {
  60249. /**
  60250. * Helper class to push actions to a pool of workers.
  60251. */
  60252. export class WorkerPool implements IDisposable {
  60253. private _workerInfos;
  60254. private _pendingActions;
  60255. /**
  60256. * Constructor
  60257. * @param workers Array of workers to use for actions
  60258. */
  60259. constructor(workers: Array<Worker>);
  60260. /**
  60261. * Terminates all workers and clears any pending actions.
  60262. */
  60263. dispose(): void;
  60264. /**
  60265. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60266. * pended until a worker has completed its action.
  60267. * @param action The action to perform. Call onComplete when the action is complete.
  60268. */
  60269. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60270. private _execute;
  60271. }
  60272. }
  60273. declare module BABYLON {
  60274. /**
  60275. * Configuration for Draco compression
  60276. */
  60277. export interface IDracoCompressionConfiguration {
  60278. /**
  60279. * Configuration for the decoder.
  60280. */
  60281. decoder: {
  60282. /**
  60283. * The url to the WebAssembly module.
  60284. */
  60285. wasmUrl?: string;
  60286. /**
  60287. * The url to the WebAssembly binary.
  60288. */
  60289. wasmBinaryUrl?: string;
  60290. /**
  60291. * The url to the fallback JavaScript module.
  60292. */
  60293. fallbackUrl?: string;
  60294. };
  60295. }
  60296. /**
  60297. * Draco compression (https://google.github.io/draco/)
  60298. *
  60299. * This class wraps the Draco module.
  60300. *
  60301. * **Encoder**
  60302. *
  60303. * The encoder is not currently implemented.
  60304. *
  60305. * **Decoder**
  60306. *
  60307. * 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.
  60308. *
  60309. * To update the configuration, use the following code:
  60310. * ```javascript
  60311. * DracoCompression.Configuration = {
  60312. * decoder: {
  60313. * wasmUrl: "<url to the WebAssembly library>",
  60314. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60315. * fallbackUrl: "<url to the fallback JavaScript library>",
  60316. * }
  60317. * };
  60318. * ```
  60319. *
  60320. * 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.
  60321. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60322. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60323. *
  60324. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60325. * ```javascript
  60326. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60327. * ```
  60328. *
  60329. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60330. */
  60331. export class DracoCompression implements IDisposable {
  60332. private _workerPoolPromise?;
  60333. private _decoderModulePromise?;
  60334. /**
  60335. * The configuration. Defaults to the following urls:
  60336. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60337. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60338. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60339. */
  60340. static Configuration: IDracoCompressionConfiguration;
  60341. /**
  60342. * Returns true if the decoder configuration is available.
  60343. */
  60344. static get DecoderAvailable(): boolean;
  60345. /**
  60346. * Default number of workers to create when creating the draco compression object.
  60347. */
  60348. static DefaultNumWorkers: number;
  60349. private static GetDefaultNumWorkers;
  60350. private static _Default;
  60351. /**
  60352. * Default instance for the draco compression object.
  60353. */
  60354. static get Default(): DracoCompression;
  60355. /**
  60356. * Constructor
  60357. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60358. */
  60359. constructor(numWorkers?: number);
  60360. /**
  60361. * Stop all async operations and release resources.
  60362. */
  60363. dispose(): void;
  60364. /**
  60365. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60366. * @returns a promise that resolves when ready
  60367. */
  60368. whenReadyAsync(): Promise<void>;
  60369. /**
  60370. * Decode Draco compressed mesh data to vertex data.
  60371. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60372. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60373. * @returns A promise that resolves with the decoded vertex data
  60374. */
  60375. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60376. [kind: string]: number;
  60377. }): Promise<VertexData>;
  60378. }
  60379. }
  60380. declare module BABYLON {
  60381. /**
  60382. * Class for building Constructive Solid Geometry
  60383. */
  60384. export class CSG {
  60385. private polygons;
  60386. /**
  60387. * The world matrix
  60388. */
  60389. matrix: Matrix;
  60390. /**
  60391. * Stores the position
  60392. */
  60393. position: Vector3;
  60394. /**
  60395. * Stores the rotation
  60396. */
  60397. rotation: Vector3;
  60398. /**
  60399. * Stores the rotation quaternion
  60400. */
  60401. rotationQuaternion: Nullable<Quaternion>;
  60402. /**
  60403. * Stores the scaling vector
  60404. */
  60405. scaling: Vector3;
  60406. /**
  60407. * Convert the Mesh to CSG
  60408. * @param mesh The Mesh to convert to CSG
  60409. * @returns A new CSG from the Mesh
  60410. */
  60411. static FromMesh(mesh: Mesh): CSG;
  60412. /**
  60413. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60414. * @param polygons Polygons used to construct a CSG solid
  60415. */
  60416. private static FromPolygons;
  60417. /**
  60418. * Clones, or makes a deep copy, of the CSG
  60419. * @returns A new CSG
  60420. */
  60421. clone(): CSG;
  60422. /**
  60423. * Unions this CSG with another CSG
  60424. * @param csg The CSG to union against this CSG
  60425. * @returns The unioned CSG
  60426. */
  60427. union(csg: CSG): CSG;
  60428. /**
  60429. * Unions this CSG with another CSG in place
  60430. * @param csg The CSG to union against this CSG
  60431. */
  60432. unionInPlace(csg: CSG): void;
  60433. /**
  60434. * Subtracts this CSG with another CSG
  60435. * @param csg The CSG to subtract against this CSG
  60436. * @returns A new CSG
  60437. */
  60438. subtract(csg: CSG): CSG;
  60439. /**
  60440. * Subtracts this CSG with another CSG in place
  60441. * @param csg The CSG to subtact against this CSG
  60442. */
  60443. subtractInPlace(csg: CSG): void;
  60444. /**
  60445. * Intersect this CSG with another CSG
  60446. * @param csg The CSG to intersect against this CSG
  60447. * @returns A new CSG
  60448. */
  60449. intersect(csg: CSG): CSG;
  60450. /**
  60451. * Intersects this CSG with another CSG in place
  60452. * @param csg The CSG to intersect against this CSG
  60453. */
  60454. intersectInPlace(csg: CSG): void;
  60455. /**
  60456. * Return a new CSG solid with solid and empty space switched. This solid is
  60457. * not modified.
  60458. * @returns A new CSG solid with solid and empty space switched
  60459. */
  60460. inverse(): CSG;
  60461. /**
  60462. * Inverses the CSG in place
  60463. */
  60464. inverseInPlace(): void;
  60465. /**
  60466. * This is used to keep meshes transformations so they can be restored
  60467. * when we build back a Babylon Mesh
  60468. * NB : All CSG operations are performed in world coordinates
  60469. * @param csg The CSG to copy the transform attributes from
  60470. * @returns This CSG
  60471. */
  60472. copyTransformAttributes(csg: CSG): CSG;
  60473. /**
  60474. * Build Raw mesh from CSG
  60475. * Coordinates here are in world space
  60476. * @param name The name of the mesh geometry
  60477. * @param scene The Scene
  60478. * @param keepSubMeshes Specifies if the submeshes should be kept
  60479. * @returns A new Mesh
  60480. */
  60481. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60482. /**
  60483. * Build Mesh from CSG taking material and transforms into account
  60484. * @param name The name of the Mesh
  60485. * @param material The material of the Mesh
  60486. * @param scene The Scene
  60487. * @param keepSubMeshes Specifies if submeshes should be kept
  60488. * @returns The new Mesh
  60489. */
  60490. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60491. }
  60492. }
  60493. declare module BABYLON {
  60494. /**
  60495. * Class used to create a trail following a mesh
  60496. */
  60497. export class TrailMesh extends Mesh {
  60498. private _generator;
  60499. private _autoStart;
  60500. private _running;
  60501. private _diameter;
  60502. private _length;
  60503. private _sectionPolygonPointsCount;
  60504. private _sectionVectors;
  60505. private _sectionNormalVectors;
  60506. private _beforeRenderObserver;
  60507. /**
  60508. * @constructor
  60509. * @param name The value used by scene.getMeshByName() to do a lookup.
  60510. * @param generator The mesh or transform node to generate a trail.
  60511. * @param scene The scene to add this mesh to.
  60512. * @param diameter Diameter of trailing mesh. Default is 1.
  60513. * @param length Length of trailing mesh. Default is 60.
  60514. * @param autoStart Automatically start trailing mesh. Default true.
  60515. */
  60516. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60517. /**
  60518. * "TrailMesh"
  60519. * @returns "TrailMesh"
  60520. */
  60521. getClassName(): string;
  60522. private _createMesh;
  60523. /**
  60524. * Start trailing mesh.
  60525. */
  60526. start(): void;
  60527. /**
  60528. * Stop trailing mesh.
  60529. */
  60530. stop(): void;
  60531. /**
  60532. * Update trailing mesh geometry.
  60533. */
  60534. update(): void;
  60535. /**
  60536. * Returns a new TrailMesh object.
  60537. * @param name is a string, the name given to the new mesh
  60538. * @param newGenerator use new generator object for cloned trail mesh
  60539. * @returns a new mesh
  60540. */
  60541. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60542. /**
  60543. * Serializes this trail mesh
  60544. * @param serializationObject object to write serialization to
  60545. */
  60546. serialize(serializationObject: any): void;
  60547. /**
  60548. * Parses a serialized trail mesh
  60549. * @param parsedMesh the serialized mesh
  60550. * @param scene the scene to create the trail mesh in
  60551. * @returns the created trail mesh
  60552. */
  60553. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60554. }
  60555. }
  60556. declare module BABYLON {
  60557. /**
  60558. * Class containing static functions to help procedurally build meshes
  60559. */
  60560. export class TiledBoxBuilder {
  60561. /**
  60562. * Creates a box mesh
  60563. * 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)
  60564. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60566. * * 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
  60567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60568. * @param name defines the name of the mesh
  60569. * @param options defines the options used to create the mesh
  60570. * @param scene defines the hosting scene
  60571. * @returns the box mesh
  60572. */
  60573. static CreateTiledBox(name: string, options: {
  60574. pattern?: number;
  60575. width?: number;
  60576. height?: number;
  60577. depth?: number;
  60578. tileSize?: number;
  60579. tileWidth?: number;
  60580. tileHeight?: number;
  60581. alignHorizontal?: number;
  60582. alignVertical?: number;
  60583. faceUV?: Vector4[];
  60584. faceColors?: Color4[];
  60585. sideOrientation?: number;
  60586. updatable?: boolean;
  60587. }, scene?: Nullable<Scene>): Mesh;
  60588. }
  60589. }
  60590. declare module BABYLON {
  60591. /**
  60592. * Class containing static functions to help procedurally build meshes
  60593. */
  60594. export class TorusKnotBuilder {
  60595. /**
  60596. * Creates a torus knot mesh
  60597. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60598. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60599. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60600. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60602. * * 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
  60603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60604. * @param name defines the name of the mesh
  60605. * @param options defines the options used to create the mesh
  60606. * @param scene defines the hosting scene
  60607. * @returns the torus knot mesh
  60608. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60609. */
  60610. static CreateTorusKnot(name: string, options: {
  60611. radius?: number;
  60612. tube?: number;
  60613. radialSegments?: number;
  60614. tubularSegments?: number;
  60615. p?: number;
  60616. q?: number;
  60617. updatable?: boolean;
  60618. sideOrientation?: number;
  60619. frontUVs?: Vector4;
  60620. backUVs?: Vector4;
  60621. }, scene: any): Mesh;
  60622. }
  60623. }
  60624. declare module BABYLON {
  60625. /**
  60626. * Polygon
  60627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60628. */
  60629. export class Polygon {
  60630. /**
  60631. * Creates a rectangle
  60632. * @param xmin bottom X coord
  60633. * @param ymin bottom Y coord
  60634. * @param xmax top X coord
  60635. * @param ymax top Y coord
  60636. * @returns points that make the resulting rectation
  60637. */
  60638. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60639. /**
  60640. * Creates a circle
  60641. * @param radius radius of circle
  60642. * @param cx scale in x
  60643. * @param cy scale in y
  60644. * @param numberOfSides number of sides that make up the circle
  60645. * @returns points that make the resulting circle
  60646. */
  60647. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60648. /**
  60649. * Creates a polygon from input string
  60650. * @param input Input polygon data
  60651. * @returns the parsed points
  60652. */
  60653. static Parse(input: string): Vector2[];
  60654. /**
  60655. * Starts building a polygon from x and y coordinates
  60656. * @param x x coordinate
  60657. * @param y y coordinate
  60658. * @returns the started path2
  60659. */
  60660. static StartingAt(x: number, y: number): Path2;
  60661. }
  60662. /**
  60663. * Builds a polygon
  60664. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60665. */
  60666. export class PolygonMeshBuilder {
  60667. private _points;
  60668. private _outlinepoints;
  60669. private _holes;
  60670. private _name;
  60671. private _scene;
  60672. private _epoints;
  60673. private _eholes;
  60674. private _addToepoint;
  60675. /**
  60676. * Babylon reference to the earcut plugin.
  60677. */
  60678. bjsEarcut: any;
  60679. /**
  60680. * Creates a PolygonMeshBuilder
  60681. * @param name name of the builder
  60682. * @param contours Path of the polygon
  60683. * @param scene scene to add to when creating the mesh
  60684. * @param earcutInjection can be used to inject your own earcut reference
  60685. */
  60686. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60687. /**
  60688. * Adds a whole within the polygon
  60689. * @param hole Array of points defining the hole
  60690. * @returns this
  60691. */
  60692. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60693. /**
  60694. * Creates the polygon
  60695. * @param updatable If the mesh should be updatable
  60696. * @param depth The depth of the mesh created
  60697. * @returns the created mesh
  60698. */
  60699. build(updatable?: boolean, depth?: number): Mesh;
  60700. /**
  60701. * Creates the polygon
  60702. * @param depth The depth of the mesh created
  60703. * @returns the created VertexData
  60704. */
  60705. buildVertexData(depth?: number): VertexData;
  60706. /**
  60707. * Adds a side to the polygon
  60708. * @param positions points that make the polygon
  60709. * @param normals normals of the polygon
  60710. * @param uvs uvs of the polygon
  60711. * @param indices indices of the polygon
  60712. * @param bounds bounds of the polygon
  60713. * @param points points of the polygon
  60714. * @param depth depth of the polygon
  60715. * @param flip flip of the polygon
  60716. */
  60717. private addSide;
  60718. }
  60719. }
  60720. declare module BABYLON {
  60721. /**
  60722. * Class containing static functions to help procedurally build meshes
  60723. */
  60724. export class PolygonBuilder {
  60725. /**
  60726. * Creates a polygon mesh
  60727. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60728. * * 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
  60729. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60731. * * 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)
  60732. * * Remember you can only change the shape positions, not their number when updating a polygon
  60733. * @param name defines the name of the mesh
  60734. * @param options defines the options used to create the mesh
  60735. * @param scene defines the hosting scene
  60736. * @param earcutInjection can be used to inject your own earcut reference
  60737. * @returns the polygon mesh
  60738. */
  60739. static CreatePolygon(name: string, options: {
  60740. shape: Vector3[];
  60741. holes?: Vector3[][];
  60742. depth?: number;
  60743. faceUV?: Vector4[];
  60744. faceColors?: Color4[];
  60745. updatable?: boolean;
  60746. sideOrientation?: number;
  60747. frontUVs?: Vector4;
  60748. backUVs?: Vector4;
  60749. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60750. /**
  60751. * Creates an extruded polygon mesh, with depth in the Y direction.
  60752. * * 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)
  60753. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60754. * @param name defines the name of the mesh
  60755. * @param options defines the options used to create the mesh
  60756. * @param scene defines the hosting scene
  60757. * @param earcutInjection can be used to inject your own earcut reference
  60758. * @returns the polygon mesh
  60759. */
  60760. static ExtrudePolygon(name: string, options: {
  60761. shape: Vector3[];
  60762. holes?: Vector3[][];
  60763. depth?: number;
  60764. faceUV?: Vector4[];
  60765. faceColors?: Color4[];
  60766. updatable?: boolean;
  60767. sideOrientation?: number;
  60768. frontUVs?: Vector4;
  60769. backUVs?: Vector4;
  60770. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60771. }
  60772. }
  60773. declare module BABYLON {
  60774. /**
  60775. * Class containing static functions to help procedurally build meshes
  60776. */
  60777. export class LatheBuilder {
  60778. /**
  60779. * Creates lathe mesh.
  60780. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60781. * * 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
  60782. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60783. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60784. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60785. * * 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
  60786. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60787. * * 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
  60788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60789. * * 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
  60790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60792. * @param name defines the name of the mesh
  60793. * @param options defines the options used to create the mesh
  60794. * @param scene defines the hosting scene
  60795. * @returns the lathe mesh
  60796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60797. */
  60798. static CreateLathe(name: string, options: {
  60799. shape: Vector3[];
  60800. radius?: number;
  60801. tessellation?: number;
  60802. clip?: number;
  60803. arc?: number;
  60804. closed?: boolean;
  60805. updatable?: boolean;
  60806. sideOrientation?: number;
  60807. frontUVs?: Vector4;
  60808. backUVs?: Vector4;
  60809. cap?: number;
  60810. invertUV?: boolean;
  60811. }, scene?: Nullable<Scene>): Mesh;
  60812. }
  60813. }
  60814. declare module BABYLON {
  60815. /**
  60816. * Class containing static functions to help procedurally build meshes
  60817. */
  60818. export class TiledPlaneBuilder {
  60819. /**
  60820. * Creates a tiled plane mesh
  60821. * * The parameter `pattern` will, depending on value, do nothing or
  60822. * * * flip (reflect about central vertical) alternate tiles across and up
  60823. * * * flip every tile on alternate rows
  60824. * * * rotate (180 degs) alternate tiles across and up
  60825. * * * rotate every tile on alternate rows
  60826. * * * flip and rotate alternate tiles across and up
  60827. * * * flip and rotate every tile on alternate rows
  60828. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60829. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60830. * * 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
  60831. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60832. * * 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)
  60833. * * 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)
  60834. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60835. * @param name defines the name of the mesh
  60836. * @param options defines the options used to create the mesh
  60837. * @param scene defines the hosting scene
  60838. * @returns the box mesh
  60839. */
  60840. static CreateTiledPlane(name: string, options: {
  60841. pattern?: number;
  60842. tileSize?: number;
  60843. tileWidth?: number;
  60844. tileHeight?: number;
  60845. size?: number;
  60846. width?: number;
  60847. height?: number;
  60848. alignHorizontal?: number;
  60849. alignVertical?: number;
  60850. sideOrientation?: number;
  60851. frontUVs?: Vector4;
  60852. backUVs?: Vector4;
  60853. updatable?: boolean;
  60854. }, scene?: Nullable<Scene>): Mesh;
  60855. }
  60856. }
  60857. declare module BABYLON {
  60858. /**
  60859. * Class containing static functions to help procedurally build meshes
  60860. */
  60861. export class TubeBuilder {
  60862. /**
  60863. * Creates a tube mesh.
  60864. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60865. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60866. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60867. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60868. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60869. * * 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)
  60870. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60871. * * 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
  60872. * * 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
  60873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60874. * * 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
  60875. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60877. * @param name defines the name of the mesh
  60878. * @param options defines the options used to create the mesh
  60879. * @param scene defines the hosting scene
  60880. * @returns the tube mesh
  60881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60882. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60883. */
  60884. static CreateTube(name: string, options: {
  60885. path: Vector3[];
  60886. radius?: number;
  60887. tessellation?: number;
  60888. radiusFunction?: {
  60889. (i: number, distance: number): number;
  60890. };
  60891. cap?: number;
  60892. arc?: number;
  60893. updatable?: boolean;
  60894. sideOrientation?: number;
  60895. frontUVs?: Vector4;
  60896. backUVs?: Vector4;
  60897. instance?: Mesh;
  60898. invertUV?: boolean;
  60899. }, scene?: Nullable<Scene>): Mesh;
  60900. }
  60901. }
  60902. declare module BABYLON {
  60903. /**
  60904. * Class containing static functions to help procedurally build meshes
  60905. */
  60906. export class IcoSphereBuilder {
  60907. /**
  60908. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60909. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60910. * * 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`)
  60911. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60912. * * 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
  60913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60914. * * 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
  60915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60916. * @param name defines the name of the mesh
  60917. * @param options defines the options used to create the mesh
  60918. * @param scene defines the hosting scene
  60919. * @returns the icosahedron mesh
  60920. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60921. */
  60922. static CreateIcoSphere(name: string, options: {
  60923. radius?: number;
  60924. radiusX?: number;
  60925. radiusY?: number;
  60926. radiusZ?: number;
  60927. flat?: boolean;
  60928. subdivisions?: number;
  60929. sideOrientation?: number;
  60930. frontUVs?: Vector4;
  60931. backUVs?: Vector4;
  60932. updatable?: boolean;
  60933. }, scene?: Nullable<Scene>): Mesh;
  60934. }
  60935. }
  60936. declare module BABYLON {
  60937. /**
  60938. * Class containing static functions to help procedurally build meshes
  60939. */
  60940. export class DecalBuilder {
  60941. /**
  60942. * Creates a decal mesh.
  60943. * 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
  60944. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60945. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60946. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60947. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60948. * @param name defines the name of the mesh
  60949. * @param sourceMesh defines the mesh where the decal must be applied
  60950. * @param options defines the options used to create the mesh
  60951. * @param scene defines the hosting scene
  60952. * @returns the decal mesh
  60953. * @see https://doc.babylonjs.com/how_to/decals
  60954. */
  60955. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60956. position?: Vector3;
  60957. normal?: Vector3;
  60958. size?: Vector3;
  60959. angle?: number;
  60960. }): Mesh;
  60961. }
  60962. }
  60963. declare module BABYLON {
  60964. /**
  60965. * Class containing static functions to help procedurally build meshes
  60966. */
  60967. export class MeshBuilder {
  60968. /**
  60969. * Creates a box mesh
  60970. * * The parameter `size` sets the size (float) of each box side (default 1)
  60971. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60972. * * 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)
  60973. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60975. * * 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
  60976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60977. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60978. * @param name defines the name of the mesh
  60979. * @param options defines the options used to create the mesh
  60980. * @param scene defines the hosting scene
  60981. * @returns the box mesh
  60982. */
  60983. static CreateBox(name: string, options: {
  60984. size?: number;
  60985. width?: number;
  60986. height?: number;
  60987. depth?: number;
  60988. faceUV?: Vector4[];
  60989. faceColors?: Color4[];
  60990. sideOrientation?: number;
  60991. frontUVs?: Vector4;
  60992. backUVs?: Vector4;
  60993. updatable?: boolean;
  60994. }, scene?: Nullable<Scene>): Mesh;
  60995. /**
  60996. * Creates a tiled box mesh
  60997. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60999. * @param name defines the name of the mesh
  61000. * @param options defines the options used to create the mesh
  61001. * @param scene defines the hosting scene
  61002. * @returns the tiled box mesh
  61003. */
  61004. static CreateTiledBox(name: string, options: {
  61005. pattern?: number;
  61006. size?: number;
  61007. width?: number;
  61008. height?: number;
  61009. depth: number;
  61010. tileSize?: number;
  61011. tileWidth?: number;
  61012. tileHeight?: number;
  61013. faceUV?: Vector4[];
  61014. faceColors?: Color4[];
  61015. alignHorizontal?: number;
  61016. alignVertical?: number;
  61017. sideOrientation?: number;
  61018. updatable?: boolean;
  61019. }, scene?: Nullable<Scene>): Mesh;
  61020. /**
  61021. * Creates a sphere mesh
  61022. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61023. * * 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`)
  61024. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61025. * * 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
  61026. * * 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)
  61027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61028. * * 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
  61029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61030. * @param name defines the name of the mesh
  61031. * @param options defines the options used to create the mesh
  61032. * @param scene defines the hosting scene
  61033. * @returns the sphere mesh
  61034. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61035. */
  61036. static CreateSphere(name: string, options: {
  61037. segments?: number;
  61038. diameter?: number;
  61039. diameterX?: number;
  61040. diameterY?: number;
  61041. diameterZ?: number;
  61042. arc?: number;
  61043. slice?: number;
  61044. sideOrientation?: number;
  61045. frontUVs?: Vector4;
  61046. backUVs?: Vector4;
  61047. updatable?: boolean;
  61048. }, scene?: Nullable<Scene>): Mesh;
  61049. /**
  61050. * Creates a plane polygonal mesh. By default, this is a disc
  61051. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61052. * * 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
  61053. * * 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
  61054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61055. * * 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
  61056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61057. * @param name defines the name of the mesh
  61058. * @param options defines the options used to create the mesh
  61059. * @param scene defines the hosting scene
  61060. * @returns the plane polygonal mesh
  61061. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61062. */
  61063. static CreateDisc(name: string, options: {
  61064. radius?: number;
  61065. tessellation?: number;
  61066. arc?: number;
  61067. updatable?: boolean;
  61068. sideOrientation?: number;
  61069. frontUVs?: Vector4;
  61070. backUVs?: Vector4;
  61071. }, scene?: Nullable<Scene>): Mesh;
  61072. /**
  61073. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61074. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61075. * * 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`)
  61076. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61077. * * 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
  61078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61079. * * 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
  61080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61081. * @param name defines the name of the mesh
  61082. * @param options defines the options used to create the mesh
  61083. * @param scene defines the hosting scene
  61084. * @returns the icosahedron mesh
  61085. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61086. */
  61087. static CreateIcoSphere(name: string, options: {
  61088. radius?: number;
  61089. radiusX?: number;
  61090. radiusY?: number;
  61091. radiusZ?: number;
  61092. flat?: boolean;
  61093. subdivisions?: number;
  61094. sideOrientation?: number;
  61095. frontUVs?: Vector4;
  61096. backUVs?: Vector4;
  61097. updatable?: boolean;
  61098. }, scene?: Nullable<Scene>): Mesh;
  61099. /**
  61100. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61101. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61102. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61103. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61104. * * 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
  61105. * * 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
  61106. * * 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
  61107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61108. * * 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
  61109. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61110. * * 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
  61111. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61112. * * 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
  61113. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61115. * @param name defines the name of the mesh
  61116. * @param options defines the options used to create the mesh
  61117. * @param scene defines the hosting scene
  61118. * @returns the ribbon mesh
  61119. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61120. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61121. */
  61122. static CreateRibbon(name: string, options: {
  61123. pathArray: Vector3[][];
  61124. closeArray?: boolean;
  61125. closePath?: boolean;
  61126. offset?: number;
  61127. updatable?: boolean;
  61128. sideOrientation?: number;
  61129. frontUVs?: Vector4;
  61130. backUVs?: Vector4;
  61131. instance?: Mesh;
  61132. invertUV?: boolean;
  61133. uvs?: Vector2[];
  61134. colors?: Color4[];
  61135. }, scene?: Nullable<Scene>): Mesh;
  61136. /**
  61137. * Creates a cylinder or a cone mesh
  61138. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61139. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61140. * * 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.
  61141. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61142. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61143. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61144. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61145. * * 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).
  61146. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61147. * * 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).
  61148. * * 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
  61149. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61150. * * 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
  61151. * * 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.
  61152. * * If `enclose` is false, a ring surface is one element.
  61153. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61154. * * 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
  61155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61156. * * 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
  61157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61158. * @param name defines the name of the mesh
  61159. * @param options defines the options used to create the mesh
  61160. * @param scene defines the hosting scene
  61161. * @returns the cylinder mesh
  61162. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61163. */
  61164. static CreateCylinder(name: string, options: {
  61165. height?: number;
  61166. diameterTop?: number;
  61167. diameterBottom?: number;
  61168. diameter?: number;
  61169. tessellation?: number;
  61170. subdivisions?: number;
  61171. arc?: number;
  61172. faceColors?: Color4[];
  61173. faceUV?: Vector4[];
  61174. updatable?: boolean;
  61175. hasRings?: boolean;
  61176. enclose?: boolean;
  61177. cap?: number;
  61178. sideOrientation?: number;
  61179. frontUVs?: Vector4;
  61180. backUVs?: Vector4;
  61181. }, scene?: Nullable<Scene>): Mesh;
  61182. /**
  61183. * Creates a torus mesh
  61184. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61185. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61186. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61188. * * 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
  61189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61190. * @param name defines the name of the mesh
  61191. * @param options defines the options used to create the mesh
  61192. * @param scene defines the hosting scene
  61193. * @returns the torus mesh
  61194. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61195. */
  61196. static CreateTorus(name: string, options: {
  61197. diameter?: number;
  61198. thickness?: number;
  61199. tessellation?: number;
  61200. updatable?: boolean;
  61201. sideOrientation?: number;
  61202. frontUVs?: Vector4;
  61203. backUVs?: Vector4;
  61204. }, scene?: Nullable<Scene>): Mesh;
  61205. /**
  61206. * Creates a torus knot mesh
  61207. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61208. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61209. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61210. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61212. * * 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
  61213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61214. * @param name defines the name of the mesh
  61215. * @param options defines the options used to create the mesh
  61216. * @param scene defines the hosting scene
  61217. * @returns the torus knot mesh
  61218. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61219. */
  61220. static CreateTorusKnot(name: string, options: {
  61221. radius?: number;
  61222. tube?: number;
  61223. radialSegments?: number;
  61224. tubularSegments?: number;
  61225. p?: number;
  61226. q?: number;
  61227. updatable?: boolean;
  61228. sideOrientation?: number;
  61229. frontUVs?: Vector4;
  61230. backUVs?: Vector4;
  61231. }, scene?: Nullable<Scene>): Mesh;
  61232. /**
  61233. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61234. * * 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
  61235. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61236. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61237. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61238. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61239. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61240. * * 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
  61241. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61244. * @param name defines the name of the new line system
  61245. * @param options defines the options used to create the line system
  61246. * @param scene defines the hosting scene
  61247. * @returns a new line system mesh
  61248. */
  61249. static CreateLineSystem(name: string, options: {
  61250. lines: Vector3[][];
  61251. updatable?: boolean;
  61252. instance?: Nullable<LinesMesh>;
  61253. colors?: Nullable<Color4[][]>;
  61254. useVertexAlpha?: boolean;
  61255. }, scene: Nullable<Scene>): LinesMesh;
  61256. /**
  61257. * Creates a line mesh
  61258. * 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
  61259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61260. * * The parameter `points` is an array successive Vector3
  61261. * * 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
  61262. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61263. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61264. * * When updating an instance, remember that only point positions can change, not the number of points
  61265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61266. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61267. * @param name defines the name of the new line system
  61268. * @param options defines the options used to create the line system
  61269. * @param scene defines the hosting scene
  61270. * @returns a new line mesh
  61271. */
  61272. static CreateLines(name: string, options: {
  61273. points: Vector3[];
  61274. updatable?: boolean;
  61275. instance?: Nullable<LinesMesh>;
  61276. colors?: Color4[];
  61277. useVertexAlpha?: boolean;
  61278. }, scene?: Nullable<Scene>): LinesMesh;
  61279. /**
  61280. * Creates a dashed line mesh
  61281. * * 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
  61282. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61283. * * The parameter `points` is an array successive Vector3
  61284. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61285. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61286. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61287. * * 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
  61288. * * When updating an instance, remember that only point positions can change, not the number of points
  61289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61290. * @param name defines the name of the mesh
  61291. * @param options defines the options used to create the mesh
  61292. * @param scene defines the hosting scene
  61293. * @returns the dashed line mesh
  61294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61295. */
  61296. static CreateDashedLines(name: string, options: {
  61297. points: Vector3[];
  61298. dashSize?: number;
  61299. gapSize?: number;
  61300. dashNb?: number;
  61301. updatable?: boolean;
  61302. instance?: LinesMesh;
  61303. }, scene?: Nullable<Scene>): LinesMesh;
  61304. /**
  61305. * 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.
  61306. * * 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.
  61307. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61308. * * 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.
  61309. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61310. * * 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
  61311. * * 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
  61312. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61314. * * 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
  61315. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61317. * @param name defines the name of the mesh
  61318. * @param options defines the options used to create the mesh
  61319. * @param scene defines the hosting scene
  61320. * @returns the extruded shape mesh
  61321. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61323. */
  61324. static ExtrudeShape(name: string, options: {
  61325. shape: Vector3[];
  61326. path: Vector3[];
  61327. scale?: number;
  61328. rotation?: number;
  61329. cap?: number;
  61330. updatable?: boolean;
  61331. sideOrientation?: number;
  61332. frontUVs?: Vector4;
  61333. backUVs?: Vector4;
  61334. instance?: Mesh;
  61335. invertUV?: boolean;
  61336. }, scene?: Nullable<Scene>): Mesh;
  61337. /**
  61338. * Creates an custom extruded shape mesh.
  61339. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61340. * * 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.
  61341. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61342. * * 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
  61343. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61344. * * 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
  61345. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61346. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61347. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61348. * * 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
  61349. * * 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
  61350. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61352. * * 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
  61353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61355. * @param name defines the name of the mesh
  61356. * @param options defines the options used to create the mesh
  61357. * @param scene defines the hosting scene
  61358. * @returns the custom extruded shape mesh
  61359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61360. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61362. */
  61363. static ExtrudeShapeCustom(name: string, options: {
  61364. shape: Vector3[];
  61365. path: Vector3[];
  61366. scaleFunction?: any;
  61367. rotationFunction?: any;
  61368. ribbonCloseArray?: boolean;
  61369. ribbonClosePath?: boolean;
  61370. cap?: number;
  61371. updatable?: boolean;
  61372. sideOrientation?: number;
  61373. frontUVs?: Vector4;
  61374. backUVs?: Vector4;
  61375. instance?: Mesh;
  61376. invertUV?: boolean;
  61377. }, scene?: Nullable<Scene>): Mesh;
  61378. /**
  61379. * Creates lathe mesh.
  61380. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61381. * * 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
  61382. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61383. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61384. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61385. * * 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
  61386. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61387. * * 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
  61388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61389. * * 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
  61390. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61392. * @param name defines the name of the mesh
  61393. * @param options defines the options used to create the mesh
  61394. * @param scene defines the hosting scene
  61395. * @returns the lathe mesh
  61396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61397. */
  61398. static CreateLathe(name: string, options: {
  61399. shape: Vector3[];
  61400. radius?: number;
  61401. tessellation?: number;
  61402. clip?: number;
  61403. arc?: number;
  61404. closed?: boolean;
  61405. updatable?: boolean;
  61406. sideOrientation?: number;
  61407. frontUVs?: Vector4;
  61408. backUVs?: Vector4;
  61409. cap?: number;
  61410. invertUV?: boolean;
  61411. }, scene?: Nullable<Scene>): Mesh;
  61412. /**
  61413. * Creates a tiled plane mesh
  61414. * * You can set a limited pattern arrangement with the tiles
  61415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61416. * * 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
  61417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61418. * @param name defines the name of the mesh
  61419. * @param options defines the options used to create the mesh
  61420. * @param scene defines the hosting scene
  61421. * @returns the plane mesh
  61422. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61423. */
  61424. static CreateTiledPlane(name: string, options: {
  61425. pattern?: number;
  61426. tileSize?: number;
  61427. tileWidth?: number;
  61428. tileHeight?: number;
  61429. size?: number;
  61430. width?: number;
  61431. height?: number;
  61432. alignHorizontal?: number;
  61433. alignVertical?: number;
  61434. sideOrientation?: number;
  61435. frontUVs?: Vector4;
  61436. backUVs?: Vector4;
  61437. updatable?: boolean;
  61438. }, scene?: Nullable<Scene>): Mesh;
  61439. /**
  61440. * Creates a plane mesh
  61441. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61442. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61443. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61445. * * 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
  61446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61447. * @param name defines the name of the mesh
  61448. * @param options defines the options used to create the mesh
  61449. * @param scene defines the hosting scene
  61450. * @returns the plane mesh
  61451. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61452. */
  61453. static CreatePlane(name: string, options: {
  61454. size?: number;
  61455. width?: number;
  61456. height?: number;
  61457. sideOrientation?: number;
  61458. frontUVs?: Vector4;
  61459. backUVs?: Vector4;
  61460. updatable?: boolean;
  61461. sourcePlane?: Plane;
  61462. }, scene?: Nullable<Scene>): Mesh;
  61463. /**
  61464. * Creates a ground mesh
  61465. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61466. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61468. * @param name defines the name of the mesh
  61469. * @param options defines the options used to create the mesh
  61470. * @param scene defines the hosting scene
  61471. * @returns the ground mesh
  61472. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61473. */
  61474. static CreateGround(name: string, options: {
  61475. width?: number;
  61476. height?: number;
  61477. subdivisions?: number;
  61478. subdivisionsX?: number;
  61479. subdivisionsY?: number;
  61480. updatable?: boolean;
  61481. }, scene?: Nullable<Scene>): Mesh;
  61482. /**
  61483. * Creates a tiled ground mesh
  61484. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61485. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61486. * * 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
  61487. * * 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
  61488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61489. * @param name defines the name of the mesh
  61490. * @param options defines the options used to create the mesh
  61491. * @param scene defines the hosting scene
  61492. * @returns the tiled ground mesh
  61493. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61494. */
  61495. static CreateTiledGround(name: string, options: {
  61496. xmin: number;
  61497. zmin: number;
  61498. xmax: number;
  61499. zmax: number;
  61500. subdivisions?: {
  61501. w: number;
  61502. h: number;
  61503. };
  61504. precision?: {
  61505. w: number;
  61506. h: number;
  61507. };
  61508. updatable?: boolean;
  61509. }, scene?: Nullable<Scene>): Mesh;
  61510. /**
  61511. * Creates a ground mesh from a height map
  61512. * * The parameter `url` sets the URL of the height map image resource.
  61513. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61514. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61515. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61516. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61517. * * 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.
  61518. * * 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).
  61519. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61521. * @param name defines the name of the mesh
  61522. * @param url defines the url to the height map
  61523. * @param options defines the options used to create the mesh
  61524. * @param scene defines the hosting scene
  61525. * @returns the ground mesh
  61526. * @see https://doc.babylonjs.com/babylon101/height_map
  61527. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61528. */
  61529. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61530. width?: number;
  61531. height?: number;
  61532. subdivisions?: number;
  61533. minHeight?: number;
  61534. maxHeight?: number;
  61535. colorFilter?: Color3;
  61536. alphaFilter?: number;
  61537. updatable?: boolean;
  61538. onReady?: (mesh: GroundMesh) => void;
  61539. }, scene?: Nullable<Scene>): GroundMesh;
  61540. /**
  61541. * Creates a polygon mesh
  61542. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61543. * * 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
  61544. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61546. * * 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)
  61547. * * Remember you can only change the shape positions, not their number when updating a polygon
  61548. * @param name defines the name of the mesh
  61549. * @param options defines the options used to create the mesh
  61550. * @param scene defines the hosting scene
  61551. * @param earcutInjection can be used to inject your own earcut reference
  61552. * @returns the polygon mesh
  61553. */
  61554. static CreatePolygon(name: string, options: {
  61555. shape: Vector3[];
  61556. holes?: Vector3[][];
  61557. depth?: number;
  61558. faceUV?: Vector4[];
  61559. faceColors?: Color4[];
  61560. updatable?: boolean;
  61561. sideOrientation?: number;
  61562. frontUVs?: Vector4;
  61563. backUVs?: Vector4;
  61564. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61565. /**
  61566. * Creates an extruded polygon mesh, with depth in the Y direction.
  61567. * * 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)
  61568. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61569. * @param name defines the name of the mesh
  61570. * @param options defines the options used to create the mesh
  61571. * @param scene defines the hosting scene
  61572. * @param earcutInjection can be used to inject your own earcut reference
  61573. * @returns the polygon mesh
  61574. */
  61575. static ExtrudePolygon(name: string, options: {
  61576. shape: Vector3[];
  61577. holes?: Vector3[][];
  61578. depth?: number;
  61579. faceUV?: Vector4[];
  61580. faceColors?: Color4[];
  61581. updatable?: boolean;
  61582. sideOrientation?: number;
  61583. frontUVs?: Vector4;
  61584. backUVs?: Vector4;
  61585. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61586. /**
  61587. * Creates a tube mesh.
  61588. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61589. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61590. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61591. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61592. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61593. * * 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)
  61594. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61595. * * 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
  61596. * * 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
  61597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61598. * * 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
  61599. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61601. * @param name defines the name of the mesh
  61602. * @param options defines the options used to create the mesh
  61603. * @param scene defines the hosting scene
  61604. * @returns the tube mesh
  61605. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61606. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61607. */
  61608. static CreateTube(name: string, options: {
  61609. path: Vector3[];
  61610. radius?: number;
  61611. tessellation?: number;
  61612. radiusFunction?: {
  61613. (i: number, distance: number): number;
  61614. };
  61615. cap?: number;
  61616. arc?: number;
  61617. updatable?: boolean;
  61618. sideOrientation?: number;
  61619. frontUVs?: Vector4;
  61620. backUVs?: Vector4;
  61621. instance?: Mesh;
  61622. invertUV?: boolean;
  61623. }, scene?: Nullable<Scene>): Mesh;
  61624. /**
  61625. * Creates a polyhedron mesh
  61626. * * 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
  61627. * * The parameter `size` (positive float, default 1) sets the polygon size
  61628. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61629. * * 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`
  61630. * * 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
  61631. * * 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)`)
  61632. * * 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
  61633. * * 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
  61634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61635. * * 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
  61636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61637. * @param name defines the name of the mesh
  61638. * @param options defines the options used to create the mesh
  61639. * @param scene defines the hosting scene
  61640. * @returns the polyhedron mesh
  61641. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61642. */
  61643. static CreatePolyhedron(name: string, options: {
  61644. type?: number;
  61645. size?: number;
  61646. sizeX?: number;
  61647. sizeY?: number;
  61648. sizeZ?: number;
  61649. custom?: any;
  61650. faceUV?: Vector4[];
  61651. faceColors?: Color4[];
  61652. flat?: boolean;
  61653. updatable?: boolean;
  61654. sideOrientation?: number;
  61655. frontUVs?: Vector4;
  61656. backUVs?: Vector4;
  61657. }, scene?: Nullable<Scene>): Mesh;
  61658. /**
  61659. * Creates a decal mesh.
  61660. * 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
  61661. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61662. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61663. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61664. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61665. * @param name defines the name of the mesh
  61666. * @param sourceMesh defines the mesh where the decal must be applied
  61667. * @param options defines the options used to create the mesh
  61668. * @param scene defines the hosting scene
  61669. * @returns the decal mesh
  61670. * @see https://doc.babylonjs.com/how_to/decals
  61671. */
  61672. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61673. position?: Vector3;
  61674. normal?: Vector3;
  61675. size?: Vector3;
  61676. angle?: number;
  61677. }): Mesh;
  61678. }
  61679. }
  61680. declare module BABYLON {
  61681. /**
  61682. * A simplifier interface for future simplification implementations
  61683. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61684. */
  61685. export interface ISimplifier {
  61686. /**
  61687. * Simplification of a given mesh according to the given settings.
  61688. * Since this requires computation, it is assumed that the function runs async.
  61689. * @param settings The settings of the simplification, including quality and distance
  61690. * @param successCallback A callback that will be called after the mesh was simplified.
  61691. * @param errorCallback in case of an error, this callback will be called. optional.
  61692. */
  61693. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61694. }
  61695. /**
  61696. * Expected simplification settings.
  61697. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61698. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61699. */
  61700. export interface ISimplificationSettings {
  61701. /**
  61702. * Gets or sets the expected quality
  61703. */
  61704. quality: number;
  61705. /**
  61706. * Gets or sets the distance when this optimized version should be used
  61707. */
  61708. distance: number;
  61709. /**
  61710. * Gets an already optimized mesh
  61711. */
  61712. optimizeMesh?: boolean;
  61713. }
  61714. /**
  61715. * Class used to specify simplification options
  61716. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61717. */
  61718. export class SimplificationSettings implements ISimplificationSettings {
  61719. /** expected quality */
  61720. quality: number;
  61721. /** distance when this optimized version should be used */
  61722. distance: number;
  61723. /** already optimized mesh */
  61724. optimizeMesh?: boolean | undefined;
  61725. /**
  61726. * Creates a SimplificationSettings
  61727. * @param quality expected quality
  61728. * @param distance distance when this optimized version should be used
  61729. * @param optimizeMesh already optimized mesh
  61730. */
  61731. constructor(
  61732. /** expected quality */
  61733. quality: number,
  61734. /** distance when this optimized version should be used */
  61735. distance: number,
  61736. /** already optimized mesh */
  61737. optimizeMesh?: boolean | undefined);
  61738. }
  61739. /**
  61740. * Interface used to define a simplification task
  61741. */
  61742. export interface ISimplificationTask {
  61743. /**
  61744. * Array of settings
  61745. */
  61746. settings: Array<ISimplificationSettings>;
  61747. /**
  61748. * Simplification type
  61749. */
  61750. simplificationType: SimplificationType;
  61751. /**
  61752. * Mesh to simplify
  61753. */
  61754. mesh: Mesh;
  61755. /**
  61756. * Callback called on success
  61757. */
  61758. successCallback?: () => void;
  61759. /**
  61760. * Defines if parallel processing can be used
  61761. */
  61762. parallelProcessing: boolean;
  61763. }
  61764. /**
  61765. * Queue used to order the simplification tasks
  61766. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61767. */
  61768. export class SimplificationQueue {
  61769. private _simplificationArray;
  61770. /**
  61771. * Gets a boolean indicating that the process is still running
  61772. */
  61773. running: boolean;
  61774. /**
  61775. * Creates a new queue
  61776. */
  61777. constructor();
  61778. /**
  61779. * Adds a new simplification task
  61780. * @param task defines a task to add
  61781. */
  61782. addTask(task: ISimplificationTask): void;
  61783. /**
  61784. * Execute next task
  61785. */
  61786. executeNext(): void;
  61787. /**
  61788. * Execute a simplification task
  61789. * @param task defines the task to run
  61790. */
  61791. runSimplification(task: ISimplificationTask): void;
  61792. private getSimplifier;
  61793. }
  61794. /**
  61795. * The implemented types of simplification
  61796. * At the moment only Quadratic Error Decimation is implemented
  61797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61798. */
  61799. export enum SimplificationType {
  61800. /** Quadratic error decimation */
  61801. QUADRATIC = 0
  61802. }
  61803. /**
  61804. * An implementation of the Quadratic Error simplification algorithm.
  61805. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  61806. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  61807. * @author RaananW
  61808. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61809. */
  61810. export class QuadraticErrorSimplification implements ISimplifier {
  61811. private _mesh;
  61812. private triangles;
  61813. private vertices;
  61814. private references;
  61815. private _reconstructedMesh;
  61816. /** Gets or sets the number pf sync interations */
  61817. syncIterations: number;
  61818. /** Gets or sets the aggressiveness of the simplifier */
  61819. aggressiveness: number;
  61820. /** Gets or sets the number of allowed iterations for decimation */
  61821. decimationIterations: number;
  61822. /** Gets or sets the espilon to use for bounding box computation */
  61823. boundingBoxEpsilon: number;
  61824. /**
  61825. * Creates a new QuadraticErrorSimplification
  61826. * @param _mesh defines the target mesh
  61827. */
  61828. constructor(_mesh: Mesh);
  61829. /**
  61830. * Simplification of a given mesh according to the given settings.
  61831. * Since this requires computation, it is assumed that the function runs async.
  61832. * @param settings The settings of the simplification, including quality and distance
  61833. * @param successCallback A callback that will be called after the mesh was simplified.
  61834. */
  61835. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  61836. private runDecimation;
  61837. private initWithMesh;
  61838. private init;
  61839. private reconstructMesh;
  61840. private initDecimatedMesh;
  61841. private isFlipped;
  61842. private updateTriangles;
  61843. private identifyBorder;
  61844. private updateMesh;
  61845. private vertexError;
  61846. private calculateError;
  61847. }
  61848. }
  61849. declare module BABYLON {
  61850. interface Scene {
  61851. /** @hidden (Backing field) */
  61852. _simplificationQueue: SimplificationQueue;
  61853. /**
  61854. * Gets or sets the simplification queue attached to the scene
  61855. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61856. */
  61857. simplificationQueue: SimplificationQueue;
  61858. }
  61859. interface Mesh {
  61860. /**
  61861. * Simplify the mesh according to the given array of settings.
  61862. * Function will return immediately and will simplify async
  61863. * @param settings a collection of simplification settings
  61864. * @param parallelProcessing should all levels calculate parallel or one after the other
  61865. * @param simplificationType the type of simplification to run
  61866. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61867. * @returns the current mesh
  61868. */
  61869. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61870. }
  61871. /**
  61872. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61873. * created in a scene
  61874. */
  61875. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61876. /**
  61877. * The component name helpfull to identify the component in the list of scene components.
  61878. */
  61879. readonly name: string;
  61880. /**
  61881. * The scene the component belongs to.
  61882. */
  61883. scene: Scene;
  61884. /**
  61885. * Creates a new instance of the component for the given scene
  61886. * @param scene Defines the scene to register the component in
  61887. */
  61888. constructor(scene: Scene);
  61889. /**
  61890. * Registers the component in a given scene
  61891. */
  61892. register(): void;
  61893. /**
  61894. * Rebuilds the elements related to this component in case of
  61895. * context lost for instance.
  61896. */
  61897. rebuild(): void;
  61898. /**
  61899. * Disposes the component and the associated ressources
  61900. */
  61901. dispose(): void;
  61902. private _beforeCameraUpdate;
  61903. }
  61904. }
  61905. declare module BABYLON {
  61906. /**
  61907. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61908. */
  61909. export interface INavigationEnginePlugin {
  61910. /**
  61911. * plugin name
  61912. */
  61913. name: string;
  61914. /**
  61915. * Creates a navigation mesh
  61916. * @param meshes array of all the geometry used to compute the navigatio mesh
  61917. * @param parameters bunch of parameters used to filter geometry
  61918. */
  61919. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61920. /**
  61921. * Create a navigation mesh debug mesh
  61922. * @param scene is where the mesh will be added
  61923. * @returns debug display mesh
  61924. */
  61925. createDebugNavMesh(scene: Scene): Mesh;
  61926. /**
  61927. * Get a navigation mesh constrained position, closest to the parameter position
  61928. * @param position world position
  61929. * @returns the closest point to position constrained by the navigation mesh
  61930. */
  61931. getClosestPoint(position: Vector3): Vector3;
  61932. /**
  61933. * Get a navigation mesh constrained position, within a particular radius
  61934. * @param position world position
  61935. * @param maxRadius the maximum distance to the constrained world position
  61936. * @returns the closest point to position constrained by the navigation mesh
  61937. */
  61938. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61939. /**
  61940. * Compute the final position from a segment made of destination-position
  61941. * @param position world position
  61942. * @param destination world position
  61943. * @returns the resulting point along the navmesh
  61944. */
  61945. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61946. /**
  61947. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61948. * @param start world position
  61949. * @param end world position
  61950. * @returns array containing world position composing the path
  61951. */
  61952. computePath(start: Vector3, end: Vector3): Vector3[];
  61953. /**
  61954. * If this plugin is supported
  61955. * @returns true if plugin is supported
  61956. */
  61957. isSupported(): boolean;
  61958. /**
  61959. * Create a new Crowd so you can add agents
  61960. * @param maxAgents the maximum agent count in the crowd
  61961. * @param maxAgentRadius the maximum radius an agent can have
  61962. * @param scene to attach the crowd to
  61963. * @returns the crowd you can add agents to
  61964. */
  61965. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61966. /**
  61967. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61968. * The queries will try to find a solution within those bounds
  61969. * default is (1,1,1)
  61970. * @param extent x,y,z value that define the extent around the queries point of reference
  61971. */
  61972. setDefaultQueryExtent(extent: Vector3): void;
  61973. /**
  61974. * Get the Bounding box extent specified by setDefaultQueryExtent
  61975. * @returns the box extent values
  61976. */
  61977. getDefaultQueryExtent(): Vector3;
  61978. /**
  61979. * Release all resources
  61980. */
  61981. dispose(): void;
  61982. }
  61983. /**
  61984. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61985. */
  61986. export interface ICrowd {
  61987. /**
  61988. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61989. * You can attach anything to that node. The node position is updated in the scene update tick.
  61990. * @param pos world position that will be constrained by the navigation mesh
  61991. * @param parameters agent parameters
  61992. * @param transform hooked to the agent that will be update by the scene
  61993. * @returns agent index
  61994. */
  61995. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61996. /**
  61997. * Returns the agent position in world space
  61998. * @param index agent index returned by addAgent
  61999. * @returns world space position
  62000. */
  62001. getAgentPosition(index: number): Vector3;
  62002. /**
  62003. * Gets the agent velocity in world space
  62004. * @param index agent index returned by addAgent
  62005. * @returns world space velocity
  62006. */
  62007. getAgentVelocity(index: number): Vector3;
  62008. /**
  62009. * remove a particular agent previously created
  62010. * @param index agent index returned by addAgent
  62011. */
  62012. removeAgent(index: number): void;
  62013. /**
  62014. * get the list of all agents attached to this crowd
  62015. * @returns list of agent indices
  62016. */
  62017. getAgents(): number[];
  62018. /**
  62019. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62020. * @param deltaTime in seconds
  62021. */
  62022. update(deltaTime: number): void;
  62023. /**
  62024. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62025. * @param index agent index returned by addAgent
  62026. * @param destination targeted world position
  62027. */
  62028. agentGoto(index: number, destination: Vector3): void;
  62029. /**
  62030. * Teleport the agent to a new position
  62031. * @param index agent index returned by addAgent
  62032. * @param destination targeted world position
  62033. */
  62034. agentTeleport(index: number, destination: Vector3): void;
  62035. /**
  62036. * Update agent parameters
  62037. * @param index agent index returned by addAgent
  62038. * @param parameters agent parameters
  62039. */
  62040. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62041. /**
  62042. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62043. * The queries will try to find a solution within those bounds
  62044. * default is (1,1,1)
  62045. * @param extent x,y,z value that define the extent around the queries point of reference
  62046. */
  62047. setDefaultQueryExtent(extent: Vector3): void;
  62048. /**
  62049. * Get the Bounding box extent specified by setDefaultQueryExtent
  62050. * @returns the box extent values
  62051. */
  62052. getDefaultQueryExtent(): Vector3;
  62053. /**
  62054. * Release all resources
  62055. */
  62056. dispose(): void;
  62057. }
  62058. /**
  62059. * Configures an agent
  62060. */
  62061. export interface IAgentParameters {
  62062. /**
  62063. * Agent radius. [Limit: >= 0]
  62064. */
  62065. radius: number;
  62066. /**
  62067. * Agent height. [Limit: > 0]
  62068. */
  62069. height: number;
  62070. /**
  62071. * Maximum allowed acceleration. [Limit: >= 0]
  62072. */
  62073. maxAcceleration: number;
  62074. /**
  62075. * Maximum allowed speed. [Limit: >= 0]
  62076. */
  62077. maxSpeed: number;
  62078. /**
  62079. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62080. */
  62081. collisionQueryRange: number;
  62082. /**
  62083. * The path visibility optimization range. [Limit: > 0]
  62084. */
  62085. pathOptimizationRange: number;
  62086. /**
  62087. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62088. */
  62089. separationWeight: number;
  62090. }
  62091. /**
  62092. * Configures the navigation mesh creation
  62093. */
  62094. export interface INavMeshParameters {
  62095. /**
  62096. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62097. */
  62098. cs: number;
  62099. /**
  62100. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62101. */
  62102. ch: number;
  62103. /**
  62104. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62105. */
  62106. walkableSlopeAngle: number;
  62107. /**
  62108. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62109. * be considered walkable. [Limit: >= 3] [Units: vx]
  62110. */
  62111. walkableHeight: number;
  62112. /**
  62113. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62114. */
  62115. walkableClimb: number;
  62116. /**
  62117. * The distance to erode/shrink the walkable area of the heightfield away from
  62118. * obstructions. [Limit: >=0] [Units: vx]
  62119. */
  62120. walkableRadius: number;
  62121. /**
  62122. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62123. */
  62124. maxEdgeLen: number;
  62125. /**
  62126. * The maximum distance a simplfied contour's border edges should deviate
  62127. * the original raw contour. [Limit: >=0] [Units: vx]
  62128. */
  62129. maxSimplificationError: number;
  62130. /**
  62131. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62132. */
  62133. minRegionArea: number;
  62134. /**
  62135. * Any regions with a span count smaller than this value will, if possible,
  62136. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62137. */
  62138. mergeRegionArea: number;
  62139. /**
  62140. * The maximum number of vertices allowed for polygons generated during the
  62141. * contour to polygon conversion process. [Limit: >= 3]
  62142. */
  62143. maxVertsPerPoly: number;
  62144. /**
  62145. * Sets the sampling distance to use when generating the detail mesh.
  62146. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62147. */
  62148. detailSampleDist: number;
  62149. /**
  62150. * The maximum distance the detail mesh surface should deviate from heightfield
  62151. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62152. */
  62153. detailSampleMaxError: number;
  62154. }
  62155. }
  62156. declare module BABYLON {
  62157. /**
  62158. * RecastJS navigation plugin
  62159. */
  62160. export class RecastJSPlugin implements INavigationEnginePlugin {
  62161. /**
  62162. * Reference to the Recast library
  62163. */
  62164. bjsRECAST: any;
  62165. /**
  62166. * plugin name
  62167. */
  62168. name: string;
  62169. /**
  62170. * the first navmesh created. We might extend this to support multiple navmeshes
  62171. */
  62172. navMesh: any;
  62173. /**
  62174. * Initializes the recastJS plugin
  62175. * @param recastInjection can be used to inject your own recast reference
  62176. */
  62177. constructor(recastInjection?: any);
  62178. /**
  62179. * Creates a navigation mesh
  62180. * @param meshes array of all the geometry used to compute the navigatio mesh
  62181. * @param parameters bunch of parameters used to filter geometry
  62182. */
  62183. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62184. /**
  62185. * Create a navigation mesh debug mesh
  62186. * @param scene is where the mesh will be added
  62187. * @returns debug display mesh
  62188. */
  62189. createDebugNavMesh(scene: Scene): Mesh;
  62190. /**
  62191. * Get a navigation mesh constrained position, closest to the parameter position
  62192. * @param position world position
  62193. * @returns the closest point to position constrained by the navigation mesh
  62194. */
  62195. getClosestPoint(position: Vector3): Vector3;
  62196. /**
  62197. * Get a navigation mesh constrained position, within a particular radius
  62198. * @param position world position
  62199. * @param maxRadius the maximum distance to the constrained world position
  62200. * @returns the closest point to position constrained by the navigation mesh
  62201. */
  62202. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62203. /**
  62204. * Compute the final position from a segment made of destination-position
  62205. * @param position world position
  62206. * @param destination world position
  62207. * @returns the resulting point along the navmesh
  62208. */
  62209. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62210. /**
  62211. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62212. * @param start world position
  62213. * @param end world position
  62214. * @returns array containing world position composing the path
  62215. */
  62216. computePath(start: Vector3, end: Vector3): Vector3[];
  62217. /**
  62218. * Create a new Crowd so you can add agents
  62219. * @param maxAgents the maximum agent count in the crowd
  62220. * @param maxAgentRadius the maximum radius an agent can have
  62221. * @param scene to attach the crowd to
  62222. * @returns the crowd you can add agents to
  62223. */
  62224. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62225. /**
  62226. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62227. * The queries will try to find a solution within those bounds
  62228. * default is (1,1,1)
  62229. * @param extent x,y,z value that define the extent around the queries point of reference
  62230. */
  62231. setDefaultQueryExtent(extent: Vector3): void;
  62232. /**
  62233. * Get the Bounding box extent specified by setDefaultQueryExtent
  62234. * @returns the box extent values
  62235. */
  62236. getDefaultQueryExtent(): Vector3;
  62237. /**
  62238. * Disposes
  62239. */
  62240. dispose(): void;
  62241. /**
  62242. * If this plugin is supported
  62243. * @returns true if plugin is supported
  62244. */
  62245. isSupported(): boolean;
  62246. }
  62247. /**
  62248. * Recast detour crowd implementation
  62249. */
  62250. export class RecastJSCrowd implements ICrowd {
  62251. /**
  62252. * Recast/detour plugin
  62253. */
  62254. bjsRECASTPlugin: RecastJSPlugin;
  62255. /**
  62256. * Link to the detour crowd
  62257. */
  62258. recastCrowd: any;
  62259. /**
  62260. * One transform per agent
  62261. */
  62262. transforms: TransformNode[];
  62263. /**
  62264. * All agents created
  62265. */
  62266. agents: number[];
  62267. /**
  62268. * Link to the scene is kept to unregister the crowd from the scene
  62269. */
  62270. private _scene;
  62271. /**
  62272. * Observer for crowd updates
  62273. */
  62274. private _onBeforeAnimationsObserver;
  62275. /**
  62276. * Constructor
  62277. * @param plugin recastJS plugin
  62278. * @param maxAgents the maximum agent count in the crowd
  62279. * @param maxAgentRadius the maximum radius an agent can have
  62280. * @param scene to attach the crowd to
  62281. * @returns the crowd you can add agents to
  62282. */
  62283. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62284. /**
  62285. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62286. * You can attach anything to that node. The node position is updated in the scene update tick.
  62287. * @param pos world position that will be constrained by the navigation mesh
  62288. * @param parameters agent parameters
  62289. * @param transform hooked to the agent that will be update by the scene
  62290. * @returns agent index
  62291. */
  62292. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62293. /**
  62294. * Returns the agent position in world space
  62295. * @param index agent index returned by addAgent
  62296. * @returns world space position
  62297. */
  62298. getAgentPosition(index: number): Vector3;
  62299. /**
  62300. * Returns the agent velocity in world space
  62301. * @param index agent index returned by addAgent
  62302. * @returns world space velocity
  62303. */
  62304. getAgentVelocity(index: number): Vector3;
  62305. /**
  62306. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62307. * @param index agent index returned by addAgent
  62308. * @param destination targeted world position
  62309. */
  62310. agentGoto(index: number, destination: Vector3): void;
  62311. /**
  62312. * Teleport the agent to a new position
  62313. * @param index agent index returned by addAgent
  62314. * @param destination targeted world position
  62315. */
  62316. agentTeleport(index: number, destination: Vector3): void;
  62317. /**
  62318. * Update agent parameters
  62319. * @param index agent index returned by addAgent
  62320. * @param parameters agent parameters
  62321. */
  62322. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62323. /**
  62324. * remove a particular agent previously created
  62325. * @param index agent index returned by addAgent
  62326. */
  62327. removeAgent(index: number): void;
  62328. /**
  62329. * get the list of all agents attached to this crowd
  62330. * @returns list of agent indices
  62331. */
  62332. getAgents(): number[];
  62333. /**
  62334. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62335. * @param deltaTime in seconds
  62336. */
  62337. update(deltaTime: number): void;
  62338. /**
  62339. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62340. * The queries will try to find a solution within those bounds
  62341. * default is (1,1,1)
  62342. * @param extent x,y,z value that define the extent around the queries point of reference
  62343. */
  62344. setDefaultQueryExtent(extent: Vector3): void;
  62345. /**
  62346. * Get the Bounding box extent specified by setDefaultQueryExtent
  62347. * @returns the box extent values
  62348. */
  62349. getDefaultQueryExtent(): Vector3;
  62350. /**
  62351. * Release all resources
  62352. */
  62353. dispose(): void;
  62354. }
  62355. }
  62356. declare module BABYLON {
  62357. /**
  62358. * Class used to enable access to IndexedDB
  62359. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62360. */
  62361. export class Database implements IOfflineProvider {
  62362. private _callbackManifestChecked;
  62363. private _currentSceneUrl;
  62364. private _db;
  62365. private _enableSceneOffline;
  62366. private _enableTexturesOffline;
  62367. private _manifestVersionFound;
  62368. private _mustUpdateRessources;
  62369. private _hasReachedQuota;
  62370. private _isSupported;
  62371. private _idbFactory;
  62372. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62373. private static IsUASupportingBlobStorage;
  62374. /**
  62375. * Gets a boolean indicating if Database storate is enabled (off by default)
  62376. */
  62377. static IDBStorageEnabled: boolean;
  62378. /**
  62379. * Gets a boolean indicating if scene must be saved in the database
  62380. */
  62381. get enableSceneOffline(): boolean;
  62382. /**
  62383. * Gets a boolean indicating if textures must be saved in the database
  62384. */
  62385. get enableTexturesOffline(): boolean;
  62386. /**
  62387. * Creates a new Database
  62388. * @param urlToScene defines the url to load the scene
  62389. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62390. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62391. */
  62392. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62393. private static _ParseURL;
  62394. private static _ReturnFullUrlLocation;
  62395. private _checkManifestFile;
  62396. /**
  62397. * Open the database and make it available
  62398. * @param successCallback defines the callback to call on success
  62399. * @param errorCallback defines the callback to call on error
  62400. */
  62401. open(successCallback: () => void, errorCallback: () => void): void;
  62402. /**
  62403. * Loads an image from the database
  62404. * @param url defines the url to load from
  62405. * @param image defines the target DOM image
  62406. */
  62407. loadImage(url: string, image: HTMLImageElement): void;
  62408. private _loadImageFromDBAsync;
  62409. private _saveImageIntoDBAsync;
  62410. private _checkVersionFromDB;
  62411. private _loadVersionFromDBAsync;
  62412. private _saveVersionIntoDBAsync;
  62413. /**
  62414. * Loads a file from database
  62415. * @param url defines the URL to load from
  62416. * @param sceneLoaded defines a callback to call on success
  62417. * @param progressCallBack defines a callback to call when progress changed
  62418. * @param errorCallback defines a callback to call on error
  62419. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62420. */
  62421. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62422. private _loadFileAsync;
  62423. private _saveFileAsync;
  62424. /**
  62425. * Validates if xhr data is correct
  62426. * @param xhr defines the request to validate
  62427. * @param dataType defines the expected data type
  62428. * @returns true if data is correct
  62429. */
  62430. private static _ValidateXHRData;
  62431. }
  62432. }
  62433. declare module BABYLON {
  62434. /** @hidden */
  62435. export var gpuUpdateParticlesPixelShader: {
  62436. name: string;
  62437. shader: string;
  62438. };
  62439. }
  62440. declare module BABYLON {
  62441. /** @hidden */
  62442. export var gpuUpdateParticlesVertexShader: {
  62443. name: string;
  62444. shader: string;
  62445. };
  62446. }
  62447. declare module BABYLON {
  62448. /** @hidden */
  62449. export var clipPlaneFragmentDeclaration2: {
  62450. name: string;
  62451. shader: string;
  62452. };
  62453. }
  62454. declare module BABYLON {
  62455. /** @hidden */
  62456. export var gpuRenderParticlesPixelShader: {
  62457. name: string;
  62458. shader: string;
  62459. };
  62460. }
  62461. declare module BABYLON {
  62462. /** @hidden */
  62463. export var clipPlaneVertexDeclaration2: {
  62464. name: string;
  62465. shader: string;
  62466. };
  62467. }
  62468. declare module BABYLON {
  62469. /** @hidden */
  62470. export var gpuRenderParticlesVertexShader: {
  62471. name: string;
  62472. shader: string;
  62473. };
  62474. }
  62475. declare module BABYLON {
  62476. /**
  62477. * This represents a GPU particle system in Babylon
  62478. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62479. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62480. */
  62481. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62482. /**
  62483. * The layer mask we are rendering the particles through.
  62484. */
  62485. layerMask: number;
  62486. private _capacity;
  62487. private _activeCount;
  62488. private _currentActiveCount;
  62489. private _accumulatedCount;
  62490. private _renderEffect;
  62491. private _updateEffect;
  62492. private _buffer0;
  62493. private _buffer1;
  62494. private _spriteBuffer;
  62495. private _updateVAO;
  62496. private _renderVAO;
  62497. private _targetIndex;
  62498. private _sourceBuffer;
  62499. private _targetBuffer;
  62500. private _engine;
  62501. private _currentRenderId;
  62502. private _started;
  62503. private _stopped;
  62504. private _timeDelta;
  62505. private _randomTexture;
  62506. private _randomTexture2;
  62507. private _attributesStrideSize;
  62508. private _updateEffectOptions;
  62509. private _randomTextureSize;
  62510. private _actualFrame;
  62511. private readonly _rawTextureWidth;
  62512. /**
  62513. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62514. */
  62515. static get IsSupported(): boolean;
  62516. /**
  62517. * An event triggered when the system is disposed.
  62518. */
  62519. onDisposeObservable: Observable<GPUParticleSystem>;
  62520. /**
  62521. * Gets the maximum number of particles active at the same time.
  62522. * @returns The max number of active particles.
  62523. */
  62524. getCapacity(): number;
  62525. /**
  62526. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62527. * to override the particles.
  62528. */
  62529. forceDepthWrite: boolean;
  62530. /**
  62531. * Gets or set the number of active particles
  62532. */
  62533. get activeParticleCount(): number;
  62534. set activeParticleCount(value: number);
  62535. private _preWarmDone;
  62536. /**
  62537. * Specifies if the particles are updated in emitter local space or world space.
  62538. * This is always false for GPU particles
  62539. */
  62540. get isLocal(): boolean;
  62541. set isLocal(value: boolean);
  62542. /**
  62543. * Is this system ready to be used/rendered
  62544. * @return true if the system is ready
  62545. */
  62546. isReady(): boolean;
  62547. /**
  62548. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62549. * @returns True if it has been started, otherwise false.
  62550. */
  62551. isStarted(): boolean;
  62552. /**
  62553. * Starts the particle system and begins to emit
  62554. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62555. */
  62556. start(delay?: number): void;
  62557. /**
  62558. * Stops the particle system.
  62559. */
  62560. stop(): void;
  62561. /**
  62562. * Remove all active particles
  62563. */
  62564. reset(): void;
  62565. /**
  62566. * Returns the string "GPUParticleSystem"
  62567. * @returns a string containing the class name
  62568. */
  62569. getClassName(): string;
  62570. private _colorGradientsTexture;
  62571. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62572. /**
  62573. * Adds a new color gradient
  62574. * @param gradient defines the gradient to use (between 0 and 1)
  62575. * @param color1 defines the color to affect to the specified gradient
  62576. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62577. * @returns the current particle system
  62578. */
  62579. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62580. /**
  62581. * Remove a specific color gradient
  62582. * @param gradient defines the gradient to remove
  62583. * @returns the current particle system
  62584. */
  62585. removeColorGradient(gradient: number): GPUParticleSystem;
  62586. private _angularSpeedGradientsTexture;
  62587. private _sizeGradientsTexture;
  62588. private _velocityGradientsTexture;
  62589. private _limitVelocityGradientsTexture;
  62590. private _dragGradientsTexture;
  62591. private _addFactorGradient;
  62592. /**
  62593. * Adds a new size gradient
  62594. * @param gradient defines the gradient to use (between 0 and 1)
  62595. * @param factor defines the size factor to affect to the specified gradient
  62596. * @returns the current particle system
  62597. */
  62598. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62599. /**
  62600. * Remove a specific size gradient
  62601. * @param gradient defines the gradient to remove
  62602. * @returns the current particle system
  62603. */
  62604. removeSizeGradient(gradient: number): GPUParticleSystem;
  62605. /**
  62606. * Adds a new angular speed gradient
  62607. * @param gradient defines the gradient to use (between 0 and 1)
  62608. * @param factor defines the angular speed to affect to the specified gradient
  62609. * @returns the current particle system
  62610. */
  62611. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62612. /**
  62613. * Remove a specific angular speed gradient
  62614. * @param gradient defines the gradient to remove
  62615. * @returns the current particle system
  62616. */
  62617. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62618. /**
  62619. * Adds a new velocity gradient
  62620. * @param gradient defines the gradient to use (between 0 and 1)
  62621. * @param factor defines the velocity to affect to the specified gradient
  62622. * @returns the current particle system
  62623. */
  62624. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62625. /**
  62626. * Remove a specific velocity gradient
  62627. * @param gradient defines the gradient to remove
  62628. * @returns the current particle system
  62629. */
  62630. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62631. /**
  62632. * Adds a new limit velocity gradient
  62633. * @param gradient defines the gradient to use (between 0 and 1)
  62634. * @param factor defines the limit velocity value to affect to the specified gradient
  62635. * @returns the current particle system
  62636. */
  62637. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62638. /**
  62639. * Remove a specific limit velocity gradient
  62640. * @param gradient defines the gradient to remove
  62641. * @returns the current particle system
  62642. */
  62643. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62644. /**
  62645. * Adds a new drag gradient
  62646. * @param gradient defines the gradient to use (between 0 and 1)
  62647. * @param factor defines the drag value to affect to the specified gradient
  62648. * @returns the current particle system
  62649. */
  62650. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62651. /**
  62652. * Remove a specific drag gradient
  62653. * @param gradient defines the gradient to remove
  62654. * @returns the current particle system
  62655. */
  62656. removeDragGradient(gradient: number): GPUParticleSystem;
  62657. /**
  62658. * Not supported by GPUParticleSystem
  62659. * @param gradient defines the gradient to use (between 0 and 1)
  62660. * @param factor defines the emit rate value to affect to the specified gradient
  62661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62662. * @returns the current particle system
  62663. */
  62664. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62665. /**
  62666. * Not supported by GPUParticleSystem
  62667. * @param gradient defines the gradient to remove
  62668. * @returns the current particle system
  62669. */
  62670. removeEmitRateGradient(gradient: number): IParticleSystem;
  62671. /**
  62672. * Not supported by GPUParticleSystem
  62673. * @param gradient defines the gradient to use (between 0 and 1)
  62674. * @param factor defines the start size value to affect to the specified gradient
  62675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62676. * @returns the current particle system
  62677. */
  62678. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62679. /**
  62680. * Not supported by GPUParticleSystem
  62681. * @param gradient defines the gradient to remove
  62682. * @returns the current particle system
  62683. */
  62684. removeStartSizeGradient(gradient: number): IParticleSystem;
  62685. /**
  62686. * Not supported by GPUParticleSystem
  62687. * @param gradient defines the gradient to use (between 0 and 1)
  62688. * @param min defines the color remap minimal range
  62689. * @param max defines the color remap maximal range
  62690. * @returns the current particle system
  62691. */
  62692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62693. /**
  62694. * Not supported by GPUParticleSystem
  62695. * @param gradient defines the gradient to remove
  62696. * @returns the current particle system
  62697. */
  62698. removeColorRemapGradient(): IParticleSystem;
  62699. /**
  62700. * Not supported by GPUParticleSystem
  62701. * @param gradient defines the gradient to use (between 0 and 1)
  62702. * @param min defines the alpha remap minimal range
  62703. * @param max defines the alpha remap maximal range
  62704. * @returns the current particle system
  62705. */
  62706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62707. /**
  62708. * Not supported by GPUParticleSystem
  62709. * @param gradient defines the gradient to remove
  62710. * @returns the current particle system
  62711. */
  62712. removeAlphaRemapGradient(): IParticleSystem;
  62713. /**
  62714. * Not supported by GPUParticleSystem
  62715. * @param gradient defines the gradient to use (between 0 and 1)
  62716. * @param color defines the color to affect to the specified gradient
  62717. * @returns the current particle system
  62718. */
  62719. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62720. /**
  62721. * Not supported by GPUParticleSystem
  62722. * @param gradient defines the gradient to remove
  62723. * @returns the current particle system
  62724. */
  62725. removeRampGradient(): IParticleSystem;
  62726. /**
  62727. * Not supported by GPUParticleSystem
  62728. * @returns the list of ramp gradients
  62729. */
  62730. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62731. /**
  62732. * Not supported by GPUParticleSystem
  62733. * Gets or sets a boolean indicating that ramp gradients must be used
  62734. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62735. */
  62736. get useRampGradients(): boolean;
  62737. set useRampGradients(value: boolean);
  62738. /**
  62739. * Not supported by GPUParticleSystem
  62740. * @param gradient defines the gradient to use (between 0 and 1)
  62741. * @param factor defines the life time factor to affect to the specified gradient
  62742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62743. * @returns the current particle system
  62744. */
  62745. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62746. /**
  62747. * Not supported by GPUParticleSystem
  62748. * @param gradient defines the gradient to remove
  62749. * @returns the current particle system
  62750. */
  62751. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62752. /**
  62753. * Instantiates a GPU particle system.
  62754. * 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.
  62755. * @param name The name of the particle system
  62756. * @param options The options used to create the system
  62757. * @param scene The scene the particle system belongs to
  62758. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62759. */
  62760. constructor(name: string, options: Partial<{
  62761. capacity: number;
  62762. randomTextureSize: number;
  62763. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62764. protected _reset(): void;
  62765. private _createUpdateVAO;
  62766. private _createRenderVAO;
  62767. private _initialize;
  62768. /** @hidden */
  62769. _recreateUpdateEffect(): void;
  62770. /** @hidden */
  62771. _recreateRenderEffect(): void;
  62772. /**
  62773. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62774. * @param preWarm defines if we are in the pre-warmimg phase
  62775. */
  62776. animate(preWarm?: boolean): void;
  62777. private _createFactorGradientTexture;
  62778. private _createSizeGradientTexture;
  62779. private _createAngularSpeedGradientTexture;
  62780. private _createVelocityGradientTexture;
  62781. private _createLimitVelocityGradientTexture;
  62782. private _createDragGradientTexture;
  62783. private _createColorGradientTexture;
  62784. /**
  62785. * Renders the particle system in its current state
  62786. * @param preWarm defines if the system should only update the particles but not render them
  62787. * @returns the current number of particles
  62788. */
  62789. render(preWarm?: boolean): number;
  62790. /**
  62791. * Rebuilds the particle system
  62792. */
  62793. rebuild(): void;
  62794. private _releaseBuffers;
  62795. private _releaseVAOs;
  62796. /**
  62797. * Disposes the particle system and free the associated resources
  62798. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62799. */
  62800. dispose(disposeTexture?: boolean): void;
  62801. /**
  62802. * Clones the particle system.
  62803. * @param name The name of the cloned object
  62804. * @param newEmitter The new emitter to use
  62805. * @returns the cloned particle system
  62806. */
  62807. clone(name: string, newEmitter: any): GPUParticleSystem;
  62808. /**
  62809. * Serializes the particle system to a JSON object.
  62810. * @returns the JSON object
  62811. */
  62812. serialize(): any;
  62813. /**
  62814. * Parses a JSON object to create a GPU particle system.
  62815. * @param parsedParticleSystem The JSON object to parse
  62816. * @param scene The scene to create the particle system in
  62817. * @param rootUrl The root url to use to load external dependencies like texture
  62818. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62819. * @returns the parsed GPU particle system
  62820. */
  62821. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62822. }
  62823. }
  62824. declare module BABYLON {
  62825. /**
  62826. * Represents a set of particle systems working together to create a specific effect
  62827. */
  62828. export class ParticleSystemSet implements IDisposable {
  62829. /**
  62830. * Gets or sets base Assets URL
  62831. */
  62832. static BaseAssetsUrl: string;
  62833. private _emitterCreationOptions;
  62834. private _emitterNode;
  62835. /**
  62836. * Gets the particle system list
  62837. */
  62838. systems: IParticleSystem[];
  62839. /**
  62840. * Gets the emitter node used with this set
  62841. */
  62842. get emitterNode(): Nullable<TransformNode>;
  62843. /**
  62844. * Creates a new emitter mesh as a sphere
  62845. * @param options defines the options used to create the sphere
  62846. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62847. * @param scene defines the hosting scene
  62848. */
  62849. setEmitterAsSphere(options: {
  62850. diameter: number;
  62851. segments: number;
  62852. color: Color3;
  62853. }, renderingGroupId: number, scene: Scene): void;
  62854. /**
  62855. * Starts all particle systems of the set
  62856. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62857. */
  62858. start(emitter?: AbstractMesh): void;
  62859. /**
  62860. * Release all associated resources
  62861. */
  62862. dispose(): void;
  62863. /**
  62864. * Serialize the set into a JSON compatible object
  62865. * @returns a JSON compatible representation of the set
  62866. */
  62867. serialize(): any;
  62868. /**
  62869. * Parse a new ParticleSystemSet from a serialized source
  62870. * @param data defines a JSON compatible representation of the set
  62871. * @param scene defines the hosting scene
  62872. * @param gpu defines if we want GPU particles or CPU particles
  62873. * @returns a new ParticleSystemSet
  62874. */
  62875. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62876. }
  62877. }
  62878. declare module BABYLON {
  62879. /**
  62880. * This class is made for on one-liner static method to help creating particle system set.
  62881. */
  62882. export class ParticleHelper {
  62883. /**
  62884. * Gets or sets base Assets URL
  62885. */
  62886. static BaseAssetsUrl: string;
  62887. /**
  62888. * Create a default particle system that you can tweak
  62889. * @param emitter defines the emitter to use
  62890. * @param capacity defines the system capacity (default is 500 particles)
  62891. * @param scene defines the hosting scene
  62892. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62893. * @returns the new Particle system
  62894. */
  62895. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62896. /**
  62897. * This is the main static method (one-liner) of this helper to create different particle systems
  62898. * @param type This string represents the type to the particle system to create
  62899. * @param scene The scene where the particle system should live
  62900. * @param gpu If the system will use gpu
  62901. * @returns the ParticleSystemSet created
  62902. */
  62903. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62904. /**
  62905. * Static function used to export a particle system to a ParticleSystemSet variable.
  62906. * Please note that the emitter shape is not exported
  62907. * @param systems defines the particle systems to export
  62908. * @returns the created particle system set
  62909. */
  62910. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62911. }
  62912. }
  62913. declare module BABYLON {
  62914. interface Engine {
  62915. /**
  62916. * Create an effect to use with particle systems.
  62917. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62918. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62919. * @param uniformsNames defines a list of attribute names
  62920. * @param samplers defines an array of string used to represent textures
  62921. * @param defines defines the string containing the defines to use to compile the shaders
  62922. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62923. * @param onCompiled defines a function to call when the effect creation is successful
  62924. * @param onError defines a function to call when the effect creation has failed
  62925. * @returns the new Effect
  62926. */
  62927. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62928. }
  62929. interface Mesh {
  62930. /**
  62931. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62932. * @returns an array of IParticleSystem
  62933. */
  62934. getEmittedParticleSystems(): IParticleSystem[];
  62935. /**
  62936. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62937. * @returns an array of IParticleSystem
  62938. */
  62939. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62940. }
  62941. /**
  62942. * @hidden
  62943. */
  62944. export var _IDoNeedToBeInTheBuild: number;
  62945. }
  62946. declare module BABYLON {
  62947. /** Defines the 4 color options */
  62948. export enum PointColor {
  62949. /** color value */
  62950. Color = 2,
  62951. /** uv value */
  62952. UV = 1,
  62953. /** random value */
  62954. Random = 0,
  62955. /** stated value */
  62956. Stated = 3
  62957. }
  62958. /**
  62959. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62960. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  62961. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62962. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62963. *
  62964. * Full documentation here : TO BE ENTERED
  62965. */
  62966. export class PointsCloudSystem implements IDisposable {
  62967. /**
  62968. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62969. * Example : var p = SPS.particles[i];
  62970. */
  62971. particles: CloudPoint[];
  62972. /**
  62973. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62974. */
  62975. nbParticles: number;
  62976. /**
  62977. * This a counter for your own usage. It's not set by any SPS functions.
  62978. */
  62979. counter: number;
  62980. /**
  62981. * The PCS name. This name is also given to the underlying mesh.
  62982. */
  62983. name: string;
  62984. /**
  62985. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62986. */
  62987. mesh: Mesh;
  62988. /**
  62989. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62990. * Please read :
  62991. */
  62992. vars: any;
  62993. /**
  62994. * @hidden
  62995. */
  62996. _size: number;
  62997. private _scene;
  62998. private _promises;
  62999. private _positions;
  63000. private _indices;
  63001. private _normals;
  63002. private _colors;
  63003. private _uvs;
  63004. private _indices32;
  63005. private _positions32;
  63006. private _colors32;
  63007. private _uvs32;
  63008. private _updatable;
  63009. private _isVisibilityBoxLocked;
  63010. private _alwaysVisible;
  63011. private _groups;
  63012. private _groupCounter;
  63013. private _computeParticleColor;
  63014. private _computeParticleTexture;
  63015. private _computeParticleRotation;
  63016. private _computeBoundingBox;
  63017. private _isReady;
  63018. /**
  63019. * Creates a PCS (Points Cloud System) object
  63020. * @param name (String) is the PCS name, this will be the underlying mesh name
  63021. * @param pointSize (number) is the size for each point
  63022. * @param scene (Scene) is the scene in which the PCS is added
  63023. * @param options defines the options of the PCS e.g.
  63024. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63025. */
  63026. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63027. updatable?: boolean;
  63028. });
  63029. /**
  63030. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63031. * If no points were added to the PCS, the returned mesh is just a single point.
  63032. * @returns a promise for the created mesh
  63033. */
  63034. buildMeshAsync(): Promise<Mesh>;
  63035. /**
  63036. * @hidden
  63037. */
  63038. private _buildMesh;
  63039. private _addParticle;
  63040. private _randomUnitVector;
  63041. private _getColorIndicesForCoord;
  63042. private _setPointsColorOrUV;
  63043. private _colorFromTexture;
  63044. private _calculateDensity;
  63045. /**
  63046. * Adds points to the PCS in random positions within a unit sphere
  63047. * @param nb (positive integer) the number of particles to be created from this model
  63048. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63049. * @returns the number of groups in the system
  63050. */
  63051. addPoints(nb: number, pointFunction?: any): number;
  63052. /**
  63053. * Adds points to the PCS from the surface of the model shape
  63054. * @param mesh is any Mesh object that will be used as a surface model for the points
  63055. * @param nb (positive integer) the number of particles to be created from this model
  63056. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63057. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63058. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63059. * @returns the number of groups in the system
  63060. */
  63061. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63062. /**
  63063. * Adds points to the PCS inside the model shape
  63064. * @param mesh is any Mesh object that will be used as a surface model for the points
  63065. * @param nb (positive integer) the number of particles to be created from this model
  63066. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63067. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63068. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63069. * @returns the number of groups in the system
  63070. */
  63071. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63072. /**
  63073. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63074. * This method calls `updateParticle()` for each particle of the SPS.
  63075. * For an animated SPS, it is usually called within the render loop.
  63076. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63077. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63078. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63079. * @returns the PCS.
  63080. */
  63081. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63082. /**
  63083. * Disposes the PCS.
  63084. */
  63085. dispose(): void;
  63086. /**
  63087. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63088. * doc :
  63089. * @returns the PCS.
  63090. */
  63091. refreshVisibleSize(): PointsCloudSystem;
  63092. /**
  63093. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63094. * @param size the size (float) of the visibility box
  63095. * note : this doesn't lock the PCS mesh bounding box.
  63096. * doc :
  63097. */
  63098. setVisibilityBox(size: number): void;
  63099. /**
  63100. * Gets whether the PCS is always visible or not
  63101. * doc :
  63102. */
  63103. get isAlwaysVisible(): boolean;
  63104. /**
  63105. * Sets the PCS as always visible or not
  63106. * doc :
  63107. */
  63108. set isAlwaysVisible(val: boolean);
  63109. /**
  63110. * Tells to `setParticles()` to compute the particle rotations or not
  63111. * Default value : false. The PCS is faster when it's set to false
  63112. * Note : particle rotations are only applied to parent particles
  63113. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63114. */
  63115. set computeParticleRotation(val: boolean);
  63116. /**
  63117. * Tells to `setParticles()` to compute the particle colors or not.
  63118. * Default value : true. The PCS is faster when it's set to false.
  63119. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63120. */
  63121. set computeParticleColor(val: boolean);
  63122. set computeParticleTexture(val: boolean);
  63123. /**
  63124. * Gets if `setParticles()` computes the particle colors or not.
  63125. * Default value : false. The PCS is faster when it's set to false.
  63126. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63127. */
  63128. get computeParticleColor(): boolean;
  63129. /**
  63130. * Gets if `setParticles()` computes the particle textures or not.
  63131. * Default value : false. The PCS is faster when it's set to false.
  63132. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63133. */
  63134. get computeParticleTexture(): boolean;
  63135. /**
  63136. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63137. */
  63138. set computeBoundingBox(val: boolean);
  63139. /**
  63140. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63141. */
  63142. get computeBoundingBox(): boolean;
  63143. /**
  63144. * This function does nothing. It may be overwritten to set all the particle first values.
  63145. * The PCS doesn't call this function, you may have to call it by your own.
  63146. * doc :
  63147. */
  63148. initParticles(): void;
  63149. /**
  63150. * This function does nothing. It may be overwritten to recycle a particle
  63151. * The PCS doesn't call this function, you can to call it
  63152. * doc :
  63153. * @param particle The particle to recycle
  63154. * @returns the recycled particle
  63155. */
  63156. recycleParticle(particle: CloudPoint): CloudPoint;
  63157. /**
  63158. * Updates a particle : this function should be overwritten by the user.
  63159. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63160. * doc :
  63161. * @example : just set a particle position or velocity and recycle conditions
  63162. * @param particle The particle to update
  63163. * @returns the updated particle
  63164. */
  63165. updateParticle(particle: CloudPoint): CloudPoint;
  63166. /**
  63167. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63168. * This does nothing and may be overwritten by the user.
  63169. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63170. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63171. * @param update the boolean update value actually passed to setParticles()
  63172. */
  63173. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63174. /**
  63175. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63176. * This will be passed three parameters.
  63177. * This does nothing and may be overwritten by the user.
  63178. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63180. * @param update the boolean update value actually passed to setParticles()
  63181. */
  63182. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63183. }
  63184. }
  63185. declare module BABYLON {
  63186. /**
  63187. * Represents one particle of a points cloud system.
  63188. */
  63189. export class CloudPoint {
  63190. /**
  63191. * particle global index
  63192. */
  63193. idx: number;
  63194. /**
  63195. * The color of the particle
  63196. */
  63197. color: Nullable<Color4>;
  63198. /**
  63199. * The world space position of the particle.
  63200. */
  63201. position: Vector3;
  63202. /**
  63203. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63204. */
  63205. rotation: Vector3;
  63206. /**
  63207. * The world space rotation quaternion of the particle.
  63208. */
  63209. rotationQuaternion: Nullable<Quaternion>;
  63210. /**
  63211. * The uv of the particle.
  63212. */
  63213. uv: Nullable<Vector2>;
  63214. /**
  63215. * The current speed of the particle.
  63216. */
  63217. velocity: Vector3;
  63218. /**
  63219. * The pivot point in the particle local space.
  63220. */
  63221. pivot: Vector3;
  63222. /**
  63223. * Must the particle be translated from its pivot point in its local space ?
  63224. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63225. * Default : false
  63226. */
  63227. translateFromPivot: boolean;
  63228. /**
  63229. * Index of this particle in the global "positions" array (Internal use)
  63230. * @hidden
  63231. */
  63232. _pos: number;
  63233. /**
  63234. * @hidden Index of this particle in the global "indices" array (Internal use)
  63235. */
  63236. _ind: number;
  63237. /**
  63238. * Group this particle belongs to
  63239. */
  63240. _group: PointsGroup;
  63241. /**
  63242. * Group id of this particle
  63243. */
  63244. groupId: number;
  63245. /**
  63246. * Index of the particle in its group id (Internal use)
  63247. */
  63248. idxInGroup: number;
  63249. /**
  63250. * @hidden Particle BoundingInfo object (Internal use)
  63251. */
  63252. _boundingInfo: BoundingInfo;
  63253. /**
  63254. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63255. */
  63256. _pcs: PointsCloudSystem;
  63257. /**
  63258. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63259. */
  63260. _stillInvisible: boolean;
  63261. /**
  63262. * @hidden Last computed particle rotation matrix
  63263. */
  63264. _rotationMatrix: number[];
  63265. /**
  63266. * Parent particle Id, if any.
  63267. * Default null.
  63268. */
  63269. parentId: Nullable<number>;
  63270. /**
  63271. * @hidden Internal global position in the PCS.
  63272. */
  63273. _globalPosition: Vector3;
  63274. /**
  63275. * Creates a Point Cloud object.
  63276. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63277. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63278. * @param group (PointsGroup) is the group the particle belongs to
  63279. * @param groupId (integer) is the group identifier in the PCS.
  63280. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63281. * @param pcs defines the PCS it is associated to
  63282. */
  63283. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63284. /**
  63285. * get point size
  63286. */
  63287. get size(): Vector3;
  63288. /**
  63289. * Set point size
  63290. */
  63291. set size(scale: Vector3);
  63292. /**
  63293. * Legacy support, changed quaternion to rotationQuaternion
  63294. */
  63295. get quaternion(): Nullable<Quaternion>;
  63296. /**
  63297. * Legacy support, changed quaternion to rotationQuaternion
  63298. */
  63299. set quaternion(q: Nullable<Quaternion>);
  63300. /**
  63301. * Returns a boolean. True if the particle intersects a mesh, else false
  63302. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63303. * @param target is the object (point or mesh) what the intersection is computed against
  63304. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63305. * @returns true if it intersects
  63306. */
  63307. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63308. /**
  63309. * get the rotation matrix of the particle
  63310. * @hidden
  63311. */
  63312. getRotationMatrix(m: Matrix): void;
  63313. }
  63314. /**
  63315. * Represents a group of points in a points cloud system
  63316. * * PCS internal tool, don't use it manually.
  63317. */
  63318. export class PointsGroup {
  63319. /**
  63320. * The group id
  63321. * @hidden
  63322. */
  63323. groupID: number;
  63324. /**
  63325. * image data for group (internal use)
  63326. * @hidden
  63327. */
  63328. _groupImageData: Nullable<ArrayBufferView>;
  63329. /**
  63330. * Image Width (internal use)
  63331. * @hidden
  63332. */
  63333. _groupImgWidth: number;
  63334. /**
  63335. * Image Height (internal use)
  63336. * @hidden
  63337. */
  63338. _groupImgHeight: number;
  63339. /**
  63340. * Custom position function (internal use)
  63341. * @hidden
  63342. */
  63343. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63344. /**
  63345. * density per facet for surface points
  63346. * @hidden
  63347. */
  63348. _groupDensity: number[];
  63349. /**
  63350. * Only when points are colored by texture carries pointer to texture list array
  63351. * @hidden
  63352. */
  63353. _textureNb: number;
  63354. /**
  63355. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63356. * PCS internal tool, don't use it manually.
  63357. * @hidden
  63358. */
  63359. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63360. }
  63361. }
  63362. declare module BABYLON {
  63363. interface Scene {
  63364. /** @hidden (Backing field) */
  63365. _physicsEngine: Nullable<IPhysicsEngine>;
  63366. /** @hidden */
  63367. _physicsTimeAccumulator: number;
  63368. /**
  63369. * Gets the current physics engine
  63370. * @returns a IPhysicsEngine or null if none attached
  63371. */
  63372. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63373. /**
  63374. * Enables physics to the current scene
  63375. * @param gravity defines the scene's gravity for the physics engine
  63376. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63377. * @return a boolean indicating if the physics engine was initialized
  63378. */
  63379. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63380. /**
  63381. * Disables and disposes the physics engine associated with the scene
  63382. */
  63383. disablePhysicsEngine(): void;
  63384. /**
  63385. * Gets a boolean indicating if there is an active physics engine
  63386. * @returns a boolean indicating if there is an active physics engine
  63387. */
  63388. isPhysicsEnabled(): boolean;
  63389. /**
  63390. * Deletes a physics compound impostor
  63391. * @param compound defines the compound to delete
  63392. */
  63393. deleteCompoundImpostor(compound: any): void;
  63394. /**
  63395. * An event triggered when physic simulation is about to be run
  63396. */
  63397. onBeforePhysicsObservable: Observable<Scene>;
  63398. /**
  63399. * An event triggered when physic simulation has been done
  63400. */
  63401. onAfterPhysicsObservable: Observable<Scene>;
  63402. }
  63403. interface AbstractMesh {
  63404. /** @hidden */
  63405. _physicsImpostor: Nullable<PhysicsImpostor>;
  63406. /**
  63407. * Gets or sets impostor used for physic simulation
  63408. * @see http://doc.babylonjs.com/features/physics_engine
  63409. */
  63410. physicsImpostor: Nullable<PhysicsImpostor>;
  63411. /**
  63412. * Gets the current physics impostor
  63413. * @see http://doc.babylonjs.com/features/physics_engine
  63414. * @returns a physics impostor or null
  63415. */
  63416. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63417. /** Apply a physic impulse to the mesh
  63418. * @param force defines the force to apply
  63419. * @param contactPoint defines where to apply the force
  63420. * @returns the current mesh
  63421. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63422. */
  63423. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63424. /**
  63425. * Creates a physic joint between two meshes
  63426. * @param otherMesh defines the other mesh to use
  63427. * @param pivot1 defines the pivot to use on this mesh
  63428. * @param pivot2 defines the pivot to use on the other mesh
  63429. * @param options defines additional options (can be plugin dependent)
  63430. * @returns the current mesh
  63431. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63432. */
  63433. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63434. /** @hidden */
  63435. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63436. }
  63437. /**
  63438. * Defines the physics engine scene component responsible to manage a physics engine
  63439. */
  63440. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63441. /**
  63442. * The component name helpful to identify the component in the list of scene components.
  63443. */
  63444. readonly name: string;
  63445. /**
  63446. * The scene the component belongs to.
  63447. */
  63448. scene: Scene;
  63449. /**
  63450. * Creates a new instance of the component for the given scene
  63451. * @param scene Defines the scene to register the component in
  63452. */
  63453. constructor(scene: Scene);
  63454. /**
  63455. * Registers the component in a given scene
  63456. */
  63457. register(): void;
  63458. /**
  63459. * Rebuilds the elements related to this component in case of
  63460. * context lost for instance.
  63461. */
  63462. rebuild(): void;
  63463. /**
  63464. * Disposes the component and the associated ressources
  63465. */
  63466. dispose(): void;
  63467. }
  63468. }
  63469. declare module BABYLON {
  63470. /**
  63471. * A helper for physics simulations
  63472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63473. */
  63474. export class PhysicsHelper {
  63475. private _scene;
  63476. private _physicsEngine;
  63477. /**
  63478. * Initializes the Physics helper
  63479. * @param scene Babylon.js scene
  63480. */
  63481. constructor(scene: Scene);
  63482. /**
  63483. * Applies a radial explosion impulse
  63484. * @param origin the origin of the explosion
  63485. * @param radiusOrEventOptions the radius or the options of radial explosion
  63486. * @param strength the explosion strength
  63487. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63488. * @returns A physics radial explosion event, or null
  63489. */
  63490. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63491. /**
  63492. * Applies a radial explosion force
  63493. * @param origin the origin of the explosion
  63494. * @param radiusOrEventOptions the radius or the options of radial explosion
  63495. * @param strength the explosion strength
  63496. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63497. * @returns A physics radial explosion event, or null
  63498. */
  63499. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63500. /**
  63501. * Creates a gravitational field
  63502. * @param origin the origin of the explosion
  63503. * @param radiusOrEventOptions the radius or the options of radial explosion
  63504. * @param strength the explosion strength
  63505. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63506. * @returns A physics gravitational field event, or null
  63507. */
  63508. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63509. /**
  63510. * Creates a physics updraft event
  63511. * @param origin the origin of the updraft
  63512. * @param radiusOrEventOptions the radius or the options of the updraft
  63513. * @param strength the strength of the updraft
  63514. * @param height the height of the updraft
  63515. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63516. * @returns A physics updraft event, or null
  63517. */
  63518. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63519. /**
  63520. * Creates a physics vortex event
  63521. * @param origin the of the vortex
  63522. * @param radiusOrEventOptions the radius or the options of the vortex
  63523. * @param strength the strength of the vortex
  63524. * @param height the height of the vortex
  63525. * @returns a Physics vortex event, or null
  63526. * A physics vortex event or null
  63527. */
  63528. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63529. }
  63530. /**
  63531. * Represents a physics radial explosion event
  63532. */
  63533. class PhysicsRadialExplosionEvent {
  63534. private _scene;
  63535. private _options;
  63536. private _sphere;
  63537. private _dataFetched;
  63538. /**
  63539. * Initializes a radial explosioin event
  63540. * @param _scene BabylonJS scene
  63541. * @param _options The options for the vortex event
  63542. */
  63543. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63544. /**
  63545. * Returns the data related to the radial explosion event (sphere).
  63546. * @returns The radial explosion event data
  63547. */
  63548. getData(): PhysicsRadialExplosionEventData;
  63549. /**
  63550. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63551. * @param impostor A physics imposter
  63552. * @param origin the origin of the explosion
  63553. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63554. */
  63555. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63556. /**
  63557. * Triggers affecterd impostors callbacks
  63558. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63559. */
  63560. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63561. /**
  63562. * Disposes the sphere.
  63563. * @param force Specifies if the sphere should be disposed by force
  63564. */
  63565. dispose(force?: boolean): void;
  63566. /*** Helpers ***/
  63567. private _prepareSphere;
  63568. private _intersectsWithSphere;
  63569. }
  63570. /**
  63571. * Represents a gravitational field event
  63572. */
  63573. class PhysicsGravitationalFieldEvent {
  63574. private _physicsHelper;
  63575. private _scene;
  63576. private _origin;
  63577. private _options;
  63578. private _tickCallback;
  63579. private _sphere;
  63580. private _dataFetched;
  63581. /**
  63582. * Initializes the physics gravitational field event
  63583. * @param _physicsHelper A physics helper
  63584. * @param _scene BabylonJS scene
  63585. * @param _origin The origin position of the gravitational field event
  63586. * @param _options The options for the vortex event
  63587. */
  63588. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63589. /**
  63590. * Returns the data related to the gravitational field event (sphere).
  63591. * @returns A gravitational field event
  63592. */
  63593. getData(): PhysicsGravitationalFieldEventData;
  63594. /**
  63595. * Enables the gravitational field.
  63596. */
  63597. enable(): void;
  63598. /**
  63599. * Disables the gravitational field.
  63600. */
  63601. disable(): void;
  63602. /**
  63603. * Disposes the sphere.
  63604. * @param force The force to dispose from the gravitational field event
  63605. */
  63606. dispose(force?: boolean): void;
  63607. private _tick;
  63608. }
  63609. /**
  63610. * Represents a physics updraft event
  63611. */
  63612. class PhysicsUpdraftEvent {
  63613. private _scene;
  63614. private _origin;
  63615. private _options;
  63616. private _physicsEngine;
  63617. private _originTop;
  63618. private _originDirection;
  63619. private _tickCallback;
  63620. private _cylinder;
  63621. private _cylinderPosition;
  63622. private _dataFetched;
  63623. /**
  63624. * Initializes the physics updraft event
  63625. * @param _scene BabylonJS scene
  63626. * @param _origin The origin position of the updraft
  63627. * @param _options The options for the updraft event
  63628. */
  63629. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63630. /**
  63631. * Returns the data related to the updraft event (cylinder).
  63632. * @returns A physics updraft event
  63633. */
  63634. getData(): PhysicsUpdraftEventData;
  63635. /**
  63636. * Enables the updraft.
  63637. */
  63638. enable(): void;
  63639. /**
  63640. * Disables the updraft.
  63641. */
  63642. disable(): void;
  63643. /**
  63644. * Disposes the cylinder.
  63645. * @param force Specifies if the updraft should be disposed by force
  63646. */
  63647. dispose(force?: boolean): void;
  63648. private getImpostorHitData;
  63649. private _tick;
  63650. /*** Helpers ***/
  63651. private _prepareCylinder;
  63652. private _intersectsWithCylinder;
  63653. }
  63654. /**
  63655. * Represents a physics vortex event
  63656. */
  63657. class PhysicsVortexEvent {
  63658. private _scene;
  63659. private _origin;
  63660. private _options;
  63661. private _physicsEngine;
  63662. private _originTop;
  63663. private _tickCallback;
  63664. private _cylinder;
  63665. private _cylinderPosition;
  63666. private _dataFetched;
  63667. /**
  63668. * Initializes the physics vortex event
  63669. * @param _scene The BabylonJS scene
  63670. * @param _origin The origin position of the vortex
  63671. * @param _options The options for the vortex event
  63672. */
  63673. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63674. /**
  63675. * Returns the data related to the vortex event (cylinder).
  63676. * @returns The physics vortex event data
  63677. */
  63678. getData(): PhysicsVortexEventData;
  63679. /**
  63680. * Enables the vortex.
  63681. */
  63682. enable(): void;
  63683. /**
  63684. * Disables the cortex.
  63685. */
  63686. disable(): void;
  63687. /**
  63688. * Disposes the sphere.
  63689. * @param force
  63690. */
  63691. dispose(force?: boolean): void;
  63692. private getImpostorHitData;
  63693. private _tick;
  63694. /*** Helpers ***/
  63695. private _prepareCylinder;
  63696. private _intersectsWithCylinder;
  63697. }
  63698. /**
  63699. * Options fot the radial explosion event
  63700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63701. */
  63702. export class PhysicsRadialExplosionEventOptions {
  63703. /**
  63704. * The radius of the sphere for the radial explosion.
  63705. */
  63706. radius: number;
  63707. /**
  63708. * The strenth of the explosion.
  63709. */
  63710. strength: number;
  63711. /**
  63712. * The strenght of the force in correspondence to the distance of the affected object
  63713. */
  63714. falloff: PhysicsRadialImpulseFalloff;
  63715. /**
  63716. * Sphere options for the radial explosion.
  63717. */
  63718. sphere: {
  63719. segments: number;
  63720. diameter: number;
  63721. };
  63722. /**
  63723. * Sphere options for the radial explosion.
  63724. */
  63725. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63726. }
  63727. /**
  63728. * Options fot the updraft event
  63729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63730. */
  63731. export class PhysicsUpdraftEventOptions {
  63732. /**
  63733. * The radius of the cylinder for the vortex
  63734. */
  63735. radius: number;
  63736. /**
  63737. * The strenth of the updraft.
  63738. */
  63739. strength: number;
  63740. /**
  63741. * The height of the cylinder for the updraft.
  63742. */
  63743. height: number;
  63744. /**
  63745. * The mode for the the updraft.
  63746. */
  63747. updraftMode: PhysicsUpdraftMode;
  63748. }
  63749. /**
  63750. * Options fot the vortex event
  63751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63752. */
  63753. export class PhysicsVortexEventOptions {
  63754. /**
  63755. * The radius of the cylinder for the vortex
  63756. */
  63757. radius: number;
  63758. /**
  63759. * The strenth of the vortex.
  63760. */
  63761. strength: number;
  63762. /**
  63763. * The height of the cylinder for the vortex.
  63764. */
  63765. height: number;
  63766. /**
  63767. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63768. */
  63769. centripetalForceThreshold: number;
  63770. /**
  63771. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63772. */
  63773. centripetalForceMultiplier: number;
  63774. /**
  63775. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63776. */
  63777. centrifugalForceMultiplier: number;
  63778. /**
  63779. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63780. */
  63781. updraftForceMultiplier: number;
  63782. }
  63783. /**
  63784. * The strenght of the force in correspondence to the distance of the affected object
  63785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63786. */
  63787. export enum PhysicsRadialImpulseFalloff {
  63788. /** Defines that impulse is constant in strength across it's whole radius */
  63789. Constant = 0,
  63790. /** Defines that impulse gets weaker if it's further from the origin */
  63791. Linear = 1
  63792. }
  63793. /**
  63794. * The strength of the force in correspondence to the distance of the affected object
  63795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63796. */
  63797. export enum PhysicsUpdraftMode {
  63798. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63799. Center = 0,
  63800. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63801. Perpendicular = 1
  63802. }
  63803. /**
  63804. * Interface for a physics hit data
  63805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63806. */
  63807. export interface PhysicsHitData {
  63808. /**
  63809. * The force applied at the contact point
  63810. */
  63811. force: Vector3;
  63812. /**
  63813. * The contact point
  63814. */
  63815. contactPoint: Vector3;
  63816. /**
  63817. * The distance from the origin to the contact point
  63818. */
  63819. distanceFromOrigin: number;
  63820. }
  63821. /**
  63822. * Interface for radial explosion event data
  63823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63824. */
  63825. export interface PhysicsRadialExplosionEventData {
  63826. /**
  63827. * A sphere used for the radial explosion event
  63828. */
  63829. sphere: Mesh;
  63830. }
  63831. /**
  63832. * Interface for gravitational field event data
  63833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63834. */
  63835. export interface PhysicsGravitationalFieldEventData {
  63836. /**
  63837. * A sphere mesh used for the gravitational field event
  63838. */
  63839. sphere: Mesh;
  63840. }
  63841. /**
  63842. * Interface for updraft event data
  63843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63844. */
  63845. export interface PhysicsUpdraftEventData {
  63846. /**
  63847. * A cylinder used for the updraft event
  63848. */
  63849. cylinder: Mesh;
  63850. }
  63851. /**
  63852. * Interface for vortex event data
  63853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63854. */
  63855. export interface PhysicsVortexEventData {
  63856. /**
  63857. * A cylinder used for the vortex event
  63858. */
  63859. cylinder: Mesh;
  63860. }
  63861. /**
  63862. * Interface for an affected physics impostor
  63863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63864. */
  63865. export interface PhysicsAffectedImpostorWithData {
  63866. /**
  63867. * The impostor affected by the effect
  63868. */
  63869. impostor: PhysicsImpostor;
  63870. /**
  63871. * The data about the hit/horce from the explosion
  63872. */
  63873. hitData: PhysicsHitData;
  63874. }
  63875. }
  63876. declare module BABYLON {
  63877. /** @hidden */
  63878. export var blackAndWhitePixelShader: {
  63879. name: string;
  63880. shader: string;
  63881. };
  63882. }
  63883. declare module BABYLON {
  63884. /**
  63885. * Post process used to render in black and white
  63886. */
  63887. export class BlackAndWhitePostProcess extends PostProcess {
  63888. /**
  63889. * Linear about to convert he result to black and white (default: 1)
  63890. */
  63891. degree: number;
  63892. /**
  63893. * Creates a black and white post process
  63894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63895. * @param name The name of the effect.
  63896. * @param options The required width/height ratio to downsize to before computing the render pass.
  63897. * @param camera The camera to apply the render pass to.
  63898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63899. * @param engine The engine which the post process will be applied. (default: current engine)
  63900. * @param reusable If the post process can be reused on the same frame. (default: false)
  63901. */
  63902. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63903. }
  63904. }
  63905. declare module BABYLON {
  63906. /**
  63907. * This represents a set of one or more post processes in Babylon.
  63908. * A post process can be used to apply a shader to a texture after it is rendered.
  63909. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63910. */
  63911. export class PostProcessRenderEffect {
  63912. private _postProcesses;
  63913. private _getPostProcesses;
  63914. private _singleInstance;
  63915. private _cameras;
  63916. private _indicesForCamera;
  63917. /**
  63918. * Name of the effect
  63919. * @hidden
  63920. */
  63921. _name: string;
  63922. /**
  63923. * Instantiates a post process render effect.
  63924. * A post process can be used to apply a shader to a texture after it is rendered.
  63925. * @param engine The engine the effect is tied to
  63926. * @param name The name of the effect
  63927. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63928. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63929. */
  63930. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63931. /**
  63932. * Checks if all the post processes in the effect are supported.
  63933. */
  63934. get isSupported(): boolean;
  63935. /**
  63936. * Updates the current state of the effect
  63937. * @hidden
  63938. */
  63939. _update(): void;
  63940. /**
  63941. * Attaches the effect on cameras
  63942. * @param cameras The camera to attach to.
  63943. * @hidden
  63944. */
  63945. _attachCameras(cameras: Camera): void;
  63946. /**
  63947. * Attaches the effect on cameras
  63948. * @param cameras The camera to attach to.
  63949. * @hidden
  63950. */
  63951. _attachCameras(cameras: Camera[]): void;
  63952. /**
  63953. * Detaches the effect on cameras
  63954. * @param cameras The camera to detatch from.
  63955. * @hidden
  63956. */
  63957. _detachCameras(cameras: Camera): void;
  63958. /**
  63959. * Detatches the effect on cameras
  63960. * @param cameras The camera to detatch from.
  63961. * @hidden
  63962. */
  63963. _detachCameras(cameras: Camera[]): void;
  63964. /**
  63965. * Enables the effect on given cameras
  63966. * @param cameras The camera to enable.
  63967. * @hidden
  63968. */
  63969. _enable(cameras: Camera): void;
  63970. /**
  63971. * Enables the effect on given cameras
  63972. * @param cameras The camera to enable.
  63973. * @hidden
  63974. */
  63975. _enable(cameras: Nullable<Camera[]>): void;
  63976. /**
  63977. * Disables the effect on the given cameras
  63978. * @param cameras The camera to disable.
  63979. * @hidden
  63980. */
  63981. _disable(cameras: Camera): void;
  63982. /**
  63983. * Disables the effect on the given cameras
  63984. * @param cameras The camera to disable.
  63985. * @hidden
  63986. */
  63987. _disable(cameras: Nullable<Camera[]>): void;
  63988. /**
  63989. * Gets a list of the post processes contained in the effect.
  63990. * @param camera The camera to get the post processes on.
  63991. * @returns The list of the post processes in the effect.
  63992. */
  63993. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63994. }
  63995. }
  63996. declare module BABYLON {
  63997. /** @hidden */
  63998. export var extractHighlightsPixelShader: {
  63999. name: string;
  64000. shader: string;
  64001. };
  64002. }
  64003. declare module BABYLON {
  64004. /**
  64005. * 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.
  64006. */
  64007. export class ExtractHighlightsPostProcess extends PostProcess {
  64008. /**
  64009. * The luminance threshold, pixels below this value will be set to black.
  64010. */
  64011. threshold: number;
  64012. /** @hidden */
  64013. _exposure: number;
  64014. /**
  64015. * Post process which has the input texture to be used when performing highlight extraction
  64016. * @hidden
  64017. */
  64018. _inputPostProcess: Nullable<PostProcess>;
  64019. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64020. }
  64021. }
  64022. declare module BABYLON {
  64023. /** @hidden */
  64024. export var bloomMergePixelShader: {
  64025. name: string;
  64026. shader: string;
  64027. };
  64028. }
  64029. declare module BABYLON {
  64030. /**
  64031. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64032. */
  64033. export class BloomMergePostProcess extends PostProcess {
  64034. /** Weight of the bloom to be added to the original input. */
  64035. weight: number;
  64036. /**
  64037. * Creates a new instance of @see BloomMergePostProcess
  64038. * @param name The name of the effect.
  64039. * @param originalFromInput Post process which's input will be used for the merge.
  64040. * @param blurred Blurred highlights post process which's output will be used.
  64041. * @param weight Weight of the bloom to be added to the original input.
  64042. * @param options The required width/height ratio to downsize to before computing the render pass.
  64043. * @param camera The camera to apply the render pass to.
  64044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64045. * @param engine The engine which the post process will be applied. (default: current engine)
  64046. * @param reusable If the post process can be reused on the same frame. (default: false)
  64047. * @param textureType Type of textures used when performing the post process. (default: 0)
  64048. * @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)
  64049. */
  64050. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64051. /** Weight of the bloom to be added to the original input. */
  64052. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64053. }
  64054. }
  64055. declare module BABYLON {
  64056. /**
  64057. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64058. */
  64059. export class BloomEffect extends PostProcessRenderEffect {
  64060. private bloomScale;
  64061. /**
  64062. * @hidden Internal
  64063. */
  64064. _effects: Array<PostProcess>;
  64065. /**
  64066. * @hidden Internal
  64067. */
  64068. _downscale: ExtractHighlightsPostProcess;
  64069. private _blurX;
  64070. private _blurY;
  64071. private _merge;
  64072. /**
  64073. * The luminance threshold to find bright areas of the image to bloom.
  64074. */
  64075. get threshold(): number;
  64076. set threshold(value: number);
  64077. /**
  64078. * The strength of the bloom.
  64079. */
  64080. get weight(): number;
  64081. set weight(value: number);
  64082. /**
  64083. * Specifies the size of the bloom blur kernel, relative to the final output size
  64084. */
  64085. get kernel(): number;
  64086. set kernel(value: number);
  64087. /**
  64088. * Creates a new instance of @see BloomEffect
  64089. * @param scene The scene the effect belongs to.
  64090. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64091. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64092. * @param bloomWeight The the strength of bloom.
  64093. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64094. * @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)
  64095. */
  64096. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64097. /**
  64098. * Disposes each of the internal effects for a given camera.
  64099. * @param camera The camera to dispose the effect on.
  64100. */
  64101. disposeEffects(camera: Camera): void;
  64102. /**
  64103. * @hidden Internal
  64104. */
  64105. _updateEffects(): void;
  64106. /**
  64107. * Internal
  64108. * @returns if all the contained post processes are ready.
  64109. * @hidden
  64110. */
  64111. _isReady(): boolean;
  64112. }
  64113. }
  64114. declare module BABYLON {
  64115. /** @hidden */
  64116. export var chromaticAberrationPixelShader: {
  64117. name: string;
  64118. shader: string;
  64119. };
  64120. }
  64121. declare module BABYLON {
  64122. /**
  64123. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64124. */
  64125. export class ChromaticAberrationPostProcess extends PostProcess {
  64126. /**
  64127. * The amount of seperation of rgb channels (default: 30)
  64128. */
  64129. aberrationAmount: number;
  64130. /**
  64131. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64132. */
  64133. radialIntensity: number;
  64134. /**
  64135. * 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))
  64136. */
  64137. direction: Vector2;
  64138. /**
  64139. * 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))
  64140. */
  64141. centerPosition: Vector2;
  64142. /**
  64143. * Creates a new instance ChromaticAberrationPostProcess
  64144. * @param name The name of the effect.
  64145. * @param screenWidth The width of the screen to apply the effect on.
  64146. * @param screenHeight The height of the screen to apply the effect on.
  64147. * @param options The required width/height ratio to downsize to before computing the render pass.
  64148. * @param camera The camera to apply the render pass to.
  64149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64150. * @param engine The engine which the post process will be applied. (default: current engine)
  64151. * @param reusable If the post process can be reused on the same frame. (default: false)
  64152. * @param textureType Type of textures used when performing the post process. (default: 0)
  64153. * @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)
  64154. */
  64155. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64156. }
  64157. }
  64158. declare module BABYLON {
  64159. /** @hidden */
  64160. export var circleOfConfusionPixelShader: {
  64161. name: string;
  64162. shader: string;
  64163. };
  64164. }
  64165. declare module BABYLON {
  64166. /**
  64167. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64168. */
  64169. export class CircleOfConfusionPostProcess extends PostProcess {
  64170. /**
  64171. * 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.
  64172. */
  64173. lensSize: number;
  64174. /**
  64175. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64176. */
  64177. fStop: number;
  64178. /**
  64179. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64180. */
  64181. focusDistance: number;
  64182. /**
  64183. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64184. */
  64185. focalLength: number;
  64186. private _depthTexture;
  64187. /**
  64188. * Creates a new instance CircleOfConfusionPostProcess
  64189. * @param name The name of the effect.
  64190. * @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.
  64191. * @param options The required width/height ratio to downsize to before computing the render pass.
  64192. * @param camera The camera to apply the render pass to.
  64193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64194. * @param engine The engine which the post process will be applied. (default: current engine)
  64195. * @param reusable If the post process can be reused on the same frame. (default: false)
  64196. * @param textureType Type of textures used when performing the post process. (default: 0)
  64197. * @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)
  64198. */
  64199. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64200. /**
  64201. * 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.
  64202. */
  64203. set depthTexture(value: RenderTargetTexture);
  64204. }
  64205. }
  64206. declare module BABYLON {
  64207. /** @hidden */
  64208. export var colorCorrectionPixelShader: {
  64209. name: string;
  64210. shader: string;
  64211. };
  64212. }
  64213. declare module BABYLON {
  64214. /**
  64215. *
  64216. * This post-process allows the modification of rendered colors by using
  64217. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64218. *
  64219. * The object needs to be provided an url to a texture containing the color
  64220. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64221. * Use an image editing software to tweak the LUT to match your needs.
  64222. *
  64223. * For an example of a color LUT, see here:
  64224. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64225. * For explanations on color grading, see here:
  64226. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64227. *
  64228. */
  64229. export class ColorCorrectionPostProcess extends PostProcess {
  64230. private _colorTableTexture;
  64231. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64232. }
  64233. }
  64234. declare module BABYLON {
  64235. /** @hidden */
  64236. export var convolutionPixelShader: {
  64237. name: string;
  64238. shader: string;
  64239. };
  64240. }
  64241. declare module BABYLON {
  64242. /**
  64243. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64244. * input texture to perform effects such as edge detection or sharpening
  64245. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64246. */
  64247. export class ConvolutionPostProcess extends PostProcess {
  64248. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64249. kernel: number[];
  64250. /**
  64251. * Creates a new instance ConvolutionPostProcess
  64252. * @param name The name of the effect.
  64253. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64254. * @param options The required width/height ratio to downsize to before computing the render pass.
  64255. * @param camera The camera to apply the render pass to.
  64256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64257. * @param engine The engine which the post process will be applied. (default: current engine)
  64258. * @param reusable If the post process can be reused on the same frame. (default: false)
  64259. * @param textureType Type of textures used when performing the post process. (default: 0)
  64260. */
  64261. constructor(name: string,
  64262. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64263. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64264. /**
  64265. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64266. */
  64267. static EdgeDetect0Kernel: number[];
  64268. /**
  64269. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64270. */
  64271. static EdgeDetect1Kernel: number[];
  64272. /**
  64273. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64274. */
  64275. static EdgeDetect2Kernel: number[];
  64276. /**
  64277. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64278. */
  64279. static SharpenKernel: number[];
  64280. /**
  64281. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64282. */
  64283. static EmbossKernel: number[];
  64284. /**
  64285. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64286. */
  64287. static GaussianKernel: number[];
  64288. }
  64289. }
  64290. declare module BABYLON {
  64291. /**
  64292. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64293. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64294. * based on samples that have a large difference in distance than the center pixel.
  64295. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64296. */
  64297. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64298. direction: Vector2;
  64299. /**
  64300. * Creates a new instance CircleOfConfusionPostProcess
  64301. * @param name The name of the effect.
  64302. * @param scene The scene the effect belongs to.
  64303. * @param direction The direction the blur should be applied.
  64304. * @param kernel The size of the kernel used to blur.
  64305. * @param options The required width/height ratio to downsize to before computing the render pass.
  64306. * @param camera The camera to apply the render pass to.
  64307. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64308. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64310. * @param engine The engine which the post process will be applied. (default: current engine)
  64311. * @param reusable If the post process can be reused on the same frame. (default: false)
  64312. * @param textureType Type of textures used when performing the post process. (default: 0)
  64313. * @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)
  64314. */
  64315. 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);
  64316. }
  64317. }
  64318. declare module BABYLON {
  64319. /** @hidden */
  64320. export var depthOfFieldMergePixelShader: {
  64321. name: string;
  64322. shader: string;
  64323. };
  64324. }
  64325. declare module BABYLON {
  64326. /**
  64327. * Options to be set when merging outputs from the default pipeline.
  64328. */
  64329. export class DepthOfFieldMergePostProcessOptions {
  64330. /**
  64331. * The original image to merge on top of
  64332. */
  64333. originalFromInput: PostProcess;
  64334. /**
  64335. * Parameters to perform the merge of the depth of field effect
  64336. */
  64337. depthOfField?: {
  64338. circleOfConfusion: PostProcess;
  64339. blurSteps: Array<PostProcess>;
  64340. };
  64341. /**
  64342. * Parameters to perform the merge of bloom effect
  64343. */
  64344. bloom?: {
  64345. blurred: PostProcess;
  64346. weight: number;
  64347. };
  64348. }
  64349. /**
  64350. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64351. */
  64352. export class DepthOfFieldMergePostProcess extends PostProcess {
  64353. private blurSteps;
  64354. /**
  64355. * Creates a new instance of DepthOfFieldMergePostProcess
  64356. * @param name The name of the effect.
  64357. * @param originalFromInput Post process which's input will be used for the merge.
  64358. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64359. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64360. * @param options The required width/height ratio to downsize to before computing the render pass.
  64361. * @param camera The camera to apply the render pass to.
  64362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64363. * @param engine The engine which the post process will be applied. (default: current engine)
  64364. * @param reusable If the post process can be reused on the same frame. (default: false)
  64365. * @param textureType Type of textures used when performing the post process. (default: 0)
  64366. * @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)
  64367. */
  64368. 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);
  64369. /**
  64370. * Updates the effect with the current post process compile time values and recompiles the shader.
  64371. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64372. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64373. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64374. * @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
  64375. * @param onCompiled Called when the shader has been compiled.
  64376. * @param onError Called if there is an error when compiling a shader.
  64377. */
  64378. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64379. }
  64380. }
  64381. declare module BABYLON {
  64382. /**
  64383. * Specifies the level of max blur that should be applied when using the depth of field effect
  64384. */
  64385. export enum DepthOfFieldEffectBlurLevel {
  64386. /**
  64387. * Subtle blur
  64388. */
  64389. Low = 0,
  64390. /**
  64391. * Medium blur
  64392. */
  64393. Medium = 1,
  64394. /**
  64395. * Large blur
  64396. */
  64397. High = 2
  64398. }
  64399. /**
  64400. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64401. */
  64402. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64403. private _circleOfConfusion;
  64404. /**
  64405. * @hidden Internal, blurs from high to low
  64406. */
  64407. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64408. private _depthOfFieldBlurY;
  64409. private _dofMerge;
  64410. /**
  64411. * @hidden Internal post processes in depth of field effect
  64412. */
  64413. _effects: Array<PostProcess>;
  64414. /**
  64415. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64416. */
  64417. set focalLength(value: number);
  64418. get focalLength(): number;
  64419. /**
  64420. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64421. */
  64422. set fStop(value: number);
  64423. get fStop(): number;
  64424. /**
  64425. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64426. */
  64427. set focusDistance(value: number);
  64428. get focusDistance(): number;
  64429. /**
  64430. * 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.
  64431. */
  64432. set lensSize(value: number);
  64433. get lensSize(): number;
  64434. /**
  64435. * Creates a new instance DepthOfFieldEffect
  64436. * @param scene The scene the effect belongs to.
  64437. * @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.
  64438. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64439. * @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)
  64440. */
  64441. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64442. /**
  64443. * Get the current class name of the current effet
  64444. * @returns "DepthOfFieldEffect"
  64445. */
  64446. getClassName(): string;
  64447. /**
  64448. * 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.
  64449. */
  64450. set depthTexture(value: RenderTargetTexture);
  64451. /**
  64452. * Disposes each of the internal effects for a given camera.
  64453. * @param camera The camera to dispose the effect on.
  64454. */
  64455. disposeEffects(camera: Camera): void;
  64456. /**
  64457. * @hidden Internal
  64458. */
  64459. _updateEffects(): void;
  64460. /**
  64461. * Internal
  64462. * @returns if all the contained post processes are ready.
  64463. * @hidden
  64464. */
  64465. _isReady(): boolean;
  64466. }
  64467. }
  64468. declare module BABYLON {
  64469. /** @hidden */
  64470. export var displayPassPixelShader: {
  64471. name: string;
  64472. shader: string;
  64473. };
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * DisplayPassPostProcess which produces an output the same as it's input
  64478. */
  64479. export class DisplayPassPostProcess extends PostProcess {
  64480. /**
  64481. * Creates the DisplayPassPostProcess
  64482. * @param name The name of the effect.
  64483. * @param options The required width/height ratio to downsize to before computing the render pass.
  64484. * @param camera The camera to apply the render pass to.
  64485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64486. * @param engine The engine which the post process will be applied. (default: current engine)
  64487. * @param reusable If the post process can be reused on the same frame. (default: false)
  64488. */
  64489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64490. }
  64491. }
  64492. declare module BABYLON {
  64493. /** @hidden */
  64494. export var filterPixelShader: {
  64495. name: string;
  64496. shader: string;
  64497. };
  64498. }
  64499. declare module BABYLON {
  64500. /**
  64501. * Applies a kernel filter to the image
  64502. */
  64503. export class FilterPostProcess extends PostProcess {
  64504. /** The matrix to be applied to the image */
  64505. kernelMatrix: Matrix;
  64506. /**
  64507. *
  64508. * @param name The name of the effect.
  64509. * @param kernelMatrix The matrix to be applied to the image
  64510. * @param options The required width/height ratio to downsize to before computing the render pass.
  64511. * @param camera The camera to apply the render pass to.
  64512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64513. * @param engine The engine which the post process will be applied. (default: current engine)
  64514. * @param reusable If the post process can be reused on the same frame. (default: false)
  64515. */
  64516. constructor(name: string,
  64517. /** The matrix to be applied to the image */
  64518. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64519. }
  64520. }
  64521. declare module BABYLON {
  64522. /** @hidden */
  64523. export var fxaaPixelShader: {
  64524. name: string;
  64525. shader: string;
  64526. };
  64527. }
  64528. declare module BABYLON {
  64529. /** @hidden */
  64530. export var fxaaVertexShader: {
  64531. name: string;
  64532. shader: string;
  64533. };
  64534. }
  64535. declare module BABYLON {
  64536. /**
  64537. * Fxaa post process
  64538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64539. */
  64540. export class FxaaPostProcess extends PostProcess {
  64541. /** @hidden */
  64542. texelWidth: number;
  64543. /** @hidden */
  64544. texelHeight: number;
  64545. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64546. private _getDefines;
  64547. }
  64548. }
  64549. declare module BABYLON {
  64550. /** @hidden */
  64551. export var grainPixelShader: {
  64552. name: string;
  64553. shader: string;
  64554. };
  64555. }
  64556. declare module BABYLON {
  64557. /**
  64558. * The GrainPostProcess adds noise to the image at mid luminance levels
  64559. */
  64560. export class GrainPostProcess extends PostProcess {
  64561. /**
  64562. * The intensity of the grain added (default: 30)
  64563. */
  64564. intensity: number;
  64565. /**
  64566. * If the grain should be randomized on every frame
  64567. */
  64568. animated: boolean;
  64569. /**
  64570. * Creates a new instance of @see GrainPostProcess
  64571. * @param name The name of the effect.
  64572. * @param options The required width/height ratio to downsize to before computing the render pass.
  64573. * @param camera The camera to apply the render pass to.
  64574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64575. * @param engine The engine which the post process will be applied. (default: current engine)
  64576. * @param reusable If the post process can be reused on the same frame. (default: false)
  64577. * @param textureType Type of textures used when performing the post process. (default: 0)
  64578. * @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)
  64579. */
  64580. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64581. }
  64582. }
  64583. declare module BABYLON {
  64584. /** @hidden */
  64585. export var highlightsPixelShader: {
  64586. name: string;
  64587. shader: string;
  64588. };
  64589. }
  64590. declare module BABYLON {
  64591. /**
  64592. * Extracts highlights from the image
  64593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64594. */
  64595. export class HighlightsPostProcess extends PostProcess {
  64596. /**
  64597. * Extracts highlights from the image
  64598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64599. * @param name The name of the effect.
  64600. * @param options The required width/height ratio to downsize to before computing the render pass.
  64601. * @param camera The camera to apply the render pass to.
  64602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64603. * @param engine The engine which the post process will be applied. (default: current engine)
  64604. * @param reusable If the post process can be reused on the same frame. (default: false)
  64605. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64606. */
  64607. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /** @hidden */
  64612. export var mrtFragmentDeclaration: {
  64613. name: string;
  64614. shader: string;
  64615. };
  64616. }
  64617. declare module BABYLON {
  64618. /** @hidden */
  64619. export var geometryPixelShader: {
  64620. name: string;
  64621. shader: string;
  64622. };
  64623. }
  64624. declare module BABYLON {
  64625. /** @hidden */
  64626. export var geometryVertexShader: {
  64627. name: string;
  64628. shader: string;
  64629. };
  64630. }
  64631. declare module BABYLON {
  64632. /** @hidden */
  64633. interface ISavedTransformationMatrix {
  64634. world: Matrix;
  64635. viewProjection: Matrix;
  64636. }
  64637. /**
  64638. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64639. */
  64640. export class GeometryBufferRenderer {
  64641. /**
  64642. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64643. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64644. */
  64645. static readonly POSITION_TEXTURE_TYPE: number;
  64646. /**
  64647. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64648. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64649. */
  64650. static readonly VELOCITY_TEXTURE_TYPE: number;
  64651. /**
  64652. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64653. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64654. */
  64655. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64656. /**
  64657. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64658. * in order to compute objects velocities when enableVelocity is set to "true"
  64659. * @hidden
  64660. */
  64661. _previousTransformationMatrices: {
  64662. [index: number]: ISavedTransformationMatrix;
  64663. };
  64664. /**
  64665. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64666. * in order to compute objects velocities when enableVelocity is set to "true"
  64667. * @hidden
  64668. */
  64669. _previousBonesTransformationMatrices: {
  64670. [index: number]: Float32Array;
  64671. };
  64672. /**
  64673. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64674. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64675. */
  64676. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64677. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64678. renderTransparentMeshes: boolean;
  64679. private _scene;
  64680. private _multiRenderTarget;
  64681. private _ratio;
  64682. private _enablePosition;
  64683. private _enableVelocity;
  64684. private _enableReflectivity;
  64685. private _positionIndex;
  64686. private _velocityIndex;
  64687. private _reflectivityIndex;
  64688. protected _effect: Effect;
  64689. protected _cachedDefines: string;
  64690. /**
  64691. * Set the render list (meshes to be rendered) used in the G buffer.
  64692. */
  64693. set renderList(meshes: Mesh[]);
  64694. /**
  64695. * Gets wether or not G buffer are supported by the running hardware.
  64696. * This requires draw buffer supports
  64697. */
  64698. get isSupported(): boolean;
  64699. /**
  64700. * Returns the index of the given texture type in the G-Buffer textures array
  64701. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64702. * @returns the index of the given texture type in the G-Buffer textures array
  64703. */
  64704. getTextureIndex(textureType: number): number;
  64705. /**
  64706. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64707. */
  64708. get enablePosition(): boolean;
  64709. /**
  64710. * Sets whether or not objects positions are enabled for the G buffer.
  64711. */
  64712. set enablePosition(enable: boolean);
  64713. /**
  64714. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64715. */
  64716. get enableVelocity(): boolean;
  64717. /**
  64718. * Sets wether or not objects velocities are enabled for the G buffer.
  64719. */
  64720. set enableVelocity(enable: boolean);
  64721. /**
  64722. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64723. */
  64724. get enableReflectivity(): boolean;
  64725. /**
  64726. * Sets wether or not objects roughness are enabled for the G buffer.
  64727. */
  64728. set enableReflectivity(enable: boolean);
  64729. /**
  64730. * Gets the scene associated with the buffer.
  64731. */
  64732. get scene(): Scene;
  64733. /**
  64734. * Gets the ratio used by the buffer during its creation.
  64735. * How big is the buffer related to the main canvas.
  64736. */
  64737. get ratio(): number;
  64738. /** @hidden */
  64739. static _SceneComponentInitialization: (scene: Scene) => void;
  64740. /**
  64741. * Creates a new G Buffer for the scene
  64742. * @param scene The scene the buffer belongs to
  64743. * @param ratio How big is the buffer related to the main canvas.
  64744. */
  64745. constructor(scene: Scene, ratio?: number);
  64746. /**
  64747. * Checks wether everything is ready to render a submesh to the G buffer.
  64748. * @param subMesh the submesh to check readiness for
  64749. * @param useInstances is the mesh drawn using instance or not
  64750. * @returns true if ready otherwise false
  64751. */
  64752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64753. /**
  64754. * Gets the current underlying G Buffer.
  64755. * @returns the buffer
  64756. */
  64757. getGBuffer(): MultiRenderTarget;
  64758. /**
  64759. * Gets the number of samples used to render the buffer (anti aliasing).
  64760. */
  64761. get samples(): number;
  64762. /**
  64763. * Sets the number of samples used to render the buffer (anti aliasing).
  64764. */
  64765. set samples(value: number);
  64766. /**
  64767. * Disposes the renderer and frees up associated resources.
  64768. */
  64769. dispose(): void;
  64770. protected _createRenderTargets(): void;
  64771. private _copyBonesTransformationMatrices;
  64772. }
  64773. }
  64774. declare module BABYLON {
  64775. interface Scene {
  64776. /** @hidden (Backing field) */
  64777. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64778. /**
  64779. * Gets or Sets the current geometry buffer associated to the scene.
  64780. */
  64781. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64782. /**
  64783. * Enables a GeometryBufferRender and associates it with the scene
  64784. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64785. * @returns the GeometryBufferRenderer
  64786. */
  64787. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64788. /**
  64789. * Disables the GeometryBufferRender associated with the scene
  64790. */
  64791. disableGeometryBufferRenderer(): void;
  64792. }
  64793. /**
  64794. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64795. * in several rendering techniques.
  64796. */
  64797. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64798. /**
  64799. * The component name helpful to identify the component in the list of scene components.
  64800. */
  64801. readonly name: string;
  64802. /**
  64803. * The scene the component belongs to.
  64804. */
  64805. scene: Scene;
  64806. /**
  64807. * Creates a new instance of the component for the given scene
  64808. * @param scene Defines the scene to register the component in
  64809. */
  64810. constructor(scene: Scene);
  64811. /**
  64812. * Registers the component in a given scene
  64813. */
  64814. register(): void;
  64815. /**
  64816. * Rebuilds the elements related to this component in case of
  64817. * context lost for instance.
  64818. */
  64819. rebuild(): void;
  64820. /**
  64821. * Disposes the component and the associated ressources
  64822. */
  64823. dispose(): void;
  64824. private _gatherRenderTargets;
  64825. }
  64826. }
  64827. declare module BABYLON {
  64828. /** @hidden */
  64829. export var motionBlurPixelShader: {
  64830. name: string;
  64831. shader: string;
  64832. };
  64833. }
  64834. declare module BABYLON {
  64835. /**
  64836. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64837. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64838. * As an example, all you have to do is to create the post-process:
  64839. * var mb = new BABYLON.MotionBlurPostProcess(
  64840. * 'mb', // The name of the effect.
  64841. * scene, // The scene containing the objects to blur according to their velocity.
  64842. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64843. * camera // The camera to apply the render pass to.
  64844. * );
  64845. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64846. */
  64847. export class MotionBlurPostProcess extends PostProcess {
  64848. /**
  64849. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64850. */
  64851. motionStrength: number;
  64852. /**
  64853. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64854. */
  64855. get motionBlurSamples(): number;
  64856. /**
  64857. * Sets the number of iterations to be used for motion blur quality
  64858. */
  64859. set motionBlurSamples(samples: number);
  64860. private _motionBlurSamples;
  64861. private _geometryBufferRenderer;
  64862. /**
  64863. * Creates a new instance MotionBlurPostProcess
  64864. * @param name The name of the effect.
  64865. * @param scene The scene containing the objects to blur according to their velocity.
  64866. * @param options The required width/height ratio to downsize to before computing the render pass.
  64867. * @param camera The camera to apply the render pass to.
  64868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64869. * @param engine The engine which the post process will be applied. (default: current engine)
  64870. * @param reusable If the post process can be reused on the same frame. (default: false)
  64871. * @param textureType Type of textures used when performing the post process. (default: 0)
  64872. * @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)
  64873. */
  64874. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64875. /**
  64876. * Excludes the given skinned mesh from computing bones velocities.
  64877. * 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.
  64878. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64879. */
  64880. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64881. /**
  64882. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64883. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64884. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64885. */
  64886. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64887. /**
  64888. * Disposes the post process.
  64889. * @param camera The camera to dispose the post process on.
  64890. */
  64891. dispose(camera?: Camera): void;
  64892. }
  64893. }
  64894. declare module BABYLON {
  64895. /** @hidden */
  64896. export var refractionPixelShader: {
  64897. name: string;
  64898. shader: string;
  64899. };
  64900. }
  64901. declare module BABYLON {
  64902. /**
  64903. * Post process which applies a refractin texture
  64904. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64905. */
  64906. export class RefractionPostProcess extends PostProcess {
  64907. /** the base color of the refraction (used to taint the rendering) */
  64908. color: Color3;
  64909. /** simulated refraction depth */
  64910. depth: number;
  64911. /** the coefficient of the base color (0 to remove base color tainting) */
  64912. colorLevel: number;
  64913. private _refTexture;
  64914. private _ownRefractionTexture;
  64915. /**
  64916. * Gets or sets the refraction texture
  64917. * Please note that you are responsible for disposing the texture if you set it manually
  64918. */
  64919. get refractionTexture(): Texture;
  64920. set refractionTexture(value: Texture);
  64921. /**
  64922. * Initializes the RefractionPostProcess
  64923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64924. * @param name The name of the effect.
  64925. * @param refractionTextureUrl Url of the refraction texture to use
  64926. * @param color the base color of the refraction (used to taint the rendering)
  64927. * @param depth simulated refraction depth
  64928. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64929. * @param camera The camera to apply the render pass to.
  64930. * @param options The required width/height ratio to downsize to before computing the render pass.
  64931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64932. * @param engine The engine which the post process will be applied. (default: current engine)
  64933. * @param reusable If the post process can be reused on the same frame. (default: false)
  64934. */
  64935. constructor(name: string, refractionTextureUrl: string,
  64936. /** the base color of the refraction (used to taint the rendering) */
  64937. color: Color3,
  64938. /** simulated refraction depth */
  64939. depth: number,
  64940. /** the coefficient of the base color (0 to remove base color tainting) */
  64941. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64942. /**
  64943. * Disposes of the post process
  64944. * @param camera Camera to dispose post process on
  64945. */
  64946. dispose(camera: Camera): void;
  64947. }
  64948. }
  64949. declare module BABYLON {
  64950. /** @hidden */
  64951. export var sharpenPixelShader: {
  64952. name: string;
  64953. shader: string;
  64954. };
  64955. }
  64956. declare module BABYLON {
  64957. /**
  64958. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64959. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64960. */
  64961. export class SharpenPostProcess extends PostProcess {
  64962. /**
  64963. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64964. */
  64965. colorAmount: number;
  64966. /**
  64967. * How much sharpness should be applied (default: 0.3)
  64968. */
  64969. edgeAmount: number;
  64970. /**
  64971. * Creates a new instance ConvolutionPostProcess
  64972. * @param name The name of the effect.
  64973. * @param options The required width/height ratio to downsize to before computing the render pass.
  64974. * @param camera The camera to apply the render pass to.
  64975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64976. * @param engine The engine which the post process will be applied. (default: current engine)
  64977. * @param reusable If the post process can be reused on the same frame. (default: false)
  64978. * @param textureType Type of textures used when performing the post process. (default: 0)
  64979. * @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)
  64980. */
  64981. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64982. }
  64983. }
  64984. declare module BABYLON {
  64985. /**
  64986. * PostProcessRenderPipeline
  64987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64988. */
  64989. export class PostProcessRenderPipeline {
  64990. private engine;
  64991. private _renderEffects;
  64992. private _renderEffectsForIsolatedPass;
  64993. /**
  64994. * List of inspectable custom properties (used by the Inspector)
  64995. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64996. */
  64997. inspectableCustomProperties: IInspectable[];
  64998. /**
  64999. * @hidden
  65000. */
  65001. protected _cameras: Camera[];
  65002. /** @hidden */
  65003. _name: string;
  65004. /**
  65005. * Gets pipeline name
  65006. */
  65007. get name(): string;
  65008. /** Gets the list of attached cameras */
  65009. get cameras(): Camera[];
  65010. /**
  65011. * Initializes a PostProcessRenderPipeline
  65012. * @param engine engine to add the pipeline to
  65013. * @param name name of the pipeline
  65014. */
  65015. constructor(engine: Engine, name: string);
  65016. /**
  65017. * Gets the class name
  65018. * @returns "PostProcessRenderPipeline"
  65019. */
  65020. getClassName(): string;
  65021. /**
  65022. * If all the render effects in the pipeline are supported
  65023. */
  65024. get isSupported(): boolean;
  65025. /**
  65026. * Adds an effect to the pipeline
  65027. * @param renderEffect the effect to add
  65028. */
  65029. addEffect(renderEffect: PostProcessRenderEffect): void;
  65030. /** @hidden */
  65031. _rebuild(): void;
  65032. /** @hidden */
  65033. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65034. /** @hidden */
  65035. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65036. /** @hidden */
  65037. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65038. /** @hidden */
  65039. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65040. /** @hidden */
  65041. _attachCameras(cameras: Camera, unique: boolean): void;
  65042. /** @hidden */
  65043. _attachCameras(cameras: Camera[], unique: boolean): void;
  65044. /** @hidden */
  65045. _detachCameras(cameras: Camera): void;
  65046. /** @hidden */
  65047. _detachCameras(cameras: Nullable<Camera[]>): void;
  65048. /** @hidden */
  65049. _update(): void;
  65050. /** @hidden */
  65051. _reset(): void;
  65052. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65053. /**
  65054. * Disposes of the pipeline
  65055. */
  65056. dispose(): void;
  65057. }
  65058. }
  65059. declare module BABYLON {
  65060. /**
  65061. * PostProcessRenderPipelineManager class
  65062. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65063. */
  65064. export class PostProcessRenderPipelineManager {
  65065. private _renderPipelines;
  65066. /**
  65067. * Initializes a PostProcessRenderPipelineManager
  65068. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65069. */
  65070. constructor();
  65071. /**
  65072. * Gets the list of supported render pipelines
  65073. */
  65074. get supportedPipelines(): PostProcessRenderPipeline[];
  65075. /**
  65076. * Adds a pipeline to the manager
  65077. * @param renderPipeline The pipeline to add
  65078. */
  65079. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65080. /**
  65081. * Attaches a camera to the pipeline
  65082. * @param renderPipelineName The name of the pipeline to attach to
  65083. * @param cameras the camera to attach
  65084. * @param unique if the camera can be attached multiple times to the pipeline
  65085. */
  65086. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65087. /**
  65088. * Detaches a camera from the pipeline
  65089. * @param renderPipelineName The name of the pipeline to detach from
  65090. * @param cameras the camera to detach
  65091. */
  65092. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65093. /**
  65094. * Enables an effect by name on a pipeline
  65095. * @param renderPipelineName the name of the pipeline to enable the effect in
  65096. * @param renderEffectName the name of the effect to enable
  65097. * @param cameras the cameras that the effect should be enabled on
  65098. */
  65099. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65100. /**
  65101. * Disables an effect by name on a pipeline
  65102. * @param renderPipelineName the name of the pipeline to disable the effect in
  65103. * @param renderEffectName the name of the effect to disable
  65104. * @param cameras the cameras that the effect should be disabled on
  65105. */
  65106. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65107. /**
  65108. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65109. */
  65110. update(): void;
  65111. /** @hidden */
  65112. _rebuild(): void;
  65113. /**
  65114. * Disposes of the manager and pipelines
  65115. */
  65116. dispose(): void;
  65117. }
  65118. }
  65119. declare module BABYLON {
  65120. interface Scene {
  65121. /** @hidden (Backing field) */
  65122. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65123. /**
  65124. * Gets the postprocess render pipeline manager
  65125. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65126. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65127. */
  65128. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65129. }
  65130. /**
  65131. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65132. */
  65133. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65134. /**
  65135. * The component name helpfull to identify the component in the list of scene components.
  65136. */
  65137. readonly name: string;
  65138. /**
  65139. * The scene the component belongs to.
  65140. */
  65141. scene: Scene;
  65142. /**
  65143. * Creates a new instance of the component for the given scene
  65144. * @param scene Defines the scene to register the component in
  65145. */
  65146. constructor(scene: Scene);
  65147. /**
  65148. * Registers the component in a given scene
  65149. */
  65150. register(): void;
  65151. /**
  65152. * Rebuilds the elements related to this component in case of
  65153. * context lost for instance.
  65154. */
  65155. rebuild(): void;
  65156. /**
  65157. * Disposes the component and the associated ressources
  65158. */
  65159. dispose(): void;
  65160. private _gatherRenderTargets;
  65161. }
  65162. }
  65163. declare module BABYLON {
  65164. /**
  65165. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65166. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65167. */
  65168. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65169. private _scene;
  65170. private _camerasToBeAttached;
  65171. /**
  65172. * ID of the sharpen post process,
  65173. */
  65174. private readonly SharpenPostProcessId;
  65175. /**
  65176. * @ignore
  65177. * ID of the image processing post process;
  65178. */
  65179. readonly ImageProcessingPostProcessId: string;
  65180. /**
  65181. * @ignore
  65182. * ID of the Fast Approximate Anti-Aliasing post process;
  65183. */
  65184. readonly FxaaPostProcessId: string;
  65185. /**
  65186. * ID of the chromatic aberration post process,
  65187. */
  65188. private readonly ChromaticAberrationPostProcessId;
  65189. /**
  65190. * ID of the grain post process
  65191. */
  65192. private readonly GrainPostProcessId;
  65193. /**
  65194. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65195. */
  65196. sharpen: SharpenPostProcess;
  65197. private _sharpenEffect;
  65198. private bloom;
  65199. /**
  65200. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65201. */
  65202. depthOfField: DepthOfFieldEffect;
  65203. /**
  65204. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65205. */
  65206. fxaa: FxaaPostProcess;
  65207. /**
  65208. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65209. */
  65210. imageProcessing: ImageProcessingPostProcess;
  65211. /**
  65212. * Chromatic aberration post process which will shift rgb colors in the image
  65213. */
  65214. chromaticAberration: ChromaticAberrationPostProcess;
  65215. private _chromaticAberrationEffect;
  65216. /**
  65217. * Grain post process which add noise to the image
  65218. */
  65219. grain: GrainPostProcess;
  65220. private _grainEffect;
  65221. /**
  65222. * Glow post process which adds a glow to emissive areas of the image
  65223. */
  65224. private _glowLayer;
  65225. /**
  65226. * Animations which can be used to tweak settings over a period of time
  65227. */
  65228. animations: Animation[];
  65229. private _imageProcessingConfigurationObserver;
  65230. private _sharpenEnabled;
  65231. private _bloomEnabled;
  65232. private _depthOfFieldEnabled;
  65233. private _depthOfFieldBlurLevel;
  65234. private _fxaaEnabled;
  65235. private _imageProcessingEnabled;
  65236. private _defaultPipelineTextureType;
  65237. private _bloomScale;
  65238. private _chromaticAberrationEnabled;
  65239. private _grainEnabled;
  65240. private _buildAllowed;
  65241. /**
  65242. * Gets active scene
  65243. */
  65244. get scene(): Scene;
  65245. /**
  65246. * Enable or disable the sharpen process from the pipeline
  65247. */
  65248. set sharpenEnabled(enabled: boolean);
  65249. get sharpenEnabled(): boolean;
  65250. private _resizeObserver;
  65251. private _hardwareScaleLevel;
  65252. private _bloomKernel;
  65253. /**
  65254. * Specifies the size of the bloom blur kernel, relative to the final output size
  65255. */
  65256. get bloomKernel(): number;
  65257. set bloomKernel(value: number);
  65258. /**
  65259. * Specifies the weight of the bloom in the final rendering
  65260. */
  65261. private _bloomWeight;
  65262. /**
  65263. * Specifies the luma threshold for the area that will be blurred by the bloom
  65264. */
  65265. private _bloomThreshold;
  65266. private _hdr;
  65267. /**
  65268. * The strength of the bloom.
  65269. */
  65270. set bloomWeight(value: number);
  65271. get bloomWeight(): number;
  65272. /**
  65273. * The strength of the bloom.
  65274. */
  65275. set bloomThreshold(value: number);
  65276. get bloomThreshold(): number;
  65277. /**
  65278. * The scale of the bloom, lower value will provide better performance.
  65279. */
  65280. set bloomScale(value: number);
  65281. get bloomScale(): number;
  65282. /**
  65283. * Enable or disable the bloom from the pipeline
  65284. */
  65285. set bloomEnabled(enabled: boolean);
  65286. get bloomEnabled(): boolean;
  65287. private _rebuildBloom;
  65288. /**
  65289. * If the depth of field is enabled.
  65290. */
  65291. get depthOfFieldEnabled(): boolean;
  65292. set depthOfFieldEnabled(enabled: boolean);
  65293. /**
  65294. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65295. */
  65296. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65297. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65298. /**
  65299. * If the anti aliasing is enabled.
  65300. */
  65301. set fxaaEnabled(enabled: boolean);
  65302. get fxaaEnabled(): boolean;
  65303. private _samples;
  65304. /**
  65305. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65306. */
  65307. set samples(sampleCount: number);
  65308. get samples(): number;
  65309. /**
  65310. * If image processing is enabled.
  65311. */
  65312. set imageProcessingEnabled(enabled: boolean);
  65313. get imageProcessingEnabled(): boolean;
  65314. /**
  65315. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65316. */
  65317. set glowLayerEnabled(enabled: boolean);
  65318. get glowLayerEnabled(): boolean;
  65319. /**
  65320. * Gets the glow layer (or null if not defined)
  65321. */
  65322. get glowLayer(): Nullable<GlowLayer>;
  65323. /**
  65324. * Enable or disable the chromaticAberration process from the pipeline
  65325. */
  65326. set chromaticAberrationEnabled(enabled: boolean);
  65327. get chromaticAberrationEnabled(): boolean;
  65328. /**
  65329. * Enable or disable the grain process from the pipeline
  65330. */
  65331. set grainEnabled(enabled: boolean);
  65332. get grainEnabled(): boolean;
  65333. /**
  65334. * @constructor
  65335. * @param name - The rendering pipeline name (default: "")
  65336. * @param hdr - If high dynamic range textures should be used (default: true)
  65337. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65338. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65339. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65340. */
  65341. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65342. /**
  65343. * Get the class name
  65344. * @returns "DefaultRenderingPipeline"
  65345. */
  65346. getClassName(): string;
  65347. /**
  65348. * Force the compilation of the entire pipeline.
  65349. */
  65350. prepare(): void;
  65351. private _hasCleared;
  65352. private _prevPostProcess;
  65353. private _prevPrevPostProcess;
  65354. private _setAutoClearAndTextureSharing;
  65355. private _depthOfFieldSceneObserver;
  65356. private _buildPipeline;
  65357. private _disposePostProcesses;
  65358. /**
  65359. * Adds a camera to the pipeline
  65360. * @param camera the camera to be added
  65361. */
  65362. addCamera(camera: Camera): void;
  65363. /**
  65364. * Removes a camera from the pipeline
  65365. * @param camera the camera to remove
  65366. */
  65367. removeCamera(camera: Camera): void;
  65368. /**
  65369. * Dispose of the pipeline and stop all post processes
  65370. */
  65371. dispose(): void;
  65372. /**
  65373. * Serialize the rendering pipeline (Used when exporting)
  65374. * @returns the serialized object
  65375. */
  65376. serialize(): any;
  65377. /**
  65378. * Parse the serialized pipeline
  65379. * @param source Source pipeline.
  65380. * @param scene The scene to load the pipeline to.
  65381. * @param rootUrl The URL of the serialized pipeline.
  65382. * @returns An instantiated pipeline from the serialized object.
  65383. */
  65384. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65385. }
  65386. }
  65387. declare module BABYLON {
  65388. /** @hidden */
  65389. export var lensHighlightsPixelShader: {
  65390. name: string;
  65391. shader: string;
  65392. };
  65393. }
  65394. declare module BABYLON {
  65395. /** @hidden */
  65396. export var depthOfFieldPixelShader: {
  65397. name: string;
  65398. shader: string;
  65399. };
  65400. }
  65401. declare module BABYLON {
  65402. /**
  65403. * BABYLON.JS Chromatic Aberration GLSL Shader
  65404. * Author: Olivier Guyot
  65405. * Separates very slightly R, G and B colors on the edges of the screen
  65406. * Inspired by Francois Tarlier & Martins Upitis
  65407. */
  65408. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65409. /**
  65410. * @ignore
  65411. * The chromatic aberration PostProcess id in the pipeline
  65412. */
  65413. LensChromaticAberrationEffect: string;
  65414. /**
  65415. * @ignore
  65416. * The highlights enhancing PostProcess id in the pipeline
  65417. */
  65418. HighlightsEnhancingEffect: string;
  65419. /**
  65420. * @ignore
  65421. * The depth-of-field PostProcess id in the pipeline
  65422. */
  65423. LensDepthOfFieldEffect: string;
  65424. private _scene;
  65425. private _depthTexture;
  65426. private _grainTexture;
  65427. private _chromaticAberrationPostProcess;
  65428. private _highlightsPostProcess;
  65429. private _depthOfFieldPostProcess;
  65430. private _edgeBlur;
  65431. private _grainAmount;
  65432. private _chromaticAberration;
  65433. private _distortion;
  65434. private _highlightsGain;
  65435. private _highlightsThreshold;
  65436. private _dofDistance;
  65437. private _dofAperture;
  65438. private _dofDarken;
  65439. private _dofPentagon;
  65440. private _blurNoise;
  65441. /**
  65442. * @constructor
  65443. *
  65444. * Effect parameters are as follow:
  65445. * {
  65446. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65447. * edge_blur: number; // from 0 to x (1 for realism)
  65448. * distortion: number; // from 0 to x (1 for realism)
  65449. * grain_amount: number; // from 0 to 1
  65450. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65451. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65452. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65453. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65454. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65455. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65456. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65457. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65458. * }
  65459. * Note: if an effect parameter is unset, effect is disabled
  65460. *
  65461. * @param name The rendering pipeline name
  65462. * @param parameters - An object containing all parameters (see above)
  65463. * @param scene The scene linked to this pipeline
  65464. * @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)
  65465. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65466. */
  65467. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65468. /**
  65469. * Get the class name
  65470. * @returns "LensRenderingPipeline"
  65471. */
  65472. getClassName(): string;
  65473. /**
  65474. * Gets associated scene
  65475. */
  65476. get scene(): Scene;
  65477. /**
  65478. * Gets or sets the edge blur
  65479. */
  65480. get edgeBlur(): number;
  65481. set edgeBlur(value: number);
  65482. /**
  65483. * Gets or sets the grain amount
  65484. */
  65485. get grainAmount(): number;
  65486. set grainAmount(value: number);
  65487. /**
  65488. * Gets or sets the chromatic aberration amount
  65489. */
  65490. get chromaticAberration(): number;
  65491. set chromaticAberration(value: number);
  65492. /**
  65493. * Gets or sets the depth of field aperture
  65494. */
  65495. get dofAperture(): number;
  65496. set dofAperture(value: number);
  65497. /**
  65498. * Gets or sets the edge distortion
  65499. */
  65500. get edgeDistortion(): number;
  65501. set edgeDistortion(value: number);
  65502. /**
  65503. * Gets or sets the depth of field distortion
  65504. */
  65505. get dofDistortion(): number;
  65506. set dofDistortion(value: number);
  65507. /**
  65508. * Gets or sets the darken out of focus amount
  65509. */
  65510. get darkenOutOfFocus(): number;
  65511. set darkenOutOfFocus(value: number);
  65512. /**
  65513. * Gets or sets a boolean indicating if blur noise is enabled
  65514. */
  65515. get blurNoise(): boolean;
  65516. set blurNoise(value: boolean);
  65517. /**
  65518. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65519. */
  65520. get pentagonBokeh(): boolean;
  65521. set pentagonBokeh(value: boolean);
  65522. /**
  65523. * Gets or sets the highlight grain amount
  65524. */
  65525. get highlightsGain(): number;
  65526. set highlightsGain(value: number);
  65527. /**
  65528. * Gets or sets the highlight threshold
  65529. */
  65530. get highlightsThreshold(): number;
  65531. set highlightsThreshold(value: number);
  65532. /**
  65533. * Sets the amount of blur at the edges
  65534. * @param amount blur amount
  65535. */
  65536. setEdgeBlur(amount: number): void;
  65537. /**
  65538. * Sets edge blur to 0
  65539. */
  65540. disableEdgeBlur(): void;
  65541. /**
  65542. * Sets the amout of grain
  65543. * @param amount Amount of grain
  65544. */
  65545. setGrainAmount(amount: number): void;
  65546. /**
  65547. * Set grain amount to 0
  65548. */
  65549. disableGrain(): void;
  65550. /**
  65551. * Sets the chromatic aberration amount
  65552. * @param amount amount of chromatic aberration
  65553. */
  65554. setChromaticAberration(amount: number): void;
  65555. /**
  65556. * Sets chromatic aberration amount to 0
  65557. */
  65558. disableChromaticAberration(): void;
  65559. /**
  65560. * Sets the EdgeDistortion amount
  65561. * @param amount amount of EdgeDistortion
  65562. */
  65563. setEdgeDistortion(amount: number): void;
  65564. /**
  65565. * Sets edge distortion to 0
  65566. */
  65567. disableEdgeDistortion(): void;
  65568. /**
  65569. * Sets the FocusDistance amount
  65570. * @param amount amount of FocusDistance
  65571. */
  65572. setFocusDistance(amount: number): void;
  65573. /**
  65574. * Disables depth of field
  65575. */
  65576. disableDepthOfField(): void;
  65577. /**
  65578. * Sets the Aperture amount
  65579. * @param amount amount of Aperture
  65580. */
  65581. setAperture(amount: number): void;
  65582. /**
  65583. * Sets the DarkenOutOfFocus amount
  65584. * @param amount amount of DarkenOutOfFocus
  65585. */
  65586. setDarkenOutOfFocus(amount: number): void;
  65587. private _pentagonBokehIsEnabled;
  65588. /**
  65589. * Creates a pentagon bokeh effect
  65590. */
  65591. enablePentagonBokeh(): void;
  65592. /**
  65593. * Disables the pentagon bokeh effect
  65594. */
  65595. disablePentagonBokeh(): void;
  65596. /**
  65597. * Enables noise blur
  65598. */
  65599. enableNoiseBlur(): void;
  65600. /**
  65601. * Disables noise blur
  65602. */
  65603. disableNoiseBlur(): void;
  65604. /**
  65605. * Sets the HighlightsGain amount
  65606. * @param amount amount of HighlightsGain
  65607. */
  65608. setHighlightsGain(amount: number): void;
  65609. /**
  65610. * Sets the HighlightsThreshold amount
  65611. * @param amount amount of HighlightsThreshold
  65612. */
  65613. setHighlightsThreshold(amount: number): void;
  65614. /**
  65615. * Disables highlights
  65616. */
  65617. disableHighlights(): void;
  65618. /**
  65619. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65620. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65621. */
  65622. dispose(disableDepthRender?: boolean): void;
  65623. private _createChromaticAberrationPostProcess;
  65624. private _createHighlightsPostProcess;
  65625. private _createDepthOfFieldPostProcess;
  65626. private _createGrainTexture;
  65627. }
  65628. }
  65629. declare module BABYLON {
  65630. /** @hidden */
  65631. export var ssao2PixelShader: {
  65632. name: string;
  65633. shader: string;
  65634. };
  65635. }
  65636. declare module BABYLON {
  65637. /** @hidden */
  65638. export var ssaoCombinePixelShader: {
  65639. name: string;
  65640. shader: string;
  65641. };
  65642. }
  65643. declare module BABYLON {
  65644. /**
  65645. * Render pipeline to produce ssao effect
  65646. */
  65647. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65648. /**
  65649. * @ignore
  65650. * The PassPostProcess id in the pipeline that contains the original scene color
  65651. */
  65652. SSAOOriginalSceneColorEffect: string;
  65653. /**
  65654. * @ignore
  65655. * The SSAO PostProcess id in the pipeline
  65656. */
  65657. SSAORenderEffect: string;
  65658. /**
  65659. * @ignore
  65660. * The horizontal blur PostProcess id in the pipeline
  65661. */
  65662. SSAOBlurHRenderEffect: string;
  65663. /**
  65664. * @ignore
  65665. * The vertical blur PostProcess id in the pipeline
  65666. */
  65667. SSAOBlurVRenderEffect: string;
  65668. /**
  65669. * @ignore
  65670. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65671. */
  65672. SSAOCombineRenderEffect: string;
  65673. /**
  65674. * The output strength of the SSAO post-process. Default value is 1.0.
  65675. */
  65676. totalStrength: number;
  65677. /**
  65678. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65679. */
  65680. maxZ: number;
  65681. /**
  65682. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65683. */
  65684. minZAspect: number;
  65685. private _samples;
  65686. /**
  65687. * Number of samples used for the SSAO calculations. Default value is 8
  65688. */
  65689. set samples(n: number);
  65690. get samples(): number;
  65691. private _textureSamples;
  65692. /**
  65693. * Number of samples to use for antialiasing
  65694. */
  65695. set textureSamples(n: number);
  65696. get textureSamples(): number;
  65697. /**
  65698. * Ratio object used for SSAO ratio and blur ratio
  65699. */
  65700. private _ratio;
  65701. /**
  65702. * Dynamically generated sphere sampler.
  65703. */
  65704. private _sampleSphere;
  65705. /**
  65706. * Blur filter offsets
  65707. */
  65708. private _samplerOffsets;
  65709. private _expensiveBlur;
  65710. /**
  65711. * If bilateral blur should be used
  65712. */
  65713. set expensiveBlur(b: boolean);
  65714. get expensiveBlur(): boolean;
  65715. /**
  65716. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65717. */
  65718. radius: number;
  65719. /**
  65720. * The base color of the SSAO post-process
  65721. * The final result is "base + ssao" between [0, 1]
  65722. */
  65723. base: number;
  65724. /**
  65725. * Support test.
  65726. */
  65727. static get IsSupported(): boolean;
  65728. private _scene;
  65729. private _depthTexture;
  65730. private _normalTexture;
  65731. private _randomTexture;
  65732. private _originalColorPostProcess;
  65733. private _ssaoPostProcess;
  65734. private _blurHPostProcess;
  65735. private _blurVPostProcess;
  65736. private _ssaoCombinePostProcess;
  65737. /**
  65738. * Gets active scene
  65739. */
  65740. get scene(): Scene;
  65741. /**
  65742. * @constructor
  65743. * @param name The rendering pipeline name
  65744. * @param scene The scene linked to this pipeline
  65745. * @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 }
  65746. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65747. */
  65748. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65749. /**
  65750. * Get the class name
  65751. * @returns "SSAO2RenderingPipeline"
  65752. */
  65753. getClassName(): string;
  65754. /**
  65755. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65756. */
  65757. dispose(disableGeometryBufferRenderer?: boolean): void;
  65758. private _createBlurPostProcess;
  65759. /** @hidden */
  65760. _rebuild(): void;
  65761. private _bits;
  65762. private _radicalInverse_VdC;
  65763. private _hammersley;
  65764. private _hemisphereSample_uniform;
  65765. private _generateHemisphere;
  65766. private _createSSAOPostProcess;
  65767. private _createSSAOCombinePostProcess;
  65768. private _createRandomTexture;
  65769. /**
  65770. * Serialize the rendering pipeline (Used when exporting)
  65771. * @returns the serialized object
  65772. */
  65773. serialize(): any;
  65774. /**
  65775. * Parse the serialized pipeline
  65776. * @param source Source pipeline.
  65777. * @param scene The scene to load the pipeline to.
  65778. * @param rootUrl The URL of the serialized pipeline.
  65779. * @returns An instantiated pipeline from the serialized object.
  65780. */
  65781. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65782. }
  65783. }
  65784. declare module BABYLON {
  65785. /** @hidden */
  65786. export var ssaoPixelShader: {
  65787. name: string;
  65788. shader: string;
  65789. };
  65790. }
  65791. declare module BABYLON {
  65792. /**
  65793. * Render pipeline to produce ssao effect
  65794. */
  65795. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65796. /**
  65797. * @ignore
  65798. * The PassPostProcess id in the pipeline that contains the original scene color
  65799. */
  65800. SSAOOriginalSceneColorEffect: string;
  65801. /**
  65802. * @ignore
  65803. * The SSAO PostProcess id in the pipeline
  65804. */
  65805. SSAORenderEffect: string;
  65806. /**
  65807. * @ignore
  65808. * The horizontal blur PostProcess id in the pipeline
  65809. */
  65810. SSAOBlurHRenderEffect: string;
  65811. /**
  65812. * @ignore
  65813. * The vertical blur PostProcess id in the pipeline
  65814. */
  65815. SSAOBlurVRenderEffect: string;
  65816. /**
  65817. * @ignore
  65818. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65819. */
  65820. SSAOCombineRenderEffect: string;
  65821. /**
  65822. * The output strength of the SSAO post-process. Default value is 1.0.
  65823. */
  65824. totalStrength: number;
  65825. /**
  65826. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65827. */
  65828. radius: number;
  65829. /**
  65830. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65831. * Must not be equal to fallOff and superior to fallOff.
  65832. * Default value is 0.0075
  65833. */
  65834. area: number;
  65835. /**
  65836. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65837. * Must not be equal to area and inferior to area.
  65838. * Default value is 0.000001
  65839. */
  65840. fallOff: number;
  65841. /**
  65842. * The base color of the SSAO post-process
  65843. * The final result is "base + ssao" between [0, 1]
  65844. */
  65845. base: number;
  65846. private _scene;
  65847. private _depthTexture;
  65848. private _randomTexture;
  65849. private _originalColorPostProcess;
  65850. private _ssaoPostProcess;
  65851. private _blurHPostProcess;
  65852. private _blurVPostProcess;
  65853. private _ssaoCombinePostProcess;
  65854. private _firstUpdate;
  65855. /**
  65856. * Gets active scene
  65857. */
  65858. get scene(): Scene;
  65859. /**
  65860. * @constructor
  65861. * @param name - The rendering pipeline name
  65862. * @param scene - The scene linked to this pipeline
  65863. * @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 }
  65864. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65865. */
  65866. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65867. /**
  65868. * Get the class name
  65869. * @returns "SSAORenderingPipeline"
  65870. */
  65871. getClassName(): string;
  65872. /**
  65873. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65874. */
  65875. dispose(disableDepthRender?: boolean): void;
  65876. private _createBlurPostProcess;
  65877. /** @hidden */
  65878. _rebuild(): void;
  65879. private _createSSAOPostProcess;
  65880. private _createSSAOCombinePostProcess;
  65881. private _createRandomTexture;
  65882. }
  65883. }
  65884. declare module BABYLON {
  65885. /** @hidden */
  65886. export var screenSpaceReflectionPixelShader: {
  65887. name: string;
  65888. shader: string;
  65889. };
  65890. }
  65891. declare module BABYLON {
  65892. /**
  65893. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65894. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65895. */
  65896. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65897. /**
  65898. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65899. */
  65900. threshold: number;
  65901. /**
  65902. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65903. */
  65904. strength: number;
  65905. /**
  65906. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65907. */
  65908. reflectionSpecularFalloffExponent: number;
  65909. /**
  65910. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  65911. */
  65912. step: number;
  65913. /**
  65914. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65915. */
  65916. roughnessFactor: number;
  65917. private _geometryBufferRenderer;
  65918. private _enableSmoothReflections;
  65919. private _reflectionSamples;
  65920. private _smoothSteps;
  65921. /**
  65922. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65923. * @param name The name of the effect.
  65924. * @param scene The scene containing the objects to calculate reflections.
  65925. * @param options The required width/height ratio to downsize to before computing the render pass.
  65926. * @param camera The camera to apply the render pass to.
  65927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65928. * @param engine The engine which the post process will be applied. (default: current engine)
  65929. * @param reusable If the post process can be reused on the same frame. (default: false)
  65930. * @param textureType Type of textures used when performing the post process. (default: 0)
  65931. * @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)
  65932. */
  65933. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65934. /**
  65935. * Gets wether or not smoothing reflections is enabled.
  65936. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65937. */
  65938. get enableSmoothReflections(): boolean;
  65939. /**
  65940. * Sets wether or not smoothing reflections is enabled.
  65941. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65942. */
  65943. set enableSmoothReflections(enabled: boolean);
  65944. /**
  65945. * Gets the number of samples taken while computing reflections. More samples count is high,
  65946. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65947. */
  65948. get reflectionSamples(): number;
  65949. /**
  65950. * Sets the number of samples taken while computing reflections. More samples count is high,
  65951. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65952. */
  65953. set reflectionSamples(samples: number);
  65954. /**
  65955. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65956. * more the post-process will require GPU power and can generate a drop in FPS.
  65957. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65958. */
  65959. get smoothSteps(): number;
  65960. set smoothSteps(steps: number);
  65961. private _updateEffectDefines;
  65962. }
  65963. }
  65964. declare module BABYLON {
  65965. /** @hidden */
  65966. export var standardPixelShader: {
  65967. name: string;
  65968. shader: string;
  65969. };
  65970. }
  65971. declare module BABYLON {
  65972. /**
  65973. * Standard rendering pipeline
  65974. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65975. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65976. */
  65977. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65978. /**
  65979. * Public members
  65980. */
  65981. /**
  65982. * Post-process which contains the original scene color before the pipeline applies all the effects
  65983. */
  65984. originalPostProcess: Nullable<PostProcess>;
  65985. /**
  65986. * Post-process used to down scale an image x4
  65987. */
  65988. downSampleX4PostProcess: Nullable<PostProcess>;
  65989. /**
  65990. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65991. */
  65992. brightPassPostProcess: Nullable<PostProcess>;
  65993. /**
  65994. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65995. */
  65996. blurHPostProcesses: PostProcess[];
  65997. /**
  65998. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65999. */
  66000. blurVPostProcesses: PostProcess[];
  66001. /**
  66002. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66003. */
  66004. textureAdderPostProcess: Nullable<PostProcess>;
  66005. /**
  66006. * Post-process used to create volumetric lighting effect
  66007. */
  66008. volumetricLightPostProcess: Nullable<PostProcess>;
  66009. /**
  66010. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66011. */
  66012. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66013. /**
  66014. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66015. */
  66016. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66017. /**
  66018. * Post-process used to merge the volumetric light effect and the real scene color
  66019. */
  66020. volumetricLightMergePostProces: Nullable<PostProcess>;
  66021. /**
  66022. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66023. */
  66024. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66025. /**
  66026. * Base post-process used to calculate the average luminance of the final image for HDR
  66027. */
  66028. luminancePostProcess: Nullable<PostProcess>;
  66029. /**
  66030. * Post-processes used to create down sample post-processes in order to get
  66031. * the average luminance of the final image for HDR
  66032. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66033. */
  66034. luminanceDownSamplePostProcesses: PostProcess[];
  66035. /**
  66036. * Post-process used to create a HDR effect (light adaptation)
  66037. */
  66038. hdrPostProcess: Nullable<PostProcess>;
  66039. /**
  66040. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66041. */
  66042. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66043. /**
  66044. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66045. */
  66046. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66047. /**
  66048. * Post-process used to merge the final HDR post-process and the real scene color
  66049. */
  66050. hdrFinalPostProcess: Nullable<PostProcess>;
  66051. /**
  66052. * Post-process used to create a lens flare effect
  66053. */
  66054. lensFlarePostProcess: Nullable<PostProcess>;
  66055. /**
  66056. * Post-process that merges the result of the lens flare post-process and the real scene color
  66057. */
  66058. lensFlareComposePostProcess: Nullable<PostProcess>;
  66059. /**
  66060. * Post-process used to create a motion blur effect
  66061. */
  66062. motionBlurPostProcess: Nullable<PostProcess>;
  66063. /**
  66064. * Post-process used to create a depth of field effect
  66065. */
  66066. depthOfFieldPostProcess: Nullable<PostProcess>;
  66067. /**
  66068. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66069. */
  66070. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66071. /**
  66072. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66073. */
  66074. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66075. /**
  66076. * Represents the brightness threshold in order to configure the illuminated surfaces
  66077. */
  66078. brightThreshold: number;
  66079. /**
  66080. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66081. */
  66082. blurWidth: number;
  66083. /**
  66084. * Sets if the blur for highlighted surfaces must be only horizontal
  66085. */
  66086. horizontalBlur: boolean;
  66087. /**
  66088. * Gets the overall exposure used by the pipeline
  66089. */
  66090. get exposure(): number;
  66091. /**
  66092. * Sets the overall exposure used by the pipeline
  66093. */
  66094. set exposure(value: number);
  66095. /**
  66096. * Texture used typically to simulate "dirty" on camera lens
  66097. */
  66098. lensTexture: Nullable<Texture>;
  66099. /**
  66100. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66101. */
  66102. volumetricLightCoefficient: number;
  66103. /**
  66104. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66105. */
  66106. volumetricLightPower: number;
  66107. /**
  66108. * Used the set the blur intensity to smooth the volumetric lights
  66109. */
  66110. volumetricLightBlurScale: number;
  66111. /**
  66112. * Light (spot or directional) used to generate the volumetric lights rays
  66113. * The source light must have a shadow generate so the pipeline can get its
  66114. * depth map
  66115. */
  66116. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66117. /**
  66118. * For eye adaptation, represents the minimum luminance the eye can see
  66119. */
  66120. hdrMinimumLuminance: number;
  66121. /**
  66122. * For eye adaptation, represents the decrease luminance speed
  66123. */
  66124. hdrDecreaseRate: number;
  66125. /**
  66126. * For eye adaptation, represents the increase luminance speed
  66127. */
  66128. hdrIncreaseRate: number;
  66129. /**
  66130. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66131. */
  66132. get hdrAutoExposure(): boolean;
  66133. /**
  66134. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66135. */
  66136. set hdrAutoExposure(value: boolean);
  66137. /**
  66138. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66139. */
  66140. lensColorTexture: Nullable<Texture>;
  66141. /**
  66142. * The overall strengh for the lens flare effect
  66143. */
  66144. lensFlareStrength: number;
  66145. /**
  66146. * Dispersion coefficient for lens flare ghosts
  66147. */
  66148. lensFlareGhostDispersal: number;
  66149. /**
  66150. * Main lens flare halo width
  66151. */
  66152. lensFlareHaloWidth: number;
  66153. /**
  66154. * Based on the lens distortion effect, defines how much the lens flare result
  66155. * is distorted
  66156. */
  66157. lensFlareDistortionStrength: number;
  66158. /**
  66159. * Configures the blur intensity used for for lens flare (halo)
  66160. */
  66161. lensFlareBlurWidth: number;
  66162. /**
  66163. * Lens star texture must be used to simulate rays on the flares and is available
  66164. * in the documentation
  66165. */
  66166. lensStarTexture: Nullable<Texture>;
  66167. /**
  66168. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66169. * flare effect by taking account of the dirt texture
  66170. */
  66171. lensFlareDirtTexture: Nullable<Texture>;
  66172. /**
  66173. * Represents the focal length for the depth of field effect
  66174. */
  66175. depthOfFieldDistance: number;
  66176. /**
  66177. * Represents the blur intensity for the blurred part of the depth of field effect
  66178. */
  66179. depthOfFieldBlurWidth: number;
  66180. /**
  66181. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66182. */
  66183. get motionStrength(): number;
  66184. /**
  66185. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66186. */
  66187. set motionStrength(strength: number);
  66188. /**
  66189. * Gets wether or not the motion blur post-process is object based or screen based.
  66190. */
  66191. get objectBasedMotionBlur(): boolean;
  66192. /**
  66193. * Sets wether or not the motion blur post-process should be object based or screen based
  66194. */
  66195. set objectBasedMotionBlur(value: boolean);
  66196. /**
  66197. * List of animations for the pipeline (IAnimatable implementation)
  66198. */
  66199. animations: Animation[];
  66200. /**
  66201. * Private members
  66202. */
  66203. private _scene;
  66204. private _currentDepthOfFieldSource;
  66205. private _basePostProcess;
  66206. private _fixedExposure;
  66207. private _currentExposure;
  66208. private _hdrAutoExposure;
  66209. private _hdrCurrentLuminance;
  66210. private _motionStrength;
  66211. private _isObjectBasedMotionBlur;
  66212. private _floatTextureType;
  66213. private _camerasToBeAttached;
  66214. private _ratio;
  66215. private _bloomEnabled;
  66216. private _depthOfFieldEnabled;
  66217. private _vlsEnabled;
  66218. private _lensFlareEnabled;
  66219. private _hdrEnabled;
  66220. private _motionBlurEnabled;
  66221. private _fxaaEnabled;
  66222. private _screenSpaceReflectionsEnabled;
  66223. private _motionBlurSamples;
  66224. private _volumetricLightStepsCount;
  66225. private _samples;
  66226. /**
  66227. * @ignore
  66228. * Specifies if the bloom pipeline is enabled
  66229. */
  66230. get BloomEnabled(): boolean;
  66231. set BloomEnabled(enabled: boolean);
  66232. /**
  66233. * @ignore
  66234. * Specifies if the depth of field pipeline is enabed
  66235. */
  66236. get DepthOfFieldEnabled(): boolean;
  66237. set DepthOfFieldEnabled(enabled: boolean);
  66238. /**
  66239. * @ignore
  66240. * Specifies if the lens flare pipeline is enabed
  66241. */
  66242. get LensFlareEnabled(): boolean;
  66243. set LensFlareEnabled(enabled: boolean);
  66244. /**
  66245. * @ignore
  66246. * Specifies if the HDR pipeline is enabled
  66247. */
  66248. get HDREnabled(): boolean;
  66249. set HDREnabled(enabled: boolean);
  66250. /**
  66251. * @ignore
  66252. * Specifies if the volumetric lights scattering effect is enabled
  66253. */
  66254. get VLSEnabled(): boolean;
  66255. set VLSEnabled(enabled: boolean);
  66256. /**
  66257. * @ignore
  66258. * Specifies if the motion blur effect is enabled
  66259. */
  66260. get MotionBlurEnabled(): boolean;
  66261. set MotionBlurEnabled(enabled: boolean);
  66262. /**
  66263. * Specifies if anti-aliasing is enabled
  66264. */
  66265. get fxaaEnabled(): boolean;
  66266. set fxaaEnabled(enabled: boolean);
  66267. /**
  66268. * Specifies if screen space reflections are enabled.
  66269. */
  66270. get screenSpaceReflectionsEnabled(): boolean;
  66271. set screenSpaceReflectionsEnabled(enabled: boolean);
  66272. /**
  66273. * Specifies the number of steps used to calculate the volumetric lights
  66274. * Typically in interval [50, 200]
  66275. */
  66276. get volumetricLightStepsCount(): number;
  66277. set volumetricLightStepsCount(count: number);
  66278. /**
  66279. * Specifies the number of samples used for the motion blur effect
  66280. * Typically in interval [16, 64]
  66281. */
  66282. get motionBlurSamples(): number;
  66283. set motionBlurSamples(samples: number);
  66284. /**
  66285. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66286. */
  66287. get samples(): number;
  66288. set samples(sampleCount: number);
  66289. /**
  66290. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66291. * @constructor
  66292. * @param name The rendering pipeline name
  66293. * @param scene The scene linked to this pipeline
  66294. * @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)
  66295. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66296. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66297. */
  66298. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66299. private _buildPipeline;
  66300. private _createDownSampleX4PostProcess;
  66301. private _createBrightPassPostProcess;
  66302. private _createBlurPostProcesses;
  66303. private _createTextureAdderPostProcess;
  66304. private _createVolumetricLightPostProcess;
  66305. private _createLuminancePostProcesses;
  66306. private _createHdrPostProcess;
  66307. private _createLensFlarePostProcess;
  66308. private _createDepthOfFieldPostProcess;
  66309. private _createMotionBlurPostProcess;
  66310. private _getDepthTexture;
  66311. private _disposePostProcesses;
  66312. /**
  66313. * Dispose of the pipeline and stop all post processes
  66314. */
  66315. dispose(): void;
  66316. /**
  66317. * Serialize the rendering pipeline (Used when exporting)
  66318. * @returns the serialized object
  66319. */
  66320. serialize(): any;
  66321. /**
  66322. * Parse the serialized pipeline
  66323. * @param source Source pipeline.
  66324. * @param scene The scene to load the pipeline to.
  66325. * @param rootUrl The URL of the serialized pipeline.
  66326. * @returns An instantiated pipeline from the serialized object.
  66327. */
  66328. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66329. /**
  66330. * Luminance steps
  66331. */
  66332. static LuminanceSteps: number;
  66333. }
  66334. }
  66335. declare module BABYLON {
  66336. /** @hidden */
  66337. export var tonemapPixelShader: {
  66338. name: string;
  66339. shader: string;
  66340. };
  66341. }
  66342. declare module BABYLON {
  66343. /** Defines operator used for tonemapping */
  66344. export enum TonemappingOperator {
  66345. /** Hable */
  66346. Hable = 0,
  66347. /** Reinhard */
  66348. Reinhard = 1,
  66349. /** HejiDawson */
  66350. HejiDawson = 2,
  66351. /** Photographic */
  66352. Photographic = 3
  66353. }
  66354. /**
  66355. * Defines a post process to apply tone mapping
  66356. */
  66357. export class TonemapPostProcess extends PostProcess {
  66358. private _operator;
  66359. /** Defines the required exposure adjustement */
  66360. exposureAdjustment: number;
  66361. /**
  66362. * Creates a new TonemapPostProcess
  66363. * @param name defines the name of the postprocess
  66364. * @param _operator defines the operator to use
  66365. * @param exposureAdjustment defines the required exposure adjustement
  66366. * @param camera defines the camera to use (can be null)
  66367. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66368. * @param engine defines the hosting engine (can be ignore if camera is set)
  66369. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66370. */
  66371. constructor(name: string, _operator: TonemappingOperator,
  66372. /** Defines the required exposure adjustement */
  66373. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66374. }
  66375. }
  66376. declare module BABYLON {
  66377. /** @hidden */
  66378. export var volumetricLightScatteringPixelShader: {
  66379. name: string;
  66380. shader: string;
  66381. };
  66382. }
  66383. declare module BABYLON {
  66384. /** @hidden */
  66385. export var volumetricLightScatteringPassVertexShader: {
  66386. name: string;
  66387. shader: string;
  66388. };
  66389. }
  66390. declare module BABYLON {
  66391. /** @hidden */
  66392. export var volumetricLightScatteringPassPixelShader: {
  66393. name: string;
  66394. shader: string;
  66395. };
  66396. }
  66397. declare module BABYLON {
  66398. /**
  66399. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66400. */
  66401. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66402. private _volumetricLightScatteringPass;
  66403. private _volumetricLightScatteringRTT;
  66404. private _viewPort;
  66405. private _screenCoordinates;
  66406. private _cachedDefines;
  66407. /**
  66408. * If not undefined, the mesh position is computed from the attached node position
  66409. */
  66410. attachedNode: {
  66411. position: Vector3;
  66412. };
  66413. /**
  66414. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66415. */
  66416. customMeshPosition: Vector3;
  66417. /**
  66418. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66419. */
  66420. useCustomMeshPosition: boolean;
  66421. /**
  66422. * If the post-process should inverse the light scattering direction
  66423. */
  66424. invert: boolean;
  66425. /**
  66426. * The internal mesh used by the post-process
  66427. */
  66428. mesh: Mesh;
  66429. /**
  66430. * @hidden
  66431. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66432. */
  66433. get useDiffuseColor(): boolean;
  66434. set useDiffuseColor(useDiffuseColor: boolean);
  66435. /**
  66436. * Array containing the excluded meshes not rendered in the internal pass
  66437. */
  66438. excludedMeshes: AbstractMesh[];
  66439. /**
  66440. * Controls the overall intensity of the post-process
  66441. */
  66442. exposure: number;
  66443. /**
  66444. * Dissipates each sample's contribution in range [0, 1]
  66445. */
  66446. decay: number;
  66447. /**
  66448. * Controls the overall intensity of each sample
  66449. */
  66450. weight: number;
  66451. /**
  66452. * Controls the density of each sample
  66453. */
  66454. density: number;
  66455. /**
  66456. * @constructor
  66457. * @param name The post-process name
  66458. * @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)
  66459. * @param camera The camera that the post-process will be attached to
  66460. * @param mesh The mesh used to create the light scattering
  66461. * @param samples The post-process quality, default 100
  66462. * @param samplingModeThe post-process filtering mode
  66463. * @param engine The babylon engine
  66464. * @param reusable If the post-process is reusable
  66465. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66466. */
  66467. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66468. /**
  66469. * Returns the string "VolumetricLightScatteringPostProcess"
  66470. * @returns "VolumetricLightScatteringPostProcess"
  66471. */
  66472. getClassName(): string;
  66473. private _isReady;
  66474. /**
  66475. * Sets the new light position for light scattering effect
  66476. * @param position The new custom light position
  66477. */
  66478. setCustomMeshPosition(position: Vector3): void;
  66479. /**
  66480. * Returns the light position for light scattering effect
  66481. * @return Vector3 The custom light position
  66482. */
  66483. getCustomMeshPosition(): Vector3;
  66484. /**
  66485. * Disposes the internal assets and detaches the post-process from the camera
  66486. */
  66487. dispose(camera: Camera): void;
  66488. /**
  66489. * Returns the render target texture used by the post-process
  66490. * @return the render target texture used by the post-process
  66491. */
  66492. getPass(): RenderTargetTexture;
  66493. private _meshExcluded;
  66494. private _createPass;
  66495. private _updateMeshScreenCoordinates;
  66496. /**
  66497. * Creates a default mesh for the Volumeric Light Scattering post-process
  66498. * @param name The mesh name
  66499. * @param scene The scene where to create the mesh
  66500. * @return the default mesh
  66501. */
  66502. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66503. }
  66504. }
  66505. declare module BABYLON {
  66506. interface Scene {
  66507. /** @hidden (Backing field) */
  66508. _boundingBoxRenderer: BoundingBoxRenderer;
  66509. /** @hidden (Backing field) */
  66510. _forceShowBoundingBoxes: boolean;
  66511. /**
  66512. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66513. */
  66514. forceShowBoundingBoxes: boolean;
  66515. /**
  66516. * Gets the bounding box renderer associated with the scene
  66517. * @returns a BoundingBoxRenderer
  66518. */
  66519. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66520. }
  66521. interface AbstractMesh {
  66522. /** @hidden (Backing field) */
  66523. _showBoundingBox: boolean;
  66524. /**
  66525. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66526. */
  66527. showBoundingBox: boolean;
  66528. }
  66529. /**
  66530. * Component responsible of rendering the bounding box of the meshes in a scene.
  66531. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66532. */
  66533. export class BoundingBoxRenderer implements ISceneComponent {
  66534. /**
  66535. * The component name helpfull to identify the component in the list of scene components.
  66536. */
  66537. readonly name: string;
  66538. /**
  66539. * The scene the component belongs to.
  66540. */
  66541. scene: Scene;
  66542. /**
  66543. * Color of the bounding box lines placed in front of an object
  66544. */
  66545. frontColor: Color3;
  66546. /**
  66547. * Color of the bounding box lines placed behind an object
  66548. */
  66549. backColor: Color3;
  66550. /**
  66551. * Defines if the renderer should show the back lines or not
  66552. */
  66553. showBackLines: boolean;
  66554. /**
  66555. * @hidden
  66556. */
  66557. renderList: SmartArray<BoundingBox>;
  66558. private _colorShader;
  66559. private _vertexBuffers;
  66560. private _indexBuffer;
  66561. private _fillIndexBuffer;
  66562. private _fillIndexData;
  66563. /**
  66564. * Instantiates a new bounding box renderer in a scene.
  66565. * @param scene the scene the renderer renders in
  66566. */
  66567. constructor(scene: Scene);
  66568. /**
  66569. * Registers the component in a given scene
  66570. */
  66571. register(): void;
  66572. private _evaluateSubMesh;
  66573. private _activeMesh;
  66574. private _prepareRessources;
  66575. private _createIndexBuffer;
  66576. /**
  66577. * Rebuilds the elements related to this component in case of
  66578. * context lost for instance.
  66579. */
  66580. rebuild(): void;
  66581. /**
  66582. * @hidden
  66583. */
  66584. reset(): void;
  66585. /**
  66586. * Render the bounding boxes of a specific rendering group
  66587. * @param renderingGroupId defines the rendering group to render
  66588. */
  66589. render(renderingGroupId: number): void;
  66590. /**
  66591. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66592. * @param mesh Define the mesh to render the occlusion bounding box for
  66593. */
  66594. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66595. /**
  66596. * Dispose and release the resources attached to this renderer.
  66597. */
  66598. dispose(): void;
  66599. }
  66600. }
  66601. declare module BABYLON {
  66602. interface Scene {
  66603. /** @hidden (Backing field) */
  66604. _depthRenderer: {
  66605. [id: string]: DepthRenderer;
  66606. };
  66607. /**
  66608. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66609. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66610. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66611. * @returns the created depth renderer
  66612. */
  66613. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66614. /**
  66615. * Disables a depth renderer for a given camera
  66616. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66617. */
  66618. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66619. }
  66620. /**
  66621. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66622. * in several rendering techniques.
  66623. */
  66624. export class DepthRendererSceneComponent implements ISceneComponent {
  66625. /**
  66626. * The component name helpfull to identify the component in the list of scene components.
  66627. */
  66628. readonly name: string;
  66629. /**
  66630. * The scene the component belongs to.
  66631. */
  66632. scene: Scene;
  66633. /**
  66634. * Creates a new instance of the component for the given scene
  66635. * @param scene Defines the scene to register the component in
  66636. */
  66637. constructor(scene: Scene);
  66638. /**
  66639. * Registers the component in a given scene
  66640. */
  66641. register(): void;
  66642. /**
  66643. * Rebuilds the elements related to this component in case of
  66644. * context lost for instance.
  66645. */
  66646. rebuild(): void;
  66647. /**
  66648. * Disposes the component and the associated ressources
  66649. */
  66650. dispose(): void;
  66651. private _gatherRenderTargets;
  66652. private _gatherActiveCameraRenderTargets;
  66653. }
  66654. }
  66655. declare module BABYLON {
  66656. /** @hidden */
  66657. export var outlinePixelShader: {
  66658. name: string;
  66659. shader: string;
  66660. };
  66661. }
  66662. declare module BABYLON {
  66663. /** @hidden */
  66664. export var outlineVertexShader: {
  66665. name: string;
  66666. shader: string;
  66667. };
  66668. }
  66669. declare module BABYLON {
  66670. interface Scene {
  66671. /** @hidden */
  66672. _outlineRenderer: OutlineRenderer;
  66673. /**
  66674. * Gets the outline renderer associated with the scene
  66675. * @returns a OutlineRenderer
  66676. */
  66677. getOutlineRenderer(): OutlineRenderer;
  66678. }
  66679. interface AbstractMesh {
  66680. /** @hidden (Backing field) */
  66681. _renderOutline: boolean;
  66682. /**
  66683. * Gets or sets a boolean indicating if the outline must be rendered as well
  66684. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66685. */
  66686. renderOutline: boolean;
  66687. /** @hidden (Backing field) */
  66688. _renderOverlay: boolean;
  66689. /**
  66690. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66691. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66692. */
  66693. renderOverlay: boolean;
  66694. }
  66695. /**
  66696. * This class is responsible to draw bothe outline/overlay of meshes.
  66697. * It should not be used directly but through the available method on mesh.
  66698. */
  66699. export class OutlineRenderer implements ISceneComponent {
  66700. /**
  66701. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66702. */
  66703. private static _StencilReference;
  66704. /**
  66705. * The name of the component. Each component must have a unique name.
  66706. */
  66707. name: string;
  66708. /**
  66709. * The scene the component belongs to.
  66710. */
  66711. scene: Scene;
  66712. /**
  66713. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66714. */
  66715. zOffset: number;
  66716. private _engine;
  66717. private _effect;
  66718. private _cachedDefines;
  66719. private _savedDepthWrite;
  66720. /**
  66721. * Instantiates a new outline renderer. (There could be only one per scene).
  66722. * @param scene Defines the scene it belongs to
  66723. */
  66724. constructor(scene: Scene);
  66725. /**
  66726. * Register the component to one instance of a scene.
  66727. */
  66728. register(): void;
  66729. /**
  66730. * Rebuilds the elements related to this component in case of
  66731. * context lost for instance.
  66732. */
  66733. rebuild(): void;
  66734. /**
  66735. * Disposes the component and the associated ressources.
  66736. */
  66737. dispose(): void;
  66738. /**
  66739. * Renders the outline in the canvas.
  66740. * @param subMesh Defines the sumesh to render
  66741. * @param batch Defines the batch of meshes in case of instances
  66742. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66743. */
  66744. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66745. /**
  66746. * Returns whether or not the outline renderer is ready for a given submesh.
  66747. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66748. * @param subMesh Defines the submesh to check readyness for
  66749. * @param useInstances Defines wheter wee are trying to render instances or not
  66750. * @returns true if ready otherwise false
  66751. */
  66752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66753. private _beforeRenderingMesh;
  66754. private _afterRenderingMesh;
  66755. }
  66756. }
  66757. declare module BABYLON {
  66758. /**
  66759. * Defines the basic options interface of a Sprite Frame Source Size.
  66760. */
  66761. export interface ISpriteJSONSpriteSourceSize {
  66762. /**
  66763. * number of the original width of the Frame
  66764. */
  66765. w: number;
  66766. /**
  66767. * number of the original height of the Frame
  66768. */
  66769. h: number;
  66770. }
  66771. /**
  66772. * Defines the basic options interface of a Sprite Frame Data.
  66773. */
  66774. export interface ISpriteJSONSpriteFrameData {
  66775. /**
  66776. * number of the x offset of the Frame
  66777. */
  66778. x: number;
  66779. /**
  66780. * number of the y offset of the Frame
  66781. */
  66782. y: number;
  66783. /**
  66784. * number of the width of the Frame
  66785. */
  66786. w: number;
  66787. /**
  66788. * number of the height of the Frame
  66789. */
  66790. h: number;
  66791. }
  66792. /**
  66793. * Defines the basic options interface of a JSON Sprite.
  66794. */
  66795. export interface ISpriteJSONSprite {
  66796. /**
  66797. * string name of the Frame
  66798. */
  66799. filename: string;
  66800. /**
  66801. * ISpriteJSONSpriteFrame basic object of the frame data
  66802. */
  66803. frame: ISpriteJSONSpriteFrameData;
  66804. /**
  66805. * boolean to flag is the frame was rotated.
  66806. */
  66807. rotated: boolean;
  66808. /**
  66809. * boolean to flag is the frame was trimmed.
  66810. */
  66811. trimmed: boolean;
  66812. /**
  66813. * ISpriteJSONSpriteFrame basic object of the source data
  66814. */
  66815. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66816. /**
  66817. * ISpriteJSONSpriteFrame basic object of the source data
  66818. */
  66819. sourceSize: ISpriteJSONSpriteSourceSize;
  66820. }
  66821. /**
  66822. * Defines the basic options interface of a JSON atlas.
  66823. */
  66824. export interface ISpriteJSONAtlas {
  66825. /**
  66826. * Array of objects that contain the frame data.
  66827. */
  66828. frames: Array<ISpriteJSONSprite>;
  66829. /**
  66830. * object basic object containing the sprite meta data.
  66831. */
  66832. meta?: object;
  66833. }
  66834. }
  66835. declare module BABYLON {
  66836. /** @hidden */
  66837. export var spriteMapPixelShader: {
  66838. name: string;
  66839. shader: string;
  66840. };
  66841. }
  66842. declare module BABYLON {
  66843. /** @hidden */
  66844. export var spriteMapVertexShader: {
  66845. name: string;
  66846. shader: string;
  66847. };
  66848. }
  66849. declare module BABYLON {
  66850. /**
  66851. * Defines the basic options interface of a SpriteMap
  66852. */
  66853. export interface ISpriteMapOptions {
  66854. /**
  66855. * Vector2 of the number of cells in the grid.
  66856. */
  66857. stageSize?: Vector2;
  66858. /**
  66859. * Vector2 of the size of the output plane in World Units.
  66860. */
  66861. outputSize?: Vector2;
  66862. /**
  66863. * Vector3 of the position of the output plane in World Units.
  66864. */
  66865. outputPosition?: Vector3;
  66866. /**
  66867. * Vector3 of the rotation of the output plane.
  66868. */
  66869. outputRotation?: Vector3;
  66870. /**
  66871. * number of layers that the system will reserve in resources.
  66872. */
  66873. layerCount?: number;
  66874. /**
  66875. * number of max animation frames a single cell will reserve in resources.
  66876. */
  66877. maxAnimationFrames?: number;
  66878. /**
  66879. * number cell index of the base tile when the system compiles.
  66880. */
  66881. baseTile?: number;
  66882. /**
  66883. * boolean flip the sprite after its been repositioned by the framing data.
  66884. */
  66885. flipU?: boolean;
  66886. /**
  66887. * Vector3 scalar of the global RGB values of the SpriteMap.
  66888. */
  66889. colorMultiply?: Vector3;
  66890. }
  66891. /**
  66892. * Defines the IDisposable interface in order to be cleanable from resources.
  66893. */
  66894. export interface ISpriteMap extends IDisposable {
  66895. /**
  66896. * String name of the SpriteMap.
  66897. */
  66898. name: string;
  66899. /**
  66900. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66901. */
  66902. atlasJSON: ISpriteJSONAtlas;
  66903. /**
  66904. * Texture of the SpriteMap.
  66905. */
  66906. spriteSheet: Texture;
  66907. /**
  66908. * The parameters to initialize the SpriteMap with.
  66909. */
  66910. options: ISpriteMapOptions;
  66911. }
  66912. /**
  66913. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66914. */
  66915. export class SpriteMap implements ISpriteMap {
  66916. /** The Name of the spriteMap */
  66917. name: string;
  66918. /** The JSON file with the frame and meta data */
  66919. atlasJSON: ISpriteJSONAtlas;
  66920. /** The systems Sprite Sheet Texture */
  66921. spriteSheet: Texture;
  66922. /** Arguments passed with the Constructor */
  66923. options: ISpriteMapOptions;
  66924. /** Public Sprite Storage array, parsed from atlasJSON */
  66925. sprites: Array<ISpriteJSONSprite>;
  66926. /** Returns the Number of Sprites in the System */
  66927. get spriteCount(): number;
  66928. /** Returns the Position of Output Plane*/
  66929. get position(): Vector3;
  66930. /** Returns the Position of Output Plane*/
  66931. set position(v: Vector3);
  66932. /** Returns the Rotation of Output Plane*/
  66933. get rotation(): Vector3;
  66934. /** Returns the Rotation of Output Plane*/
  66935. set rotation(v: Vector3);
  66936. /** Sets the AnimationMap*/
  66937. get animationMap(): RawTexture;
  66938. /** Sets the AnimationMap*/
  66939. set animationMap(v: RawTexture);
  66940. /** Scene that the SpriteMap was created in */
  66941. private _scene;
  66942. /** Texture Buffer of Float32 that holds tile frame data*/
  66943. private _frameMap;
  66944. /** Texture Buffers of Float32 that holds tileMap data*/
  66945. private _tileMaps;
  66946. /** Texture Buffer of Float32 that holds Animation Data*/
  66947. private _animationMap;
  66948. /** Custom ShaderMaterial Central to the System*/
  66949. private _material;
  66950. /** Custom ShaderMaterial Central to the System*/
  66951. private _output;
  66952. /** Systems Time Ticker*/
  66953. private _time;
  66954. /**
  66955. * Creates a new SpriteMap
  66956. * @param name defines the SpriteMaps Name
  66957. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66958. * @param spriteSheet is the Texture that the Sprites are on.
  66959. * @param options a basic deployment configuration
  66960. * @param scene The Scene that the map is deployed on
  66961. */
  66962. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66963. /**
  66964. * Returns tileID location
  66965. * @returns Vector2 the cell position ID
  66966. */
  66967. getTileID(): Vector2;
  66968. /**
  66969. * Gets the UV location of the mouse over the SpriteMap.
  66970. * @returns Vector2 the UV position of the mouse interaction
  66971. */
  66972. getMousePosition(): Vector2;
  66973. /**
  66974. * Creates the "frame" texture Buffer
  66975. * -------------------------------------
  66976. * Structure of frames
  66977. * "filename": "Falling-Water-2.png",
  66978. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66979. * "rotated": true,
  66980. * "trimmed": true,
  66981. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66982. * "sourceSize": {"w":32,"h":32}
  66983. * @returns RawTexture of the frameMap
  66984. */
  66985. private _createFrameBuffer;
  66986. /**
  66987. * Creates the tileMap texture Buffer
  66988. * @param buffer normally and array of numbers, or a false to generate from scratch
  66989. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66990. * @returns RawTexture of the tileMap
  66991. */
  66992. private _createTileBuffer;
  66993. /**
  66994. * Modifies the data of the tileMaps
  66995. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66996. * @param pos is the iVector2 Coordinates of the Tile
  66997. * @param tile The SpriteIndex of the new Tile
  66998. */
  66999. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67000. /**
  67001. * Creates the animationMap texture Buffer
  67002. * @param buffer normally and array of numbers, or a false to generate from scratch
  67003. * @returns RawTexture of the animationMap
  67004. */
  67005. private _createTileAnimationBuffer;
  67006. /**
  67007. * Modifies the data of the animationMap
  67008. * @param cellID is the Index of the Sprite
  67009. * @param _frame is the target Animation frame
  67010. * @param toCell is the Target Index of the next frame of the animation
  67011. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67012. * @param speed is a global scalar of the time variable on the map.
  67013. */
  67014. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67015. /**
  67016. * Exports the .tilemaps file
  67017. */
  67018. saveTileMaps(): void;
  67019. /**
  67020. * Imports the .tilemaps file
  67021. * @param url of the .tilemaps file
  67022. */
  67023. loadTileMaps(url: string): void;
  67024. /**
  67025. * Release associated resources
  67026. */
  67027. dispose(): void;
  67028. }
  67029. }
  67030. declare module BABYLON {
  67031. /**
  67032. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67033. * @see http://doc.babylonjs.com/babylon101/sprites
  67034. */
  67035. export class SpritePackedManager extends SpriteManager {
  67036. /** defines the packed manager's name */
  67037. name: string;
  67038. /**
  67039. * Creates a new sprite manager from a packed sprite sheet
  67040. * @param name defines the manager's name
  67041. * @param imgUrl defines the sprite sheet url
  67042. * @param capacity defines the maximum allowed number of sprites
  67043. * @param scene defines the hosting scene
  67044. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67045. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67046. * @param samplingMode defines the smapling mode to use with spritesheet
  67047. * @param fromPacked set to true; do not alter
  67048. */
  67049. constructor(
  67050. /** defines the packed manager's name */
  67051. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67052. }
  67053. }
  67054. declare module BABYLON {
  67055. /**
  67056. * Defines the list of states available for a task inside a AssetsManager
  67057. */
  67058. export enum AssetTaskState {
  67059. /**
  67060. * Initialization
  67061. */
  67062. INIT = 0,
  67063. /**
  67064. * Running
  67065. */
  67066. RUNNING = 1,
  67067. /**
  67068. * Done
  67069. */
  67070. DONE = 2,
  67071. /**
  67072. * Error
  67073. */
  67074. ERROR = 3
  67075. }
  67076. /**
  67077. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67078. */
  67079. export abstract class AbstractAssetTask {
  67080. /**
  67081. * Task name
  67082. */ name: string;
  67083. /**
  67084. * Callback called when the task is successful
  67085. */
  67086. onSuccess: (task: any) => void;
  67087. /**
  67088. * Callback called when the task is not successful
  67089. */
  67090. onError: (task: any, message?: string, exception?: any) => void;
  67091. /**
  67092. * Creates a new AssetsManager
  67093. * @param name defines the name of the task
  67094. */
  67095. constructor(
  67096. /**
  67097. * Task name
  67098. */ name: string);
  67099. private _isCompleted;
  67100. private _taskState;
  67101. private _errorObject;
  67102. /**
  67103. * Get if the task is completed
  67104. */
  67105. get isCompleted(): boolean;
  67106. /**
  67107. * Gets the current state of the task
  67108. */
  67109. get taskState(): AssetTaskState;
  67110. /**
  67111. * Gets the current error object (if task is in error)
  67112. */
  67113. get errorObject(): {
  67114. message?: string;
  67115. exception?: any;
  67116. };
  67117. /**
  67118. * Internal only
  67119. * @hidden
  67120. */
  67121. _setErrorObject(message?: string, exception?: any): void;
  67122. /**
  67123. * Execute the current task
  67124. * @param scene defines the scene where you want your assets to be loaded
  67125. * @param onSuccess is a callback called when the task is successfully executed
  67126. * @param onError is a callback called if an error occurs
  67127. */
  67128. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67129. /**
  67130. * Execute the current task
  67131. * @param scene defines the scene where you want your assets to be loaded
  67132. * @param onSuccess is a callback called when the task is successfully executed
  67133. * @param onError is a callback called if an error occurs
  67134. */
  67135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67136. /**
  67137. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67138. * This can be used with failed tasks that have the reason for failure fixed.
  67139. */
  67140. reset(): void;
  67141. private onErrorCallback;
  67142. private onDoneCallback;
  67143. }
  67144. /**
  67145. * Define the interface used by progress events raised during assets loading
  67146. */
  67147. export interface IAssetsProgressEvent {
  67148. /**
  67149. * Defines the number of remaining tasks to process
  67150. */
  67151. remainingCount: number;
  67152. /**
  67153. * Defines the total number of tasks
  67154. */
  67155. totalCount: number;
  67156. /**
  67157. * Defines the task that was just processed
  67158. */
  67159. task: AbstractAssetTask;
  67160. }
  67161. /**
  67162. * Class used to share progress information about assets loading
  67163. */
  67164. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67165. /**
  67166. * Defines the number of remaining tasks to process
  67167. */
  67168. remainingCount: number;
  67169. /**
  67170. * Defines the total number of tasks
  67171. */
  67172. totalCount: number;
  67173. /**
  67174. * Defines the task that was just processed
  67175. */
  67176. task: AbstractAssetTask;
  67177. /**
  67178. * Creates a AssetsProgressEvent
  67179. * @param remainingCount defines the number of remaining tasks to process
  67180. * @param totalCount defines the total number of tasks
  67181. * @param task defines the task that was just processed
  67182. */
  67183. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67184. }
  67185. /**
  67186. * Define a task used by AssetsManager to load meshes
  67187. */
  67188. export class MeshAssetTask extends AbstractAssetTask {
  67189. /**
  67190. * Defines the name of the task
  67191. */
  67192. name: string;
  67193. /**
  67194. * Defines the list of mesh's names you want to load
  67195. */
  67196. meshesNames: any;
  67197. /**
  67198. * Defines the root url to use as a base to load your meshes and associated resources
  67199. */
  67200. rootUrl: string;
  67201. /**
  67202. * Defines the filename of the scene to load from
  67203. */
  67204. sceneFilename: string;
  67205. /**
  67206. * Gets the list of loaded meshes
  67207. */
  67208. loadedMeshes: Array<AbstractMesh>;
  67209. /**
  67210. * Gets the list of loaded particle systems
  67211. */
  67212. loadedParticleSystems: Array<IParticleSystem>;
  67213. /**
  67214. * Gets the list of loaded skeletons
  67215. */
  67216. loadedSkeletons: Array<Skeleton>;
  67217. /**
  67218. * Gets the list of loaded animation groups
  67219. */
  67220. loadedAnimationGroups: Array<AnimationGroup>;
  67221. /**
  67222. * Callback called when the task is successful
  67223. */
  67224. onSuccess: (task: MeshAssetTask) => void;
  67225. /**
  67226. * Callback called when the task is successful
  67227. */
  67228. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67229. /**
  67230. * Creates a new MeshAssetTask
  67231. * @param name defines the name of the task
  67232. * @param meshesNames defines the list of mesh's names you want to load
  67233. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67234. * @param sceneFilename defines the filename of the scene to load from
  67235. */
  67236. constructor(
  67237. /**
  67238. * Defines the name of the task
  67239. */
  67240. name: string,
  67241. /**
  67242. * Defines the list of mesh's names you want to load
  67243. */
  67244. meshesNames: any,
  67245. /**
  67246. * Defines the root url to use as a base to load your meshes and associated resources
  67247. */
  67248. rootUrl: string,
  67249. /**
  67250. * Defines the filename of the scene to load from
  67251. */
  67252. sceneFilename: string);
  67253. /**
  67254. * Execute the current task
  67255. * @param scene defines the scene where you want your assets to be loaded
  67256. * @param onSuccess is a callback called when the task is successfully executed
  67257. * @param onError is a callback called if an error occurs
  67258. */
  67259. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67260. }
  67261. /**
  67262. * Define a task used by AssetsManager to load text content
  67263. */
  67264. export class TextFileAssetTask extends AbstractAssetTask {
  67265. /**
  67266. * Defines the name of the task
  67267. */
  67268. name: string;
  67269. /**
  67270. * Defines the location of the file to load
  67271. */
  67272. url: string;
  67273. /**
  67274. * Gets the loaded text string
  67275. */
  67276. text: string;
  67277. /**
  67278. * Callback called when the task is successful
  67279. */
  67280. onSuccess: (task: TextFileAssetTask) => void;
  67281. /**
  67282. * Callback called when the task is successful
  67283. */
  67284. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67285. /**
  67286. * Creates a new TextFileAssetTask object
  67287. * @param name defines the name of the task
  67288. * @param url defines the location of the file to load
  67289. */
  67290. constructor(
  67291. /**
  67292. * Defines the name of the task
  67293. */
  67294. name: string,
  67295. /**
  67296. * Defines the location of the file to load
  67297. */
  67298. url: string);
  67299. /**
  67300. * Execute the current task
  67301. * @param scene defines the scene where you want your assets to be loaded
  67302. * @param onSuccess is a callback called when the task is successfully executed
  67303. * @param onError is a callback called if an error occurs
  67304. */
  67305. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67306. }
  67307. /**
  67308. * Define a task used by AssetsManager to load binary data
  67309. */
  67310. export class BinaryFileAssetTask extends AbstractAssetTask {
  67311. /**
  67312. * Defines the name of the task
  67313. */
  67314. name: string;
  67315. /**
  67316. * Defines the location of the file to load
  67317. */
  67318. url: string;
  67319. /**
  67320. * Gets the lodaded data (as an array buffer)
  67321. */
  67322. data: ArrayBuffer;
  67323. /**
  67324. * Callback called when the task is successful
  67325. */
  67326. onSuccess: (task: BinaryFileAssetTask) => void;
  67327. /**
  67328. * Callback called when the task is successful
  67329. */
  67330. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67331. /**
  67332. * Creates a new BinaryFileAssetTask object
  67333. * @param name defines the name of the new task
  67334. * @param url defines the location of the file to load
  67335. */
  67336. constructor(
  67337. /**
  67338. * Defines the name of the task
  67339. */
  67340. name: string,
  67341. /**
  67342. * Defines the location of the file to load
  67343. */
  67344. url: string);
  67345. /**
  67346. * Execute the current task
  67347. * @param scene defines the scene where you want your assets to be loaded
  67348. * @param onSuccess is a callback called when the task is successfully executed
  67349. * @param onError is a callback called if an error occurs
  67350. */
  67351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67352. }
  67353. /**
  67354. * Define a task used by AssetsManager to load images
  67355. */
  67356. export class ImageAssetTask extends AbstractAssetTask {
  67357. /**
  67358. * Defines the name of the task
  67359. */
  67360. name: string;
  67361. /**
  67362. * Defines the location of the image to load
  67363. */
  67364. url: string;
  67365. /**
  67366. * Gets the loaded images
  67367. */
  67368. image: HTMLImageElement;
  67369. /**
  67370. * Callback called when the task is successful
  67371. */
  67372. onSuccess: (task: ImageAssetTask) => void;
  67373. /**
  67374. * Callback called when the task is successful
  67375. */
  67376. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67377. /**
  67378. * Creates a new ImageAssetTask
  67379. * @param name defines the name of the task
  67380. * @param url defines the location of the image to load
  67381. */
  67382. constructor(
  67383. /**
  67384. * Defines the name of the task
  67385. */
  67386. name: string,
  67387. /**
  67388. * Defines the location of the image to load
  67389. */
  67390. url: string);
  67391. /**
  67392. * Execute the current task
  67393. * @param scene defines the scene where you want your assets to be loaded
  67394. * @param onSuccess is a callback called when the task is successfully executed
  67395. * @param onError is a callback called if an error occurs
  67396. */
  67397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67398. }
  67399. /**
  67400. * Defines the interface used by texture loading tasks
  67401. */
  67402. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67403. /**
  67404. * Gets the loaded texture
  67405. */
  67406. texture: TEX;
  67407. }
  67408. /**
  67409. * Define a task used by AssetsManager to load 2D textures
  67410. */
  67411. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67412. /**
  67413. * Defines the name of the task
  67414. */
  67415. name: string;
  67416. /**
  67417. * Defines the location of the file to load
  67418. */
  67419. url: string;
  67420. /**
  67421. * Defines if mipmap should not be generated (default is false)
  67422. */
  67423. noMipmap?: boolean | undefined;
  67424. /**
  67425. * Defines if texture must be inverted on Y axis (default is false)
  67426. */
  67427. invertY?: boolean | undefined;
  67428. /**
  67429. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67430. */
  67431. samplingMode: number;
  67432. /**
  67433. * Gets the loaded texture
  67434. */
  67435. texture: Texture;
  67436. /**
  67437. * Callback called when the task is successful
  67438. */
  67439. onSuccess: (task: TextureAssetTask) => void;
  67440. /**
  67441. * Callback called when the task is successful
  67442. */
  67443. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67444. /**
  67445. * Creates a new TextureAssetTask object
  67446. * @param name defines the name of the task
  67447. * @param url defines the location of the file to load
  67448. * @param noMipmap defines if mipmap should not be generated (default is false)
  67449. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67450. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67451. */
  67452. constructor(
  67453. /**
  67454. * Defines the name of the task
  67455. */
  67456. name: string,
  67457. /**
  67458. * Defines the location of the file to load
  67459. */
  67460. url: string,
  67461. /**
  67462. * Defines if mipmap should not be generated (default is false)
  67463. */
  67464. noMipmap?: boolean | undefined,
  67465. /**
  67466. * Defines if texture must be inverted on Y axis (default is false)
  67467. */
  67468. invertY?: boolean | undefined,
  67469. /**
  67470. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67471. */
  67472. samplingMode?: number);
  67473. /**
  67474. * Execute the current task
  67475. * @param scene defines the scene where you want your assets to be loaded
  67476. * @param onSuccess is a callback called when the task is successfully executed
  67477. * @param onError is a callback called if an error occurs
  67478. */
  67479. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67480. }
  67481. /**
  67482. * Define a task used by AssetsManager to load cube textures
  67483. */
  67484. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67485. /**
  67486. * Defines the name of the task
  67487. */
  67488. name: string;
  67489. /**
  67490. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67491. */
  67492. url: string;
  67493. /**
  67494. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67495. */
  67496. extensions?: string[] | undefined;
  67497. /**
  67498. * Defines if mipmaps should not be generated (default is false)
  67499. */
  67500. noMipmap?: boolean | undefined;
  67501. /**
  67502. * Defines the explicit list of files (undefined by default)
  67503. */
  67504. files?: string[] | undefined;
  67505. /**
  67506. * Gets the loaded texture
  67507. */
  67508. texture: CubeTexture;
  67509. /**
  67510. * Callback called when the task is successful
  67511. */
  67512. onSuccess: (task: CubeTextureAssetTask) => void;
  67513. /**
  67514. * Callback called when the task is successful
  67515. */
  67516. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67517. /**
  67518. * Creates a new CubeTextureAssetTask
  67519. * @param name defines the name of the task
  67520. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67521. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67522. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67523. * @param files defines the explicit list of files (undefined by default)
  67524. */
  67525. constructor(
  67526. /**
  67527. * Defines the name of the task
  67528. */
  67529. name: string,
  67530. /**
  67531. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67532. */
  67533. url: string,
  67534. /**
  67535. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67536. */
  67537. extensions?: string[] | undefined,
  67538. /**
  67539. * Defines if mipmaps should not be generated (default is false)
  67540. */
  67541. noMipmap?: boolean | undefined,
  67542. /**
  67543. * Defines the explicit list of files (undefined by default)
  67544. */
  67545. files?: string[] | undefined);
  67546. /**
  67547. * Execute the current task
  67548. * @param scene defines the scene where you want your assets to be loaded
  67549. * @param onSuccess is a callback called when the task is successfully executed
  67550. * @param onError is a callback called if an error occurs
  67551. */
  67552. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67553. }
  67554. /**
  67555. * Define a task used by AssetsManager to load HDR cube textures
  67556. */
  67557. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67558. /**
  67559. * Defines the name of the task
  67560. */
  67561. name: string;
  67562. /**
  67563. * Defines the location of the file to load
  67564. */
  67565. url: string;
  67566. /**
  67567. * Defines the desired size (the more it increases the longer the generation will be)
  67568. */
  67569. size: number;
  67570. /**
  67571. * Defines if mipmaps should not be generated (default is false)
  67572. */
  67573. noMipmap: boolean;
  67574. /**
  67575. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67576. */
  67577. generateHarmonics: boolean;
  67578. /**
  67579. * 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)
  67580. */
  67581. gammaSpace: boolean;
  67582. /**
  67583. * Internal Use Only
  67584. */
  67585. reserved: boolean;
  67586. /**
  67587. * Gets the loaded texture
  67588. */
  67589. texture: HDRCubeTexture;
  67590. /**
  67591. * Callback called when the task is successful
  67592. */
  67593. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67594. /**
  67595. * Callback called when the task is successful
  67596. */
  67597. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67598. /**
  67599. * Creates a new HDRCubeTextureAssetTask object
  67600. * @param name defines the name of the task
  67601. * @param url defines the location of the file to load
  67602. * @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.
  67603. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67604. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67605. * @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)
  67606. * @param reserved Internal use only
  67607. */
  67608. constructor(
  67609. /**
  67610. * Defines the name of the task
  67611. */
  67612. name: string,
  67613. /**
  67614. * Defines the location of the file to load
  67615. */
  67616. url: string,
  67617. /**
  67618. * Defines the desired size (the more it increases the longer the generation will be)
  67619. */
  67620. size: number,
  67621. /**
  67622. * Defines if mipmaps should not be generated (default is false)
  67623. */
  67624. noMipmap?: boolean,
  67625. /**
  67626. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67627. */
  67628. generateHarmonics?: boolean,
  67629. /**
  67630. * 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)
  67631. */
  67632. gammaSpace?: boolean,
  67633. /**
  67634. * Internal Use Only
  67635. */
  67636. reserved?: boolean);
  67637. /**
  67638. * Execute the current task
  67639. * @param scene defines the scene where you want your assets to be loaded
  67640. * @param onSuccess is a callback called when the task is successfully executed
  67641. * @param onError is a callback called if an error occurs
  67642. */
  67643. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67644. }
  67645. /**
  67646. * Define a task used by AssetsManager to load Equirectangular cube textures
  67647. */
  67648. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67649. /**
  67650. * Defines the name of the task
  67651. */
  67652. name: string;
  67653. /**
  67654. * Defines the location of the file to load
  67655. */
  67656. url: string;
  67657. /**
  67658. * Defines the desired size (the more it increases the longer the generation will be)
  67659. */
  67660. size: number;
  67661. /**
  67662. * Defines if mipmaps should not be generated (default is false)
  67663. */
  67664. noMipmap: boolean;
  67665. /**
  67666. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67667. * but the standard material would require them in Gamma space) (default is true)
  67668. */
  67669. gammaSpace: boolean;
  67670. /**
  67671. * Gets the loaded texture
  67672. */
  67673. texture: EquiRectangularCubeTexture;
  67674. /**
  67675. * Callback called when the task is successful
  67676. */
  67677. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67678. /**
  67679. * Callback called when the task is successful
  67680. */
  67681. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67682. /**
  67683. * Creates a new EquiRectangularCubeTextureAssetTask object
  67684. * @param name defines the name of the task
  67685. * @param url defines the location of the file to load
  67686. * @param size defines the desired size (the more it increases the longer the generation will be)
  67687. * If the size is omitted this implies you are using a preprocessed cubemap.
  67688. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67689. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67690. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67691. * (default is true)
  67692. */
  67693. constructor(
  67694. /**
  67695. * Defines the name of the task
  67696. */
  67697. name: string,
  67698. /**
  67699. * Defines the location of the file to load
  67700. */
  67701. url: string,
  67702. /**
  67703. * Defines the desired size (the more it increases the longer the generation will be)
  67704. */
  67705. size: number,
  67706. /**
  67707. * Defines if mipmaps should not be generated (default is false)
  67708. */
  67709. noMipmap?: boolean,
  67710. /**
  67711. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67712. * but the standard material would require them in Gamma space) (default is true)
  67713. */
  67714. gammaSpace?: boolean);
  67715. /**
  67716. * Execute the current task
  67717. * @param scene defines the scene where you want your assets to be loaded
  67718. * @param onSuccess is a callback called when the task is successfully executed
  67719. * @param onError is a callback called if an error occurs
  67720. */
  67721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67722. }
  67723. /**
  67724. * This class can be used to easily import assets into a scene
  67725. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67726. */
  67727. export class AssetsManager {
  67728. private _scene;
  67729. private _isLoading;
  67730. protected _tasks: AbstractAssetTask[];
  67731. protected _waitingTasksCount: number;
  67732. protected _totalTasksCount: number;
  67733. /**
  67734. * Callback called when all tasks are processed
  67735. */
  67736. onFinish: (tasks: AbstractAssetTask[]) => void;
  67737. /**
  67738. * Callback called when a task is successful
  67739. */
  67740. onTaskSuccess: (task: AbstractAssetTask) => void;
  67741. /**
  67742. * Callback called when a task had an error
  67743. */
  67744. onTaskError: (task: AbstractAssetTask) => void;
  67745. /**
  67746. * Callback called when a task is done (whatever the result is)
  67747. */
  67748. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67749. /**
  67750. * Observable called when all tasks are processed
  67751. */
  67752. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67753. /**
  67754. * Observable called when a task had an error
  67755. */
  67756. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67757. /**
  67758. * Observable called when all tasks were executed
  67759. */
  67760. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67761. /**
  67762. * Observable called when a task is done (whatever the result is)
  67763. */
  67764. onProgressObservable: Observable<IAssetsProgressEvent>;
  67765. /**
  67766. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67767. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67768. */
  67769. useDefaultLoadingScreen: boolean;
  67770. /**
  67771. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67772. * when all assets have been downloaded.
  67773. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67774. */
  67775. autoHideLoadingUI: boolean;
  67776. /**
  67777. * Creates a new AssetsManager
  67778. * @param scene defines the scene to work on
  67779. */
  67780. constructor(scene: Scene);
  67781. /**
  67782. * Add a MeshAssetTask to the list of active tasks
  67783. * @param taskName defines the name of the new task
  67784. * @param meshesNames defines the name of meshes to load
  67785. * @param rootUrl defines the root url to use to locate files
  67786. * @param sceneFilename defines the filename of the scene file
  67787. * @returns a new MeshAssetTask object
  67788. */
  67789. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67790. /**
  67791. * Add a TextFileAssetTask to the list of active tasks
  67792. * @param taskName defines the name of the new task
  67793. * @param url defines the url of the file to load
  67794. * @returns a new TextFileAssetTask object
  67795. */
  67796. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67797. /**
  67798. * Add a BinaryFileAssetTask to the list of active tasks
  67799. * @param taskName defines the name of the new task
  67800. * @param url defines the url of the file to load
  67801. * @returns a new BinaryFileAssetTask object
  67802. */
  67803. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67804. /**
  67805. * Add a ImageAssetTask to the list of active tasks
  67806. * @param taskName defines the name of the new task
  67807. * @param url defines the url of the file to load
  67808. * @returns a new ImageAssetTask object
  67809. */
  67810. addImageTask(taskName: string, url: string): ImageAssetTask;
  67811. /**
  67812. * Add a TextureAssetTask to the list of active tasks
  67813. * @param taskName defines the name of the new task
  67814. * @param url defines the url of the file to load
  67815. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67816. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67817. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67818. * @returns a new TextureAssetTask object
  67819. */
  67820. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67821. /**
  67822. * Add a CubeTextureAssetTask to the list of active tasks
  67823. * @param taskName defines the name of the new task
  67824. * @param url defines the url of the file to load
  67825. * @param extensions defines the extension to use to load the cube map (can be null)
  67826. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67827. * @param files defines the list of files to load (can be null)
  67828. * @returns a new CubeTextureAssetTask object
  67829. */
  67830. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67831. /**
  67832. *
  67833. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67834. * @param taskName defines the name of the new task
  67835. * @param url defines the url of the file to load
  67836. * @param size defines the size you want for the cubemap (can be null)
  67837. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67838. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67839. * @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)
  67840. * @param reserved Internal use only
  67841. * @returns a new HDRCubeTextureAssetTask object
  67842. */
  67843. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67844. /**
  67845. *
  67846. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67847. * @param taskName defines the name of the new task
  67848. * @param url defines the url of the file to load
  67849. * @param size defines the size you want for the cubemap (can be null)
  67850. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67851. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67852. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67853. * @returns a new EquiRectangularCubeTextureAssetTask object
  67854. */
  67855. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67856. /**
  67857. * Remove a task from the assets manager.
  67858. * @param task the task to remove
  67859. */
  67860. removeTask(task: AbstractAssetTask): void;
  67861. private _decreaseWaitingTasksCount;
  67862. private _runTask;
  67863. /**
  67864. * Reset the AssetsManager and remove all tasks
  67865. * @return the current instance of the AssetsManager
  67866. */
  67867. reset(): AssetsManager;
  67868. /**
  67869. * Start the loading process
  67870. * @return the current instance of the AssetsManager
  67871. */
  67872. load(): AssetsManager;
  67873. /**
  67874. * Start the loading process as an async operation
  67875. * @return a promise returning the list of failed tasks
  67876. */
  67877. loadAsync(): Promise<void>;
  67878. }
  67879. }
  67880. declare module BABYLON {
  67881. /**
  67882. * Wrapper class for promise with external resolve and reject.
  67883. */
  67884. export class Deferred<T> {
  67885. /**
  67886. * The promise associated with this deferred object.
  67887. */
  67888. readonly promise: Promise<T>;
  67889. private _resolve;
  67890. private _reject;
  67891. /**
  67892. * The resolve method of the promise associated with this deferred object.
  67893. */
  67894. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67895. /**
  67896. * The reject method of the promise associated with this deferred object.
  67897. */
  67898. get reject(): (reason?: any) => void;
  67899. /**
  67900. * Constructor for this deferred object.
  67901. */
  67902. constructor();
  67903. }
  67904. }
  67905. declare module BABYLON {
  67906. /**
  67907. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67908. */
  67909. export class MeshExploder {
  67910. private _centerMesh;
  67911. private _meshes;
  67912. private _meshesOrigins;
  67913. private _toCenterVectors;
  67914. private _scaledDirection;
  67915. private _newPosition;
  67916. private _centerPosition;
  67917. /**
  67918. * Explodes meshes from a center mesh.
  67919. * @param meshes The meshes to explode.
  67920. * @param centerMesh The mesh to be center of explosion.
  67921. */
  67922. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67923. private _setCenterMesh;
  67924. /**
  67925. * Get class name
  67926. * @returns "MeshExploder"
  67927. */
  67928. getClassName(): string;
  67929. /**
  67930. * "Exploded meshes"
  67931. * @returns Array of meshes with the centerMesh at index 0.
  67932. */
  67933. getMeshes(): Array<Mesh>;
  67934. /**
  67935. * Explodes meshes giving a specific direction
  67936. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67937. */
  67938. explode(direction?: number): void;
  67939. }
  67940. }
  67941. declare module BABYLON {
  67942. /**
  67943. * Class used to help managing file picking and drag'n'drop
  67944. */
  67945. export class FilesInput {
  67946. /**
  67947. * List of files ready to be loaded
  67948. */
  67949. static get FilesToLoad(): {
  67950. [key: string]: File;
  67951. };
  67952. /**
  67953. * Callback called when a file is processed
  67954. */
  67955. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67956. private _engine;
  67957. private _currentScene;
  67958. private _sceneLoadedCallback;
  67959. private _progressCallback;
  67960. private _additionalRenderLoopLogicCallback;
  67961. private _textureLoadingCallback;
  67962. private _startingProcessingFilesCallback;
  67963. private _onReloadCallback;
  67964. private _errorCallback;
  67965. private _elementToMonitor;
  67966. private _sceneFileToLoad;
  67967. private _filesToLoad;
  67968. /**
  67969. * Creates a new FilesInput
  67970. * @param engine defines the rendering engine
  67971. * @param scene defines the hosting scene
  67972. * @param sceneLoadedCallback callback called when scene is loaded
  67973. * @param progressCallback callback called to track progress
  67974. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67975. * @param textureLoadingCallback callback called when a texture is loading
  67976. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67977. * @param onReloadCallback callback called when a reload is requested
  67978. * @param errorCallback callback call if an error occurs
  67979. */
  67980. 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);
  67981. private _dragEnterHandler;
  67982. private _dragOverHandler;
  67983. private _dropHandler;
  67984. /**
  67985. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67986. * @param elementToMonitor defines the DOM element to track
  67987. */
  67988. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67989. /**
  67990. * Release all associated resources
  67991. */
  67992. dispose(): void;
  67993. private renderFunction;
  67994. private drag;
  67995. private drop;
  67996. private _traverseFolder;
  67997. private _processFiles;
  67998. /**
  67999. * Load files from a drop event
  68000. * @param event defines the drop event to use as source
  68001. */
  68002. loadFiles(event: any): void;
  68003. private _processReload;
  68004. /**
  68005. * Reload the current scene from the loaded files
  68006. */
  68007. reload(): void;
  68008. }
  68009. }
  68010. declare module BABYLON {
  68011. /**
  68012. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68014. */
  68015. export class SceneOptimization {
  68016. /**
  68017. * Defines the priority of this optimization (0 by default which means first in the list)
  68018. */
  68019. priority: number;
  68020. /**
  68021. * Gets a string describing the action executed by the current optimization
  68022. * @returns description string
  68023. */
  68024. getDescription(): string;
  68025. /**
  68026. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68027. * @param scene defines the current scene where to apply this optimization
  68028. * @param optimizer defines the current optimizer
  68029. * @returns true if everything that can be done was applied
  68030. */
  68031. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68032. /**
  68033. * Creates the SceneOptimization object
  68034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68035. * @param desc defines the description associated with the optimization
  68036. */
  68037. constructor(
  68038. /**
  68039. * Defines the priority of this optimization (0 by default which means first in the list)
  68040. */
  68041. priority?: number);
  68042. }
  68043. /**
  68044. * Defines an optimization used to reduce the size of render target textures
  68045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68046. */
  68047. export class TextureOptimization extends SceneOptimization {
  68048. /**
  68049. * Defines the priority of this optimization (0 by default which means first in the list)
  68050. */
  68051. priority: number;
  68052. /**
  68053. * 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
  68054. */
  68055. maximumSize: number;
  68056. /**
  68057. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68058. */
  68059. step: number;
  68060. /**
  68061. * Gets a string describing the action executed by the current optimization
  68062. * @returns description string
  68063. */
  68064. getDescription(): string;
  68065. /**
  68066. * Creates the TextureOptimization object
  68067. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68068. * @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
  68069. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68070. */
  68071. constructor(
  68072. /**
  68073. * Defines the priority of this optimization (0 by default which means first in the list)
  68074. */
  68075. priority?: number,
  68076. /**
  68077. * 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
  68078. */
  68079. maximumSize?: number,
  68080. /**
  68081. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68082. */
  68083. step?: number);
  68084. /**
  68085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68086. * @param scene defines the current scene where to apply this optimization
  68087. * @param optimizer defines the current optimizer
  68088. * @returns true if everything that can be done was applied
  68089. */
  68090. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68091. }
  68092. /**
  68093. * Defines an optimization used to increase or decrease the rendering resolution
  68094. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68095. */
  68096. export class HardwareScalingOptimization extends SceneOptimization {
  68097. /**
  68098. * Defines the priority of this optimization (0 by default which means first in the list)
  68099. */
  68100. priority: number;
  68101. /**
  68102. * Defines the maximum scale to use (2 by default)
  68103. */
  68104. maximumScale: number;
  68105. /**
  68106. * Defines the step to use between two passes (0.5 by default)
  68107. */
  68108. step: number;
  68109. private _currentScale;
  68110. private _directionOffset;
  68111. /**
  68112. * Gets a string describing the action executed by the current optimization
  68113. * @return description string
  68114. */
  68115. getDescription(): string;
  68116. /**
  68117. * Creates the HardwareScalingOptimization object
  68118. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68119. * @param maximumScale defines the maximum scale to use (2 by default)
  68120. * @param step defines the step to use between two passes (0.5 by default)
  68121. */
  68122. constructor(
  68123. /**
  68124. * Defines the priority of this optimization (0 by default which means first in the list)
  68125. */
  68126. priority?: number,
  68127. /**
  68128. * Defines the maximum scale to use (2 by default)
  68129. */
  68130. maximumScale?: number,
  68131. /**
  68132. * Defines the step to use between two passes (0.5 by default)
  68133. */
  68134. step?: number);
  68135. /**
  68136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68137. * @param scene defines the current scene where to apply this optimization
  68138. * @param optimizer defines the current optimizer
  68139. * @returns true if everything that can be done was applied
  68140. */
  68141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68142. }
  68143. /**
  68144. * Defines an optimization used to remove shadows
  68145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68146. */
  68147. export class ShadowsOptimization extends SceneOptimization {
  68148. /**
  68149. * Gets a string describing the action executed by the current optimization
  68150. * @return description string
  68151. */
  68152. getDescription(): string;
  68153. /**
  68154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68155. * @param scene defines the current scene where to apply this optimization
  68156. * @param optimizer defines the current optimizer
  68157. * @returns true if everything that can be done was applied
  68158. */
  68159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68160. }
  68161. /**
  68162. * Defines an optimization used to turn post-processes off
  68163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68164. */
  68165. export class PostProcessesOptimization extends SceneOptimization {
  68166. /**
  68167. * Gets a string describing the action executed by the current optimization
  68168. * @return description string
  68169. */
  68170. getDescription(): string;
  68171. /**
  68172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68173. * @param scene defines the current scene where to apply this optimization
  68174. * @param optimizer defines the current optimizer
  68175. * @returns true if everything that can be done was applied
  68176. */
  68177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68178. }
  68179. /**
  68180. * Defines an optimization used to turn lens flares off
  68181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68182. */
  68183. export class LensFlaresOptimization extends SceneOptimization {
  68184. /**
  68185. * Gets a string describing the action executed by the current optimization
  68186. * @return description string
  68187. */
  68188. getDescription(): string;
  68189. /**
  68190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68191. * @param scene defines the current scene where to apply this optimization
  68192. * @param optimizer defines the current optimizer
  68193. * @returns true if everything that can be done was applied
  68194. */
  68195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68196. }
  68197. /**
  68198. * Defines an optimization based on user defined callback.
  68199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68200. */
  68201. export class CustomOptimization extends SceneOptimization {
  68202. /**
  68203. * Callback called to apply the custom optimization.
  68204. */
  68205. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68206. /**
  68207. * Callback called to get custom description
  68208. */
  68209. onGetDescription: () => string;
  68210. /**
  68211. * Gets a string describing the action executed by the current optimization
  68212. * @returns description string
  68213. */
  68214. getDescription(): string;
  68215. /**
  68216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68217. * @param scene defines the current scene where to apply this optimization
  68218. * @param optimizer defines the current optimizer
  68219. * @returns true if everything that can be done was applied
  68220. */
  68221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68222. }
  68223. /**
  68224. * Defines an optimization used to turn particles off
  68225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68226. */
  68227. export class ParticlesOptimization extends SceneOptimization {
  68228. /**
  68229. * Gets a string describing the action executed by the current optimization
  68230. * @return description string
  68231. */
  68232. getDescription(): string;
  68233. /**
  68234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68235. * @param scene defines the current scene where to apply this optimization
  68236. * @param optimizer defines the current optimizer
  68237. * @returns true if everything that can be done was applied
  68238. */
  68239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68240. }
  68241. /**
  68242. * Defines an optimization used to turn render targets off
  68243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68244. */
  68245. export class RenderTargetsOptimization extends SceneOptimization {
  68246. /**
  68247. * Gets a string describing the action executed by the current optimization
  68248. * @return description string
  68249. */
  68250. getDescription(): string;
  68251. /**
  68252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68253. * @param scene defines the current scene where to apply this optimization
  68254. * @param optimizer defines the current optimizer
  68255. * @returns true if everything that can be done was applied
  68256. */
  68257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68258. }
  68259. /**
  68260. * Defines an optimization used to merge meshes with compatible materials
  68261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68262. */
  68263. export class MergeMeshesOptimization extends SceneOptimization {
  68264. private static _UpdateSelectionTree;
  68265. /**
  68266. * Gets or sets a boolean which defines if optimization octree has to be updated
  68267. */
  68268. static get UpdateSelectionTree(): boolean;
  68269. /**
  68270. * Gets or sets a boolean which defines if optimization octree has to be updated
  68271. */
  68272. static set UpdateSelectionTree(value: boolean);
  68273. /**
  68274. * Gets a string describing the action executed by the current optimization
  68275. * @return description string
  68276. */
  68277. getDescription(): string;
  68278. private _canBeMerged;
  68279. /**
  68280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68281. * @param scene defines the current scene where to apply this optimization
  68282. * @param optimizer defines the current optimizer
  68283. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68284. * @returns true if everything that can be done was applied
  68285. */
  68286. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68287. }
  68288. /**
  68289. * Defines a list of options used by SceneOptimizer
  68290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68291. */
  68292. export class SceneOptimizerOptions {
  68293. /**
  68294. * Defines the target frame rate to reach (60 by default)
  68295. */
  68296. targetFrameRate: number;
  68297. /**
  68298. * Defines the interval between two checkes (2000ms by default)
  68299. */
  68300. trackerDuration: number;
  68301. /**
  68302. * Gets the list of optimizations to apply
  68303. */
  68304. optimizations: SceneOptimization[];
  68305. /**
  68306. * Creates a new list of options used by SceneOptimizer
  68307. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68308. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68309. */
  68310. constructor(
  68311. /**
  68312. * Defines the target frame rate to reach (60 by default)
  68313. */
  68314. targetFrameRate?: number,
  68315. /**
  68316. * Defines the interval between two checkes (2000ms by default)
  68317. */
  68318. trackerDuration?: number);
  68319. /**
  68320. * Add a new optimization
  68321. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68322. * @returns the current SceneOptimizerOptions
  68323. */
  68324. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68325. /**
  68326. * Add a new custom optimization
  68327. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68328. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68329. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68330. * @returns the current SceneOptimizerOptions
  68331. */
  68332. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68333. /**
  68334. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68335. * @param targetFrameRate defines the target frame rate (60 by default)
  68336. * @returns a SceneOptimizerOptions object
  68337. */
  68338. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68339. /**
  68340. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68341. * @param targetFrameRate defines the target frame rate (60 by default)
  68342. * @returns a SceneOptimizerOptions object
  68343. */
  68344. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68345. /**
  68346. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68347. * @param targetFrameRate defines the target frame rate (60 by default)
  68348. * @returns a SceneOptimizerOptions object
  68349. */
  68350. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68351. }
  68352. /**
  68353. * Class used to run optimizations in order to reach a target frame rate
  68354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68355. */
  68356. export class SceneOptimizer implements IDisposable {
  68357. private _isRunning;
  68358. private _options;
  68359. private _scene;
  68360. private _currentPriorityLevel;
  68361. private _targetFrameRate;
  68362. private _trackerDuration;
  68363. private _currentFrameRate;
  68364. private _sceneDisposeObserver;
  68365. private _improvementMode;
  68366. /**
  68367. * Defines an observable called when the optimizer reaches the target frame rate
  68368. */
  68369. onSuccessObservable: Observable<SceneOptimizer>;
  68370. /**
  68371. * Defines an observable called when the optimizer enables an optimization
  68372. */
  68373. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68374. /**
  68375. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68376. */
  68377. onFailureObservable: Observable<SceneOptimizer>;
  68378. /**
  68379. * Gets a boolean indicating if the optimizer is in improvement mode
  68380. */
  68381. get isInImprovementMode(): boolean;
  68382. /**
  68383. * Gets the current priority level (0 at start)
  68384. */
  68385. get currentPriorityLevel(): number;
  68386. /**
  68387. * Gets the current frame rate checked by the SceneOptimizer
  68388. */
  68389. get currentFrameRate(): number;
  68390. /**
  68391. * Gets or sets the current target frame rate (60 by default)
  68392. */
  68393. get targetFrameRate(): number;
  68394. /**
  68395. * Gets or sets the current target frame rate (60 by default)
  68396. */
  68397. set targetFrameRate(value: number);
  68398. /**
  68399. * Gets or sets the current interval between two checks (every 2000ms by default)
  68400. */
  68401. get trackerDuration(): number;
  68402. /**
  68403. * Gets or sets the current interval between two checks (every 2000ms by default)
  68404. */
  68405. set trackerDuration(value: number);
  68406. /**
  68407. * Gets the list of active optimizations
  68408. */
  68409. get optimizations(): SceneOptimization[];
  68410. /**
  68411. * Creates a new SceneOptimizer
  68412. * @param scene defines the scene to work on
  68413. * @param options defines the options to use with the SceneOptimizer
  68414. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68415. * @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)
  68416. */
  68417. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68418. /**
  68419. * Stops the current optimizer
  68420. */
  68421. stop(): void;
  68422. /**
  68423. * Reset the optimizer to initial step (current priority level = 0)
  68424. */
  68425. reset(): void;
  68426. /**
  68427. * Start the optimizer. By default it will try to reach a specific framerate
  68428. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68429. */
  68430. start(): void;
  68431. private _checkCurrentState;
  68432. /**
  68433. * Release all resources
  68434. */
  68435. dispose(): void;
  68436. /**
  68437. * Helper function to create a SceneOptimizer with one single line of code
  68438. * @param scene defines the scene to work on
  68439. * @param options defines the options to use with the SceneOptimizer
  68440. * @param onSuccess defines a callback to call on success
  68441. * @param onFailure defines a callback to call on failure
  68442. * @returns the new SceneOptimizer object
  68443. */
  68444. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68445. }
  68446. }
  68447. declare module BABYLON {
  68448. /**
  68449. * Class used to serialize a scene into a string
  68450. */
  68451. export class SceneSerializer {
  68452. /**
  68453. * Clear cache used by a previous serialization
  68454. */
  68455. static ClearCache(): void;
  68456. /**
  68457. * Serialize a scene into a JSON compatible object
  68458. * @param scene defines the scene to serialize
  68459. * @returns a JSON compatible object
  68460. */
  68461. static Serialize(scene: Scene): any;
  68462. /**
  68463. * Serialize a mesh into a JSON compatible object
  68464. * @param toSerialize defines the mesh to serialize
  68465. * @param withParents defines if parents must be serialized as well
  68466. * @param withChildren defines if children must be serialized as well
  68467. * @returns a JSON compatible object
  68468. */
  68469. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68470. }
  68471. }
  68472. declare module BABYLON {
  68473. /**
  68474. * Class used to host texture specific utilities
  68475. */
  68476. export class TextureTools {
  68477. /**
  68478. * Uses the GPU to create a copy texture rescaled at a given size
  68479. * @param texture Texture to copy from
  68480. * @param width defines the desired width
  68481. * @param height defines the desired height
  68482. * @param useBilinearMode defines if bilinear mode has to be used
  68483. * @return the generated texture
  68484. */
  68485. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68486. }
  68487. }
  68488. declare module BABYLON {
  68489. /**
  68490. * This represents the different options available for the video capture.
  68491. */
  68492. export interface VideoRecorderOptions {
  68493. /** Defines the mime type of the video. */
  68494. mimeType: string;
  68495. /** Defines the FPS the video should be recorded at. */
  68496. fps: number;
  68497. /** Defines the chunk size for the recording data. */
  68498. recordChunckSize: number;
  68499. /** The audio tracks to attach to the recording. */
  68500. audioTracks?: MediaStreamTrack[];
  68501. }
  68502. /**
  68503. * This can help with recording videos from BabylonJS.
  68504. * This is based on the available WebRTC functionalities of the browser.
  68505. *
  68506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68507. */
  68508. export class VideoRecorder {
  68509. private static readonly _defaultOptions;
  68510. /**
  68511. * Returns whether or not the VideoRecorder is available in your browser.
  68512. * @param engine Defines the Babylon Engine.
  68513. * @returns true if supported otherwise false.
  68514. */
  68515. static IsSupported(engine: Engine): boolean;
  68516. private readonly _options;
  68517. private _canvas;
  68518. private _mediaRecorder;
  68519. private _recordedChunks;
  68520. private _fileName;
  68521. private _resolve;
  68522. private _reject;
  68523. /**
  68524. * True when a recording is already in progress.
  68525. */
  68526. get isRecording(): boolean;
  68527. /**
  68528. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68529. * @param engine Defines the BabylonJS Engine you wish to record.
  68530. * @param options Defines options that can be used to customize the capture.
  68531. */
  68532. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68533. /**
  68534. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68535. */
  68536. stopRecording(): void;
  68537. /**
  68538. * Starts recording the canvas for a max duration specified in parameters.
  68539. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68540. * If null no automatic download will start and you can rely on the promise to get the data back.
  68541. * @param maxDuration Defines the maximum recording time in seconds.
  68542. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68543. * @return A promise callback at the end of the recording with the video data in Blob.
  68544. */
  68545. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68546. /**
  68547. * Releases internal resources used during the recording.
  68548. */
  68549. dispose(): void;
  68550. private _handleDataAvailable;
  68551. private _handleError;
  68552. private _handleStop;
  68553. }
  68554. }
  68555. declare module BABYLON {
  68556. /**
  68557. * Class containing a set of static utilities functions for screenshots
  68558. */
  68559. export class ScreenshotTools {
  68560. /**
  68561. * Captures a screenshot of the current rendering
  68562. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68563. * @param engine defines the rendering engine
  68564. * @param camera defines the source camera
  68565. * @param size This parameter can be set to a single number or to an object with the
  68566. * following (optional) properties: precision, width, height. If a single number is passed,
  68567. * it will be used for both width and height. If an object is passed, the screenshot size
  68568. * will be derived from the parameters. The precision property is a multiplier allowing
  68569. * rendering at a higher or lower resolution
  68570. * @param successCallback defines the callback receives a single parameter which contains the
  68571. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68572. * src parameter of an <img> to display it
  68573. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68574. * Check your browser for supported MIME types
  68575. */
  68576. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68577. /**
  68578. * Captures a screenshot of the current rendering
  68579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68580. * @param engine defines the rendering engine
  68581. * @param camera defines the source camera
  68582. * @param size This parameter can be set to a single number or to an object with the
  68583. * following (optional) properties: precision, width, height. If a single number is passed,
  68584. * it will be used for both width and height. If an object is passed, the screenshot size
  68585. * will be derived from the parameters. The precision property is a multiplier allowing
  68586. * rendering at a higher or lower resolution
  68587. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68588. * Check your browser for supported MIME types
  68589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68590. * to the src parameter of an <img> to display it
  68591. */
  68592. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68593. /**
  68594. * Generates an image screenshot from the specified camera.
  68595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68596. * @param engine The engine to use for rendering
  68597. * @param camera The camera to use for rendering
  68598. * @param size This parameter can be set to a single number or to an object with the
  68599. * following (optional) properties: precision, width, height. If a single number is passed,
  68600. * it will be used for both width and height. If an object is passed, the screenshot size
  68601. * will be derived from the parameters. The precision property is a multiplier allowing
  68602. * rendering at a higher or lower resolution
  68603. * @param successCallback The callback receives a single parameter which contains the
  68604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68605. * src parameter of an <img> to display it
  68606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68607. * Check your browser for supported MIME types
  68608. * @param samples Texture samples (default: 1)
  68609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68610. * @param fileName A name for for the downloaded file.
  68611. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68612. */
  68613. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68614. /**
  68615. * Generates an image screenshot from the specified camera.
  68616. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68617. * @param engine The engine to use for rendering
  68618. * @param camera The camera to use for rendering
  68619. * @param size This parameter can be set to a single number or to an object with the
  68620. * following (optional) properties: precision, width, height. If a single number is passed,
  68621. * it will be used for both width and height. If an object is passed, the screenshot size
  68622. * will be derived from the parameters. The precision property is a multiplier allowing
  68623. * rendering at a higher or lower resolution
  68624. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68625. * Check your browser for supported MIME types
  68626. * @param samples Texture samples (default: 1)
  68627. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68628. * @param fileName A name for for the downloaded file.
  68629. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68630. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68631. * to the src parameter of an <img> to display it
  68632. */
  68633. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68634. /**
  68635. * Gets height and width for screenshot size
  68636. * @private
  68637. */
  68638. private static _getScreenshotSize;
  68639. }
  68640. }
  68641. declare module BABYLON {
  68642. /**
  68643. * Interface for a data buffer
  68644. */
  68645. export interface IDataBuffer {
  68646. /**
  68647. * Reads bytes from the data buffer.
  68648. * @param byteOffset The byte offset to read
  68649. * @param byteLength The byte length to read
  68650. * @returns A promise that resolves when the bytes are read
  68651. */
  68652. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68653. /**
  68654. * The byte length of the buffer.
  68655. */
  68656. readonly byteLength: number;
  68657. }
  68658. /**
  68659. * Utility class for reading from a data buffer
  68660. */
  68661. export class DataReader {
  68662. /**
  68663. * The data buffer associated with this data reader.
  68664. */
  68665. readonly buffer: IDataBuffer;
  68666. /**
  68667. * The current byte offset from the beginning of the data buffer.
  68668. */
  68669. byteOffset: number;
  68670. private _dataView;
  68671. private _dataByteOffset;
  68672. /**
  68673. * Constructor
  68674. * @param buffer The buffer to read
  68675. */
  68676. constructor(buffer: IDataBuffer);
  68677. /**
  68678. * Loads the given byte length.
  68679. * @param byteLength The byte length to load
  68680. * @returns A promise that resolves when the load is complete
  68681. */
  68682. loadAsync(byteLength: number): Promise<void>;
  68683. /**
  68684. * Read a unsigned 32-bit integer from the currently loaded data range.
  68685. * @returns The 32-bit integer read
  68686. */
  68687. readUint32(): number;
  68688. /**
  68689. * Read a byte array from the currently loaded data range.
  68690. * @param byteLength The byte length to read
  68691. * @returns The byte array read
  68692. */
  68693. readUint8Array(byteLength: number): Uint8Array;
  68694. /**
  68695. * Read a string from the currently loaded data range.
  68696. * @param byteLength The byte length to read
  68697. * @returns The string read
  68698. */
  68699. readString(byteLength: number): string;
  68700. /**
  68701. * Skips the given byte length the currently loaded data range.
  68702. * @param byteLength The byte length to skip
  68703. */
  68704. skipBytes(byteLength: number): void;
  68705. }
  68706. }
  68707. declare module BABYLON {
  68708. /**
  68709. * Class for storing data to local storage if available or in-memory storage otherwise
  68710. */
  68711. export class DataStorage {
  68712. private static _Storage;
  68713. private static _GetStorage;
  68714. /**
  68715. * Reads a string from the data storage
  68716. * @param key The key to read
  68717. * @param defaultValue The value if the key doesn't exist
  68718. * @returns The string value
  68719. */
  68720. static ReadString(key: string, defaultValue: string): string;
  68721. /**
  68722. * Writes a string to the data storage
  68723. * @param key The key to write
  68724. * @param value The value to write
  68725. */
  68726. static WriteString(key: string, value: string): void;
  68727. /**
  68728. * Reads a boolean from the data storage
  68729. * @param key The key to read
  68730. * @param defaultValue The value if the key doesn't exist
  68731. * @returns The boolean value
  68732. */
  68733. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  68734. /**
  68735. * Writes a boolean to the data storage
  68736. * @param key The key to write
  68737. * @param value The value to write
  68738. */
  68739. static WriteBoolean(key: string, value: boolean): void;
  68740. /**
  68741. * Reads a number from the data storage
  68742. * @param key The key to read
  68743. * @param defaultValue The value if the key doesn't exist
  68744. * @returns The number value
  68745. */
  68746. static ReadNumber(key: string, defaultValue: number): number;
  68747. /**
  68748. * Writes a number to the data storage
  68749. * @param key The key to write
  68750. * @param value The value to write
  68751. */
  68752. static WriteNumber(key: string, value: number): void;
  68753. }
  68754. }
  68755. declare module BABYLON {
  68756. /**
  68757. * Options used for hit testing
  68758. */
  68759. export interface IWebXRHitTestOptions {
  68760. /**
  68761. * Only test when user interacted with the scene. Default - hit test every frame
  68762. */
  68763. testOnPointerDownOnly?: boolean;
  68764. /**
  68765. * The node to use to transform the local results to world coordinates
  68766. */
  68767. worldParentNode?: TransformNode;
  68768. }
  68769. /**
  68770. * Interface defining the babylon result of raycasting/hit-test
  68771. */
  68772. export interface IWebXRHitResult {
  68773. /**
  68774. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68775. */
  68776. transformationMatrix: Matrix;
  68777. /**
  68778. * The native hit test result
  68779. */
  68780. xrHitResult: XRHitResult;
  68781. }
  68782. /**
  68783. * The currently-working hit-test module.
  68784. * Hit test (or Ray-casting) is used to interact with the real world.
  68785. * For further information read here - https://github.com/immersive-web/hit-test
  68786. */
  68787. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68788. /**
  68789. * options to use when constructing this feature
  68790. */
  68791. readonly options: IWebXRHitTestOptions;
  68792. private _direction;
  68793. private _mat;
  68794. private _onSelectEnabled;
  68795. private _origin;
  68796. /**
  68797. * The module's name
  68798. */
  68799. static readonly Name: string;
  68800. /**
  68801. * The (Babylon) version of this module.
  68802. * This is an integer representing the implementation version.
  68803. * This number does not correspond to the WebXR specs version
  68804. */
  68805. static readonly Version: number;
  68806. /**
  68807. * Populated with the last native XR Hit Results
  68808. */
  68809. lastNativeXRHitResults: XRHitResult[];
  68810. /**
  68811. * Triggered when new babylon (transformed) hit test results are available
  68812. */
  68813. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68814. /**
  68815. * Creates a new instance of the (legacy version) hit test feature
  68816. * @param _xrSessionManager an instance of WebXRSessionManager
  68817. * @param options options to use when constructing this feature
  68818. */
  68819. constructor(_xrSessionManager: WebXRSessionManager,
  68820. /**
  68821. * options to use when constructing this feature
  68822. */
  68823. options?: IWebXRHitTestOptions);
  68824. /**
  68825. * execute a hit test with an XR Ray
  68826. *
  68827. * @param xrSession a native xrSession that will execute this hit test
  68828. * @param xrRay the ray (position and direction) to use for ray-casting
  68829. * @param referenceSpace native XR reference space to use for the hit-test
  68830. * @param filter filter function that will filter the results
  68831. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68832. */
  68833. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68834. /**
  68835. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68836. * @param event the (select) event to use to select with
  68837. * @param referenceSpace the reference space to use for this hit test
  68838. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68839. */
  68840. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68841. /**
  68842. * attach this feature
  68843. * Will usually be called by the features manager
  68844. *
  68845. * @returns true if successful.
  68846. */
  68847. attach(): boolean;
  68848. /**
  68849. * detach this feature.
  68850. * Will usually be called by the features manager
  68851. *
  68852. * @returns true if successful.
  68853. */
  68854. detach(): boolean;
  68855. /**
  68856. * Dispose this feature and all of the resources attached
  68857. */
  68858. dispose(): void;
  68859. protected _onXRFrame(frame: XRFrame): void;
  68860. private _onHitTestResults;
  68861. private _onSelect;
  68862. }
  68863. }
  68864. declare module BABYLON {
  68865. /**
  68866. * Options used in the plane detector module
  68867. */
  68868. export interface IWebXRPlaneDetectorOptions {
  68869. /**
  68870. * The node to use to transform the local results to world coordinates
  68871. */
  68872. worldParentNode?: TransformNode;
  68873. }
  68874. /**
  68875. * A babylon interface for a WebXR plane.
  68876. * A Plane is actually a polygon, built from N points in space
  68877. *
  68878. * Supported in chrome 79, not supported in canary 81 ATM
  68879. */
  68880. export interface IWebXRPlane {
  68881. /**
  68882. * a babylon-assigned ID for this polygon
  68883. */
  68884. id: number;
  68885. /**
  68886. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68887. */
  68888. polygonDefinition: Array<Vector3>;
  68889. /**
  68890. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68891. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68892. */
  68893. transformationMatrix: Matrix;
  68894. /**
  68895. * the native xr-plane object
  68896. */
  68897. xrPlane: XRPlane;
  68898. }
  68899. /**
  68900. * The plane detector is used to detect planes in the real world when in AR
  68901. * For more information see https://github.com/immersive-web/real-world-geometry/
  68902. */
  68903. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68904. private _options;
  68905. private _detectedPlanes;
  68906. private _enabled;
  68907. private _lastFrameDetected;
  68908. /**
  68909. * The module's name
  68910. */
  68911. static readonly Name: string;
  68912. /**
  68913. * The (Babylon) version of this module.
  68914. * This is an integer representing the implementation version.
  68915. * This number does not correspond to the WebXR specs version
  68916. */
  68917. static readonly Version: number;
  68918. /**
  68919. * Observers registered here will be executed when a new plane was added to the session
  68920. */
  68921. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68922. /**
  68923. * Observers registered here will be executed when a plane is no longer detected in the session
  68924. */
  68925. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68926. /**
  68927. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68928. * This can execute N times every frame
  68929. */
  68930. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68931. /**
  68932. * construct a new Plane Detector
  68933. * @param _xrSessionManager an instance of xr Session manager
  68934. * @param _options configuration to use when constructing this feature
  68935. */
  68936. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68937. /**
  68938. * Dispose this feature and all of the resources attached
  68939. */
  68940. dispose(): void;
  68941. protected _onXRFrame(frame: XRFrame): void;
  68942. private _init;
  68943. private _updatePlaneWithXRPlane;
  68944. /**
  68945. * avoiding using Array.find for global support.
  68946. * @param xrPlane the plane to find in the array
  68947. */
  68948. private findIndexInPlaneArray;
  68949. }
  68950. }
  68951. declare module BABYLON {
  68952. /**
  68953. * Configuration options of the anchor system
  68954. */
  68955. export interface IWebXRAnchorSystemOptions {
  68956. /**
  68957. * Should a new anchor be added every time a select event is triggered
  68958. */
  68959. addAnchorOnSelect?: boolean;
  68960. /**
  68961. * should the anchor system use plane detection.
  68962. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68963. */
  68964. usePlaneDetection?: boolean;
  68965. /**
  68966. * a node that will be used to convert local to world coordinates
  68967. */
  68968. worldParentNode?: TransformNode;
  68969. }
  68970. /**
  68971. * A babylon container for an XR Anchor
  68972. */
  68973. export interface IWebXRAnchor {
  68974. /**
  68975. * A babylon-assigned ID for this anchor
  68976. */
  68977. id: number;
  68978. /**
  68979. * Transformation matrix to apply to an object attached to this anchor
  68980. */
  68981. transformationMatrix: Matrix;
  68982. /**
  68983. * The native anchor object
  68984. */
  68985. xrAnchor: XRAnchor;
  68986. }
  68987. /**
  68988. * An implementation of the anchor system of WebXR.
  68989. * Note that the current documented implementation is not available in any browser. Future implementations
  68990. * will use the frame to create an anchor and not the session or a detected plane
  68991. * For further information see https://github.com/immersive-web/anchors/
  68992. */
  68993. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68994. private _options;
  68995. private _enabled;
  68996. private _hitTestModule;
  68997. private _lastFrameDetected;
  68998. private _onSelect;
  68999. private _planeDetector;
  69000. private _trackedAnchors;
  69001. /**
  69002. * The module's name
  69003. */
  69004. static readonly Name: string;
  69005. /**
  69006. * The (Babylon) version of this module.
  69007. * This is an integer representing the implementation version.
  69008. * This number does not correspond to the WebXR specs version
  69009. */
  69010. static readonly Version: number;
  69011. /**
  69012. * Observers registered here will be executed when a new anchor was added to the session
  69013. */
  69014. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69015. /**
  69016. * Observers registered here will be executed when an anchor was removed from the session
  69017. */
  69018. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69019. /**
  69020. * Observers registered here will be executed when an existing anchor updates
  69021. * This can execute N times every frame
  69022. */
  69023. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69024. /**
  69025. * constructs a new anchor system
  69026. * @param _xrSessionManager an instance of WebXRSessionManager
  69027. * @param _options configuration object for this feature
  69028. */
  69029. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69030. /**
  69031. * Add anchor at a specific XR point.
  69032. *
  69033. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69034. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69035. * @returns a promise the fulfills when the anchor was created
  69036. */
  69037. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69038. /**
  69039. * attach this feature
  69040. * Will usually be called by the features manager
  69041. *
  69042. * @returns true if successful.
  69043. */
  69044. attach(): boolean;
  69045. /**
  69046. * detach this feature.
  69047. * Will usually be called by the features manager
  69048. *
  69049. * @returns true if successful.
  69050. */
  69051. detach(): boolean;
  69052. /**
  69053. * Dispose this feature and all of the resources attached
  69054. */
  69055. dispose(): void;
  69056. /**
  69057. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69058. * @param hitTestModule the hit-test module to use.
  69059. */
  69060. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69061. /**
  69062. * set the plane detector to use in order to create anchors from frames
  69063. * @param planeDetector the plane-detector module to use
  69064. * @param enable enable plane-anchors. default is true
  69065. */
  69066. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69067. protected _onXRFrame(frame: XRFrame): void;
  69068. /**
  69069. * avoiding using Array.find for global support.
  69070. * @param xrAnchor the plane to find in the array
  69071. */
  69072. private _findIndexInAnchorArray;
  69073. private _updateAnchorWithXRFrame;
  69074. }
  69075. }
  69076. declare module BABYLON {
  69077. /**
  69078. * Options interface for the background remover plugin
  69079. */
  69080. export interface IWebXRBackgroundRemoverOptions {
  69081. /**
  69082. * Further background meshes to disable when entering AR
  69083. */
  69084. backgroundMeshes?: AbstractMesh[];
  69085. /**
  69086. * flags to configure the removal of the environment helper.
  69087. * If not set, the entire background will be removed. If set, flags should be set as well.
  69088. */
  69089. environmentHelperRemovalFlags?: {
  69090. /**
  69091. * Should the skybox be removed (default false)
  69092. */
  69093. skyBox?: boolean;
  69094. /**
  69095. * Should the ground be removed (default false)
  69096. */
  69097. ground?: boolean;
  69098. };
  69099. /**
  69100. * don't disable the environment helper
  69101. */
  69102. ignoreEnvironmentHelper?: boolean;
  69103. }
  69104. /**
  69105. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69106. */
  69107. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69108. /**
  69109. * read-only options to be used in this module
  69110. */
  69111. readonly options: IWebXRBackgroundRemoverOptions;
  69112. /**
  69113. * The module's name
  69114. */
  69115. static readonly Name: string;
  69116. /**
  69117. * The (Babylon) version of this module.
  69118. * This is an integer representing the implementation version.
  69119. * This number does not correspond to the WebXR specs version
  69120. */
  69121. static readonly Version: number;
  69122. /**
  69123. * registered observers will be triggered when the background state changes
  69124. */
  69125. onBackgroundStateChangedObservable: Observable<boolean>;
  69126. /**
  69127. * constructs a new background remover module
  69128. * @param _xrSessionManager the session manager for this module
  69129. * @param options read-only options to be used in this module
  69130. */
  69131. constructor(_xrSessionManager: WebXRSessionManager,
  69132. /**
  69133. * read-only options to be used in this module
  69134. */
  69135. options?: IWebXRBackgroundRemoverOptions);
  69136. /**
  69137. * attach this feature
  69138. * Will usually be called by the features manager
  69139. *
  69140. * @returns true if successful.
  69141. */
  69142. attach(): boolean;
  69143. /**
  69144. * detach this feature.
  69145. * Will usually be called by the features manager
  69146. *
  69147. * @returns true if successful.
  69148. */
  69149. detach(): boolean;
  69150. /**
  69151. * Dispose this feature and all of the resources attached
  69152. */
  69153. dispose(): void;
  69154. protected _onXRFrame(_xrFrame: XRFrame): void;
  69155. private _setBackgroundState;
  69156. }
  69157. }
  69158. declare module BABYLON {
  69159. /**
  69160. * Options for the controller physics feature
  69161. */
  69162. export class IWebXRControllerPhysicsOptions {
  69163. /**
  69164. * Should the headset get its own impostor
  69165. */
  69166. enableHeadsetImpostor?: boolean;
  69167. /**
  69168. * Optional parameters for the headset impostor
  69169. */
  69170. headsetImpostorParams?: {
  69171. /**
  69172. * The type of impostor to create. Default is sphere
  69173. */
  69174. impostorType: number;
  69175. /**
  69176. * the size of the impostor. Defaults to 10cm
  69177. */
  69178. impostorSize?: number | {
  69179. width: number;
  69180. height: number;
  69181. depth: number;
  69182. };
  69183. /**
  69184. * Friction definitions
  69185. */
  69186. friction?: number;
  69187. /**
  69188. * Restitution
  69189. */
  69190. restitution?: number;
  69191. };
  69192. /**
  69193. * The physics properties of the future impostors
  69194. */
  69195. physicsProperties?: {
  69196. /**
  69197. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69198. * Note that this requires a physics engine that supports mesh impostors!
  69199. */
  69200. useControllerMesh?: boolean;
  69201. /**
  69202. * The type of impostor to create. Default is sphere
  69203. */
  69204. impostorType?: number;
  69205. /**
  69206. * the size of the impostor. Defaults to 10cm
  69207. */
  69208. impostorSize?: number | {
  69209. width: number;
  69210. height: number;
  69211. depth: number;
  69212. };
  69213. /**
  69214. * Friction definitions
  69215. */
  69216. friction?: number;
  69217. /**
  69218. * Restitution
  69219. */
  69220. restitution?: number;
  69221. };
  69222. /**
  69223. * the xr input to use with this pointer selection
  69224. */
  69225. xrInput: WebXRInput;
  69226. }
  69227. /**
  69228. * Add physics impostor to your webxr controllers,
  69229. * including naive calculation of their linear and angular velocity
  69230. */
  69231. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69232. private readonly _options;
  69233. private _attachController;
  69234. private _controllers;
  69235. private _debugMode;
  69236. private _delta;
  69237. private _headsetImpostor?;
  69238. private _headsetMesh?;
  69239. private _lastTimestamp;
  69240. private _tmpQuaternion;
  69241. private _tmpVector;
  69242. /**
  69243. * The module's name
  69244. */
  69245. static readonly Name: string;
  69246. /**
  69247. * The (Babylon) version of this module.
  69248. * This is an integer representing the implementation version.
  69249. * This number does not correspond to the webxr specs version
  69250. */
  69251. static readonly Version: number;
  69252. /**
  69253. * Construct a new Controller Physics Feature
  69254. * @param _xrSessionManager the corresponding xr session manager
  69255. * @param _options options to create this feature with
  69256. */
  69257. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69258. /**
  69259. * @hidden
  69260. * enable debugging - will show console outputs and the impostor mesh
  69261. */
  69262. _enablePhysicsDebug(): void;
  69263. /**
  69264. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69265. * @param xrController the controller to add
  69266. */
  69267. addController(xrController: WebXRInputSource): void;
  69268. /**
  69269. * attach this feature
  69270. * Will usually be called by the features manager
  69271. *
  69272. * @returns true if successful.
  69273. */
  69274. attach(): boolean;
  69275. /**
  69276. * detach this feature.
  69277. * Will usually be called by the features manager
  69278. *
  69279. * @returns true if successful.
  69280. */
  69281. detach(): boolean;
  69282. /**
  69283. * Get the headset impostor, if enabled
  69284. * @returns the impostor
  69285. */
  69286. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69287. /**
  69288. * Get the physics impostor of a specific controller.
  69289. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69290. * @param controller the controller or the controller id of which to get the impostor
  69291. * @returns the impostor or null
  69292. */
  69293. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69294. /**
  69295. * Update the physics properties provided in the constructor
  69296. * @param newProperties the new properties object
  69297. */
  69298. setPhysicsProperties(newProperties: {
  69299. impostorType?: number;
  69300. impostorSize?: number | {
  69301. width: number;
  69302. height: number;
  69303. depth: number;
  69304. };
  69305. friction?: number;
  69306. restitution?: number;
  69307. }): void;
  69308. protected _onXRFrame(_xrFrame: any): void;
  69309. private _detachController;
  69310. }
  69311. }
  69312. declare module BABYLON {
  69313. /**
  69314. * The motion controller class for all microsoft mixed reality controllers
  69315. */
  69316. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69317. protected readonly _mapping: {
  69318. defaultButton: {
  69319. "valueNodeName": string;
  69320. "unpressedNodeName": string;
  69321. "pressedNodeName": string;
  69322. };
  69323. defaultAxis: {
  69324. "valueNodeName": string;
  69325. "minNodeName": string;
  69326. "maxNodeName": string;
  69327. };
  69328. buttons: {
  69329. "xr-standard-trigger": {
  69330. "rootNodeName": string;
  69331. "componentProperty": string;
  69332. "states": string[];
  69333. };
  69334. "xr-standard-squeeze": {
  69335. "rootNodeName": string;
  69336. "componentProperty": string;
  69337. "states": string[];
  69338. };
  69339. "xr-standard-touchpad": {
  69340. "rootNodeName": string;
  69341. "labelAnchorNodeName": string;
  69342. "touchPointNodeName": string;
  69343. };
  69344. "xr-standard-thumbstick": {
  69345. "rootNodeName": string;
  69346. "componentProperty": string;
  69347. "states": string[];
  69348. };
  69349. };
  69350. axes: {
  69351. "xr-standard-touchpad": {
  69352. "x-axis": {
  69353. "rootNodeName": string;
  69354. };
  69355. "y-axis": {
  69356. "rootNodeName": string;
  69357. };
  69358. };
  69359. "xr-standard-thumbstick": {
  69360. "x-axis": {
  69361. "rootNodeName": string;
  69362. };
  69363. "y-axis": {
  69364. "rootNodeName": string;
  69365. };
  69366. };
  69367. };
  69368. };
  69369. /**
  69370. * The base url used to load the left and right controller models
  69371. */
  69372. static MODEL_BASE_URL: string;
  69373. /**
  69374. * The name of the left controller model file
  69375. */
  69376. static MODEL_LEFT_FILENAME: string;
  69377. /**
  69378. * The name of the right controller model file
  69379. */
  69380. static MODEL_RIGHT_FILENAME: string;
  69381. profileId: string;
  69382. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69383. protected _getFilenameAndPath(): {
  69384. filename: string;
  69385. path: string;
  69386. };
  69387. protected _getModelLoadingConstraints(): boolean;
  69388. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69389. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69390. protected _updateModel(): void;
  69391. }
  69392. }
  69393. declare module BABYLON {
  69394. /**
  69395. * The motion controller class for oculus touch (quest, rift).
  69396. * This class supports legacy mapping as well the standard xr mapping
  69397. */
  69398. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69399. private _forceLegacyControllers;
  69400. private _modelRootNode;
  69401. /**
  69402. * The base url used to load the left and right controller models
  69403. */
  69404. static MODEL_BASE_URL: string;
  69405. /**
  69406. * The name of the left controller model file
  69407. */
  69408. static MODEL_LEFT_FILENAME: string;
  69409. /**
  69410. * The name of the right controller model file
  69411. */
  69412. static MODEL_RIGHT_FILENAME: string;
  69413. /**
  69414. * Base Url for the Quest controller model.
  69415. */
  69416. static QUEST_MODEL_BASE_URL: string;
  69417. profileId: string;
  69418. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69419. protected _getFilenameAndPath(): {
  69420. filename: string;
  69421. path: string;
  69422. };
  69423. protected _getModelLoadingConstraints(): boolean;
  69424. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69425. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69426. protected _updateModel(): void;
  69427. /**
  69428. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69429. * between the touch and touch 2.
  69430. */
  69431. private _isQuest;
  69432. }
  69433. }
  69434. declare module BABYLON {
  69435. /**
  69436. * The motion controller class for the standard HTC-Vive controllers
  69437. */
  69438. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69439. private _modelRootNode;
  69440. /**
  69441. * The base url used to load the left and right controller models
  69442. */
  69443. static MODEL_BASE_URL: string;
  69444. /**
  69445. * File name for the controller model.
  69446. */
  69447. static MODEL_FILENAME: string;
  69448. profileId: string;
  69449. /**
  69450. * Create a new Vive motion controller object
  69451. * @param scene the scene to use to create this controller
  69452. * @param gamepadObject the corresponding gamepad object
  69453. * @param handness the handness of the controller
  69454. */
  69455. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69456. protected _getFilenameAndPath(): {
  69457. filename: string;
  69458. path: string;
  69459. };
  69460. protected _getModelLoadingConstraints(): boolean;
  69461. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69462. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69463. protected _updateModel(): void;
  69464. }
  69465. }
  69466. declare module BABYLON {
  69467. /**
  69468. * A cursor which tracks a point on a path
  69469. */
  69470. export class PathCursor {
  69471. private path;
  69472. /**
  69473. * Stores path cursor callbacks for when an onchange event is triggered
  69474. */
  69475. private _onchange;
  69476. /**
  69477. * The value of the path cursor
  69478. */
  69479. value: number;
  69480. /**
  69481. * The animation array of the path cursor
  69482. */
  69483. animations: Animation[];
  69484. /**
  69485. * Initializes the path cursor
  69486. * @param path The path to track
  69487. */
  69488. constructor(path: Path2);
  69489. /**
  69490. * Gets the cursor point on the path
  69491. * @returns A point on the path cursor at the cursor location
  69492. */
  69493. getPoint(): Vector3;
  69494. /**
  69495. * Moves the cursor ahead by the step amount
  69496. * @param step The amount to move the cursor forward
  69497. * @returns This path cursor
  69498. */
  69499. moveAhead(step?: number): PathCursor;
  69500. /**
  69501. * Moves the cursor behind by the step amount
  69502. * @param step The amount to move the cursor back
  69503. * @returns This path cursor
  69504. */
  69505. moveBack(step?: number): PathCursor;
  69506. /**
  69507. * Moves the cursor by the step amount
  69508. * If the step amount is greater than one, an exception is thrown
  69509. * @param step The amount to move the cursor
  69510. * @returns This path cursor
  69511. */
  69512. move(step: number): PathCursor;
  69513. /**
  69514. * Ensures that the value is limited between zero and one
  69515. * @returns This path cursor
  69516. */
  69517. private ensureLimits;
  69518. /**
  69519. * Runs onchange callbacks on change (used by the animation engine)
  69520. * @returns This path cursor
  69521. */
  69522. private raiseOnChange;
  69523. /**
  69524. * Executes a function on change
  69525. * @param f A path cursor onchange callback
  69526. * @returns This path cursor
  69527. */
  69528. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69529. }
  69530. }
  69531. declare module BABYLON {
  69532. /** @hidden */
  69533. export var blurPixelShader: {
  69534. name: string;
  69535. shader: string;
  69536. };
  69537. }
  69538. declare module BABYLON {
  69539. /** @hidden */
  69540. export var pointCloudVertexDeclaration: {
  69541. name: string;
  69542. shader: string;
  69543. };
  69544. }
  69545. // Mixins
  69546. interface Window {
  69547. mozIndexedDB: IDBFactory;
  69548. webkitIndexedDB: IDBFactory;
  69549. msIndexedDB: IDBFactory;
  69550. webkitURL: typeof URL;
  69551. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69552. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69553. WebGLRenderingContext: WebGLRenderingContext;
  69554. MSGesture: MSGesture;
  69555. CANNON: any;
  69556. AudioContext: AudioContext;
  69557. webkitAudioContext: AudioContext;
  69558. PointerEvent: any;
  69559. Math: Math;
  69560. Uint8Array: Uint8ArrayConstructor;
  69561. Float32Array: Float32ArrayConstructor;
  69562. mozURL: typeof URL;
  69563. msURL: typeof URL;
  69564. VRFrameData: any; // WebVR, from specs 1.1
  69565. DracoDecoderModule: any;
  69566. setImmediate(handler: (...args: any[]) => void): number;
  69567. }
  69568. interface HTMLCanvasElement {
  69569. requestPointerLock(): void;
  69570. msRequestPointerLock?(): void;
  69571. mozRequestPointerLock?(): void;
  69572. webkitRequestPointerLock?(): void;
  69573. /** Track wether a record is in progress */
  69574. isRecording: boolean;
  69575. /** Capture Stream method defined by some browsers */
  69576. captureStream(fps?: number): MediaStream;
  69577. }
  69578. interface CanvasRenderingContext2D {
  69579. msImageSmoothingEnabled: boolean;
  69580. }
  69581. interface MouseEvent {
  69582. mozMovementX: number;
  69583. mozMovementY: number;
  69584. webkitMovementX: number;
  69585. webkitMovementY: number;
  69586. msMovementX: number;
  69587. msMovementY: number;
  69588. }
  69589. interface Navigator {
  69590. mozGetVRDevices: (any: any) => any;
  69591. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69592. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69593. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69594. webkitGetGamepads(): Gamepad[];
  69595. msGetGamepads(): Gamepad[];
  69596. webkitGamepads(): Gamepad[];
  69597. }
  69598. interface HTMLVideoElement {
  69599. mozSrcObject: any;
  69600. }
  69601. interface Math {
  69602. fround(x: number): number;
  69603. imul(a: number, b: number): number;
  69604. }
  69605. interface WebGLRenderingContext {
  69606. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69607. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69608. vertexAttribDivisor(index: number, divisor: number): void;
  69609. createVertexArray(): any;
  69610. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69611. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69612. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69613. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69614. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69615. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69616. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69617. // Queries
  69618. createQuery(): WebGLQuery;
  69619. deleteQuery(query: WebGLQuery): void;
  69620. beginQuery(target: number, query: WebGLQuery): void;
  69621. endQuery(target: number): void;
  69622. getQueryParameter(query: WebGLQuery, pname: number): any;
  69623. getQuery(target: number, pname: number): any;
  69624. MAX_SAMPLES: number;
  69625. RGBA8: number;
  69626. READ_FRAMEBUFFER: number;
  69627. DRAW_FRAMEBUFFER: number;
  69628. UNIFORM_BUFFER: number;
  69629. HALF_FLOAT_OES: number;
  69630. RGBA16F: number;
  69631. RGBA32F: number;
  69632. R32F: number;
  69633. RG32F: number;
  69634. RGB32F: number;
  69635. R16F: number;
  69636. RG16F: number;
  69637. RGB16F: number;
  69638. RED: number;
  69639. RG: number;
  69640. R8: number;
  69641. RG8: number;
  69642. UNSIGNED_INT_24_8: number;
  69643. DEPTH24_STENCIL8: number;
  69644. MIN: number;
  69645. MAX: number;
  69646. /* Multiple Render Targets */
  69647. drawBuffers(buffers: number[]): void;
  69648. readBuffer(src: number): void;
  69649. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69650. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69651. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69652. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69653. // Occlusion Query
  69654. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69655. ANY_SAMPLES_PASSED: number;
  69656. QUERY_RESULT_AVAILABLE: number;
  69657. QUERY_RESULT: number;
  69658. }
  69659. interface WebGLProgram {
  69660. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69661. }
  69662. interface EXT_disjoint_timer_query {
  69663. QUERY_COUNTER_BITS_EXT: number;
  69664. TIME_ELAPSED_EXT: number;
  69665. TIMESTAMP_EXT: number;
  69666. GPU_DISJOINT_EXT: number;
  69667. QUERY_RESULT_EXT: number;
  69668. QUERY_RESULT_AVAILABLE_EXT: number;
  69669. queryCounterEXT(query: WebGLQuery, target: number): void;
  69670. createQueryEXT(): WebGLQuery;
  69671. beginQueryEXT(target: number, query: WebGLQuery): void;
  69672. endQueryEXT(target: number): void;
  69673. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69674. deleteQueryEXT(query: WebGLQuery): void;
  69675. }
  69676. interface WebGLUniformLocation {
  69677. _currentState: any;
  69678. }
  69679. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69680. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69681. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69682. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69683. interface WebGLRenderingContext {
  69684. readonly RASTERIZER_DISCARD: number;
  69685. readonly DEPTH_COMPONENT24: number;
  69686. readonly TEXTURE_3D: number;
  69687. readonly TEXTURE_2D_ARRAY: number;
  69688. readonly TEXTURE_COMPARE_FUNC: number;
  69689. readonly TEXTURE_COMPARE_MODE: number;
  69690. readonly COMPARE_REF_TO_TEXTURE: number;
  69691. readonly TEXTURE_WRAP_R: number;
  69692. readonly HALF_FLOAT: number;
  69693. readonly RGB8: number;
  69694. readonly RED_INTEGER: number;
  69695. readonly RG_INTEGER: number;
  69696. readonly RGB_INTEGER: number;
  69697. readonly RGBA_INTEGER: number;
  69698. readonly R8_SNORM: number;
  69699. readonly RG8_SNORM: number;
  69700. readonly RGB8_SNORM: number;
  69701. readonly RGBA8_SNORM: number;
  69702. readonly R8I: number;
  69703. readonly RG8I: number;
  69704. readonly RGB8I: number;
  69705. readonly RGBA8I: number;
  69706. readonly R8UI: number;
  69707. readonly RG8UI: number;
  69708. readonly RGB8UI: number;
  69709. readonly RGBA8UI: number;
  69710. readonly R16I: number;
  69711. readonly RG16I: number;
  69712. readonly RGB16I: number;
  69713. readonly RGBA16I: number;
  69714. readonly R16UI: number;
  69715. readonly RG16UI: number;
  69716. readonly RGB16UI: number;
  69717. readonly RGBA16UI: number;
  69718. readonly R32I: number;
  69719. readonly RG32I: number;
  69720. readonly RGB32I: number;
  69721. readonly RGBA32I: number;
  69722. readonly R32UI: number;
  69723. readonly RG32UI: number;
  69724. readonly RGB32UI: number;
  69725. readonly RGBA32UI: number;
  69726. readonly RGB10_A2UI: number;
  69727. readonly R11F_G11F_B10F: number;
  69728. readonly RGB9_E5: number;
  69729. readonly RGB10_A2: number;
  69730. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69731. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69732. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69733. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69734. readonly DEPTH_COMPONENT32F: number;
  69735. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69736. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69737. 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;
  69738. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69739. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69740. readonly TRANSFORM_FEEDBACK: number;
  69741. readonly INTERLEAVED_ATTRIBS: number;
  69742. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69743. createTransformFeedback(): WebGLTransformFeedback;
  69744. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69745. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69746. beginTransformFeedback(primitiveMode: number): void;
  69747. endTransformFeedback(): void;
  69748. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69749. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69750. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69751. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69752. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69753. }
  69754. interface ImageBitmap {
  69755. readonly width: number;
  69756. readonly height: number;
  69757. close(): void;
  69758. }
  69759. interface WebGLQuery extends WebGLObject {
  69760. }
  69761. declare var WebGLQuery: {
  69762. prototype: WebGLQuery;
  69763. new(): WebGLQuery;
  69764. };
  69765. interface WebGLSampler extends WebGLObject {
  69766. }
  69767. declare var WebGLSampler: {
  69768. prototype: WebGLSampler;
  69769. new(): WebGLSampler;
  69770. };
  69771. interface WebGLSync extends WebGLObject {
  69772. }
  69773. declare var WebGLSync: {
  69774. prototype: WebGLSync;
  69775. new(): WebGLSync;
  69776. };
  69777. interface WebGLTransformFeedback extends WebGLObject {
  69778. }
  69779. declare var WebGLTransformFeedback: {
  69780. prototype: WebGLTransformFeedback;
  69781. new(): WebGLTransformFeedback;
  69782. };
  69783. interface WebGLVertexArrayObject extends WebGLObject {
  69784. }
  69785. declare var WebGLVertexArrayObject: {
  69786. prototype: WebGLVertexArrayObject;
  69787. new(): WebGLVertexArrayObject;
  69788. };
  69789. // Type definitions for WebVR API
  69790. // Project: https://w3c.github.io/webvr/
  69791. // Definitions by: six a <https://github.com/lostfictions>
  69792. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69793. interface VRDisplay extends EventTarget {
  69794. /**
  69795. * Dictionary of capabilities describing the VRDisplay.
  69796. */
  69797. readonly capabilities: VRDisplayCapabilities;
  69798. /**
  69799. * z-depth defining the far plane of the eye view frustum
  69800. * enables mapping of values in the render target depth
  69801. * attachment to scene coordinates. Initially set to 10000.0.
  69802. */
  69803. depthFar: number;
  69804. /**
  69805. * z-depth defining the near plane of the eye view frustum
  69806. * enables mapping of values in the render target depth
  69807. * attachment to scene coordinates. Initially set to 0.01.
  69808. */
  69809. depthNear: number;
  69810. /**
  69811. * An identifier for this distinct VRDisplay. Used as an
  69812. * association point in the Gamepad API.
  69813. */
  69814. readonly displayId: number;
  69815. /**
  69816. * A display name, a user-readable name identifying it.
  69817. */
  69818. readonly displayName: string;
  69819. readonly isConnected: boolean;
  69820. readonly isPresenting: boolean;
  69821. /**
  69822. * If this VRDisplay supports room-scale experiences, the optional
  69823. * stage attribute contains details on the room-scale parameters.
  69824. */
  69825. readonly stageParameters: VRStageParameters | null;
  69826. /**
  69827. * Passing the value returned by `requestAnimationFrame` to
  69828. * `cancelAnimationFrame` will unregister the callback.
  69829. * @param handle Define the hanle of the request to cancel
  69830. */
  69831. cancelAnimationFrame(handle: number): void;
  69832. /**
  69833. * Stops presenting to the VRDisplay.
  69834. * @returns a promise to know when it stopped
  69835. */
  69836. exitPresent(): Promise<void>;
  69837. /**
  69838. * Return the current VREyeParameters for the given eye.
  69839. * @param whichEye Define the eye we want the parameter for
  69840. * @returns the eye parameters
  69841. */
  69842. getEyeParameters(whichEye: string): VREyeParameters;
  69843. /**
  69844. * Populates the passed VRFrameData with the information required to render
  69845. * the current frame.
  69846. * @param frameData Define the data structure to populate
  69847. * @returns true if ok otherwise false
  69848. */
  69849. getFrameData(frameData: VRFrameData): boolean;
  69850. /**
  69851. * Get the layers currently being presented.
  69852. * @returns the list of VR layers
  69853. */
  69854. getLayers(): VRLayer[];
  69855. /**
  69856. * Return a VRPose containing the future predicted pose of the VRDisplay
  69857. * when the current frame will be presented. The value returned will not
  69858. * change until JavaScript has returned control to the browser.
  69859. *
  69860. * The VRPose will contain the position, orientation, velocity,
  69861. * and acceleration of each of these properties.
  69862. * @returns the pose object
  69863. */
  69864. getPose(): VRPose;
  69865. /**
  69866. * Return the current instantaneous pose of the VRDisplay, with no
  69867. * prediction applied.
  69868. * @returns the current instantaneous pose
  69869. */
  69870. getImmediatePose(): VRPose;
  69871. /**
  69872. * The callback passed to `requestAnimationFrame` will be called
  69873. * any time a new frame should be rendered. When the VRDisplay is
  69874. * presenting the callback will be called at the native refresh
  69875. * rate of the HMD. When not presenting this function acts
  69876. * identically to how window.requestAnimationFrame acts. Content should
  69877. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69878. * asynchronously from other displays and at differing refresh rates.
  69879. * @param callback Define the eaction to run next frame
  69880. * @returns the request handle it
  69881. */
  69882. requestAnimationFrame(callback: FrameRequestCallback): number;
  69883. /**
  69884. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69885. * Repeat calls while already presenting will update the VRLayers being displayed.
  69886. * @param layers Define the list of layer to present
  69887. * @returns a promise to know when the request has been fulfilled
  69888. */
  69889. requestPresent(layers: VRLayer[]): Promise<void>;
  69890. /**
  69891. * Reset the pose for this display, treating its current position and
  69892. * orientation as the "origin/zero" values. VRPose.position,
  69893. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69894. * updated when calling resetPose(). This should be called in only
  69895. * sitting-space experiences.
  69896. */
  69897. resetPose(): void;
  69898. /**
  69899. * The VRLayer provided to the VRDisplay will be captured and presented
  69900. * in the HMD. Calling this function has the same effect on the source
  69901. * canvas as any other operation that uses its source image, and canvases
  69902. * created without preserveDrawingBuffer set to true will be cleared.
  69903. * @param pose Define the pose to submit
  69904. */
  69905. submitFrame(pose?: VRPose): void;
  69906. }
  69907. declare var VRDisplay: {
  69908. prototype: VRDisplay;
  69909. new(): VRDisplay;
  69910. };
  69911. interface VRLayer {
  69912. leftBounds?: number[] | Float32Array | null;
  69913. rightBounds?: number[] | Float32Array | null;
  69914. source?: HTMLCanvasElement | null;
  69915. }
  69916. interface VRDisplayCapabilities {
  69917. readonly canPresent: boolean;
  69918. readonly hasExternalDisplay: boolean;
  69919. readonly hasOrientation: boolean;
  69920. readonly hasPosition: boolean;
  69921. readonly maxLayers: number;
  69922. }
  69923. interface VREyeParameters {
  69924. /** @deprecated */
  69925. readonly fieldOfView: VRFieldOfView;
  69926. readonly offset: Float32Array;
  69927. readonly renderHeight: number;
  69928. readonly renderWidth: number;
  69929. }
  69930. interface VRFieldOfView {
  69931. readonly downDegrees: number;
  69932. readonly leftDegrees: number;
  69933. readonly rightDegrees: number;
  69934. readonly upDegrees: number;
  69935. }
  69936. interface VRFrameData {
  69937. readonly leftProjectionMatrix: Float32Array;
  69938. readonly leftViewMatrix: Float32Array;
  69939. readonly pose: VRPose;
  69940. readonly rightProjectionMatrix: Float32Array;
  69941. readonly rightViewMatrix: Float32Array;
  69942. readonly timestamp: number;
  69943. }
  69944. interface VRPose {
  69945. readonly angularAcceleration: Float32Array | null;
  69946. readonly angularVelocity: Float32Array | null;
  69947. readonly linearAcceleration: Float32Array | null;
  69948. readonly linearVelocity: Float32Array | null;
  69949. readonly orientation: Float32Array | null;
  69950. readonly position: Float32Array | null;
  69951. readonly timestamp: number;
  69952. }
  69953. interface VRStageParameters {
  69954. sittingToStandingTransform?: Float32Array;
  69955. sizeX?: number;
  69956. sizeY?: number;
  69957. }
  69958. interface Navigator {
  69959. getVRDisplays(): Promise<VRDisplay[]>;
  69960. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69961. }
  69962. interface Window {
  69963. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69964. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69965. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69966. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69967. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69968. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69969. }
  69970. interface Gamepad {
  69971. readonly displayId: number;
  69972. }
  69973. type XRSessionMode =
  69974. | "inline"
  69975. | "immersive-vr"
  69976. | "immersive-ar";
  69977. type XRReferenceSpaceType =
  69978. | "viewer"
  69979. | "local"
  69980. | "local-floor"
  69981. | "bounded-floor"
  69982. | "unbounded";
  69983. type XREnvironmentBlendMode =
  69984. | "opaque"
  69985. | "additive"
  69986. | "alpha-blend";
  69987. type XRVisibilityState =
  69988. | "visible"
  69989. | "visible-blurred"
  69990. | "hidden";
  69991. type XRHandedness =
  69992. | "none"
  69993. | "left"
  69994. | "right";
  69995. type XRTargetRayMode =
  69996. | "gaze"
  69997. | "tracked-pointer"
  69998. | "screen";
  69999. type XREye =
  70000. | "none"
  70001. | "left"
  70002. | "right";
  70003. interface XRSpace extends EventTarget {
  70004. }
  70005. interface XRRenderState {
  70006. depthNear?: number;
  70007. depthFar?: number;
  70008. inlineVerticalFieldOfView?: number;
  70009. baseLayer?: XRWebGLLayer;
  70010. }
  70011. interface XRInputSource {
  70012. handedness: XRHandedness;
  70013. targetRayMode: XRTargetRayMode;
  70014. targetRaySpace: XRSpace;
  70015. gripSpace: XRSpace | undefined;
  70016. gamepad: Gamepad | undefined;
  70017. profiles: Array<string>;
  70018. }
  70019. interface XRSessionInit {
  70020. optionalFeatures?: XRReferenceSpaceType[];
  70021. requiredFeatures?: XRReferenceSpaceType[];
  70022. }
  70023. interface XRSession extends XRAnchorCreator {
  70024. addEventListener: Function;
  70025. removeEventListener: Function;
  70026. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70027. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70028. requestAnimationFrame: Function;
  70029. end(): Promise<void>;
  70030. renderState: XRRenderState;
  70031. inputSources: Array<XRInputSource>;
  70032. // AR hit test
  70033. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70034. updateWorldTrackingState(options: {
  70035. planeDetectionState?: { enabled: boolean; }
  70036. }): void;
  70037. }
  70038. interface XRReferenceSpace extends XRSpace {
  70039. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70040. onreset: any;
  70041. }
  70042. type XRPlaneSet = Set<XRPlane>;
  70043. type XRAnchorSet = Set<XRAnchor>;
  70044. interface XRFrame {
  70045. session: XRSession;
  70046. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70047. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70048. // Anchors
  70049. trackedAnchors?: XRAnchorSet;
  70050. // Planes
  70051. worldInformation: {
  70052. detectedPlanes?: XRPlaneSet;
  70053. };
  70054. }
  70055. interface XRViewerPose extends XRPose {
  70056. views: Array<XRView>;
  70057. }
  70058. interface XRPose {
  70059. transform: XRRigidTransform;
  70060. emulatedPosition: boolean;
  70061. }
  70062. interface XRWebGLLayerOptions {
  70063. antialias?: boolean;
  70064. depth?: boolean;
  70065. stencil?: boolean;
  70066. alpha?: boolean;
  70067. multiview?: boolean;
  70068. framebufferScaleFactor?: number;
  70069. }
  70070. declare var XRWebGLLayer: {
  70071. prototype: XRWebGLLayer;
  70072. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70073. };
  70074. interface XRWebGLLayer {
  70075. framebuffer: WebGLFramebuffer;
  70076. framebufferWidth: number;
  70077. framebufferHeight: number;
  70078. getViewport: Function;
  70079. }
  70080. declare class XRRigidTransform {
  70081. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70082. position: DOMPointReadOnly;
  70083. orientation: DOMPointReadOnly;
  70084. matrix: Float32Array;
  70085. inverse: XRRigidTransform;
  70086. }
  70087. interface XRView {
  70088. eye: XREye;
  70089. projectionMatrix: Float32Array;
  70090. transform: XRRigidTransform;
  70091. }
  70092. interface XRInputSourceChangeEvent {
  70093. session: XRSession;
  70094. removed: Array<XRInputSource>;
  70095. added: Array<XRInputSource>;
  70096. }
  70097. interface XRInputSourceEvent extends Event {
  70098. readonly frame: XRFrame;
  70099. readonly inputSource: XRInputSource;
  70100. }
  70101. // Experimental(er) features
  70102. declare class XRRay {
  70103. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70104. origin: DOMPointReadOnly;
  70105. direction: DOMPointReadOnly;
  70106. matrix: Float32Array;
  70107. }
  70108. interface XRHitResult {
  70109. hitMatrix: Float32Array;
  70110. }
  70111. interface XRAnchor {
  70112. // remove?
  70113. id?: string;
  70114. anchorSpace: XRSpace;
  70115. lastChangedTime: number;
  70116. detach(): void;
  70117. }
  70118. interface XRPlane extends XRAnchorCreator {
  70119. orientation: "Horizontal" | "Vertical";
  70120. planeSpace: XRSpace;
  70121. polygon: Array<DOMPointReadOnly>;
  70122. lastChangedTime: number;
  70123. }
  70124. interface XRAnchorCreator {
  70125. // AR Anchors
  70126. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70127. }
  70128. /**
  70129. * @ignore
  70130. */
  70131. declare module BABYLON.GLTF2.Exporter {
  70132. }
  70133. /**
  70134. * @ignore
  70135. */
  70136. declare module BABYLON.GLTF1 {
  70137. }
  70138. declare module BABYLON.GUI {
  70139. /**
  70140. * Class used to specific a value and its associated unit
  70141. */
  70142. export class ValueAndUnit {
  70143. /** defines the unit to store */
  70144. unit: number;
  70145. /** defines a boolean indicating if the value can be negative */
  70146. negativeValueAllowed: boolean;
  70147. private _value;
  70148. private _originalUnit;
  70149. /**
  70150. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70151. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70152. */
  70153. ignoreAdaptiveScaling: boolean;
  70154. /**
  70155. * Creates a new ValueAndUnit
  70156. * @param value defines the value to store
  70157. * @param unit defines the unit to store
  70158. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70159. */
  70160. constructor(value: number,
  70161. /** defines the unit to store */
  70162. unit?: number,
  70163. /** defines a boolean indicating if the value can be negative */
  70164. negativeValueAllowed?: boolean);
  70165. /** Gets a boolean indicating if the value is a percentage */
  70166. get isPercentage(): boolean;
  70167. /** Gets a boolean indicating if the value is store as pixel */
  70168. get isPixel(): boolean;
  70169. /** Gets direct internal value */
  70170. get internalValue(): number;
  70171. /**
  70172. * Gets value as pixel
  70173. * @param host defines the root host
  70174. * @param refValue defines the reference value for percentages
  70175. * @returns the value as pixel
  70176. */
  70177. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70178. /**
  70179. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70180. * @param value defines the value to store
  70181. * @param unit defines the unit to store
  70182. * @returns the current ValueAndUnit
  70183. */
  70184. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70185. /**
  70186. * Gets the value accordingly to its unit
  70187. * @param host defines the root host
  70188. * @returns the value
  70189. */
  70190. getValue(host: AdvancedDynamicTexture): number;
  70191. /**
  70192. * Gets a string representation of the value
  70193. * @param host defines the root host
  70194. * @param decimals defines an optional number of decimals to display
  70195. * @returns a string
  70196. */
  70197. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70198. /**
  70199. * Store a value parsed from a string
  70200. * @param source defines the source string
  70201. * @returns true if the value was successfully parsed
  70202. */
  70203. fromString(source: string | number): boolean;
  70204. private static _Regex;
  70205. private static _UNITMODE_PERCENTAGE;
  70206. private static _UNITMODE_PIXEL;
  70207. /** UNITMODE_PERCENTAGE */
  70208. static get UNITMODE_PERCENTAGE(): number;
  70209. /** UNITMODE_PIXEL */
  70210. static get UNITMODE_PIXEL(): number;
  70211. }
  70212. }
  70213. declare module BABYLON.GUI {
  70214. /**
  70215. * Define a style used by control to automatically setup properties based on a template.
  70216. * Only support font related properties so far
  70217. */
  70218. export class Style implements BABYLON.IDisposable {
  70219. private _fontFamily;
  70220. private _fontStyle;
  70221. private _fontWeight;
  70222. /** @hidden */
  70223. _host: AdvancedDynamicTexture;
  70224. /** @hidden */
  70225. _fontSize: ValueAndUnit;
  70226. /**
  70227. * BABYLON.Observable raised when the style values are changed
  70228. */
  70229. onChangedObservable: BABYLON.Observable<Style>;
  70230. /**
  70231. * Creates a new style object
  70232. * @param host defines the AdvancedDynamicTexture which hosts this style
  70233. */
  70234. constructor(host: AdvancedDynamicTexture);
  70235. /**
  70236. * Gets or sets the font size
  70237. */
  70238. get fontSize(): string | number;
  70239. set fontSize(value: string | number);
  70240. /**
  70241. * Gets or sets the font family
  70242. */
  70243. get fontFamily(): string;
  70244. set fontFamily(value: string);
  70245. /**
  70246. * Gets or sets the font style
  70247. */
  70248. get fontStyle(): string;
  70249. set fontStyle(value: string);
  70250. /** Gets or sets font weight */
  70251. get fontWeight(): string;
  70252. set fontWeight(value: string);
  70253. /** Dispose all associated resources */
  70254. dispose(): void;
  70255. }
  70256. }
  70257. declare module BABYLON.GUI {
  70258. /**
  70259. * Class used to transport BABYLON.Vector2 information for pointer events
  70260. */
  70261. export class Vector2WithInfo extends BABYLON.Vector2 {
  70262. /** defines the current mouse button index */
  70263. buttonIndex: number;
  70264. /**
  70265. * Creates a new Vector2WithInfo
  70266. * @param source defines the vector2 data to transport
  70267. * @param buttonIndex defines the current mouse button index
  70268. */
  70269. constructor(source: BABYLON.Vector2,
  70270. /** defines the current mouse button index */
  70271. buttonIndex?: number);
  70272. }
  70273. /** Class used to provide 2D matrix features */
  70274. export class Matrix2D {
  70275. /** Gets the internal array of 6 floats used to store matrix data */
  70276. m: Float32Array;
  70277. /**
  70278. * Creates a new matrix
  70279. * @param m00 defines value for (0, 0)
  70280. * @param m01 defines value for (0, 1)
  70281. * @param m10 defines value for (1, 0)
  70282. * @param m11 defines value for (1, 1)
  70283. * @param m20 defines value for (2, 0)
  70284. * @param m21 defines value for (2, 1)
  70285. */
  70286. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70287. /**
  70288. * Fills the matrix from direct values
  70289. * @param m00 defines value for (0, 0)
  70290. * @param m01 defines value for (0, 1)
  70291. * @param m10 defines value for (1, 0)
  70292. * @param m11 defines value for (1, 1)
  70293. * @param m20 defines value for (2, 0)
  70294. * @param m21 defines value for (2, 1)
  70295. * @returns the current modified matrix
  70296. */
  70297. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70298. /**
  70299. * Gets matrix determinant
  70300. * @returns the determinant
  70301. */
  70302. determinant(): number;
  70303. /**
  70304. * Inverses the matrix and stores it in a target matrix
  70305. * @param result defines the target matrix
  70306. * @returns the current matrix
  70307. */
  70308. invertToRef(result: Matrix2D): Matrix2D;
  70309. /**
  70310. * Multiplies the current matrix with another one
  70311. * @param other defines the second operand
  70312. * @param result defines the target matrix
  70313. * @returns the current matrix
  70314. */
  70315. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70316. /**
  70317. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70318. * @param x defines the x coordinate to transform
  70319. * @param y defines the x coordinate to transform
  70320. * @param result defines the target vector2
  70321. * @returns the current matrix
  70322. */
  70323. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70324. /**
  70325. * Creates an identity matrix
  70326. * @returns a new matrix
  70327. */
  70328. static Identity(): Matrix2D;
  70329. /**
  70330. * Creates a translation matrix and stores it in a target matrix
  70331. * @param x defines the x coordinate of the translation
  70332. * @param y defines the y coordinate of the translation
  70333. * @param result defines the target matrix
  70334. */
  70335. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70336. /**
  70337. * Creates a scaling matrix and stores it in a target matrix
  70338. * @param x defines the x coordinate of the scaling
  70339. * @param y defines the y coordinate of the scaling
  70340. * @param result defines the target matrix
  70341. */
  70342. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70343. /**
  70344. * Creates a rotation matrix and stores it in a target matrix
  70345. * @param angle defines the rotation angle
  70346. * @param result defines the target matrix
  70347. */
  70348. static RotationToRef(angle: number, result: Matrix2D): void;
  70349. private static _TempPreTranslationMatrix;
  70350. private static _TempPostTranslationMatrix;
  70351. private static _TempRotationMatrix;
  70352. private static _TempScalingMatrix;
  70353. private static _TempCompose0;
  70354. private static _TempCompose1;
  70355. private static _TempCompose2;
  70356. /**
  70357. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70358. * @param tx defines the x coordinate of the translation
  70359. * @param ty defines the y coordinate of the translation
  70360. * @param angle defines the rotation angle
  70361. * @param scaleX defines the x coordinate of the scaling
  70362. * @param scaleY defines the y coordinate of the scaling
  70363. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70364. * @param result defines the target matrix
  70365. */
  70366. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70367. }
  70368. }
  70369. declare module BABYLON.GUI {
  70370. /**
  70371. * Class used to store 2D control sizes
  70372. */
  70373. export class Measure {
  70374. /** defines left coordinate */
  70375. left: number;
  70376. /** defines top coordinate */
  70377. top: number;
  70378. /** defines width dimension */
  70379. width: number;
  70380. /** defines height dimension */
  70381. height: number;
  70382. /**
  70383. * Creates a new measure
  70384. * @param left defines left coordinate
  70385. * @param top defines top coordinate
  70386. * @param width defines width dimension
  70387. * @param height defines height dimension
  70388. */
  70389. constructor(
  70390. /** defines left coordinate */
  70391. left: number,
  70392. /** defines top coordinate */
  70393. top: number,
  70394. /** defines width dimension */
  70395. width: number,
  70396. /** defines height dimension */
  70397. height: number);
  70398. /**
  70399. * Copy from another measure
  70400. * @param other defines the other measure to copy from
  70401. */
  70402. copyFrom(other: Measure): void;
  70403. /**
  70404. * Copy from a group of 4 floats
  70405. * @param left defines left coordinate
  70406. * @param top defines top coordinate
  70407. * @param width defines width dimension
  70408. * @param height defines height dimension
  70409. */
  70410. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70411. /**
  70412. * Computes the axis aligned bounding box measure for two given measures
  70413. * @param a Input measure
  70414. * @param b Input measure
  70415. * @param result the resulting bounding measure
  70416. */
  70417. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70418. /**
  70419. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70420. * @param transform the matrix to transform the measure before computing the AABB
  70421. * @param result the resulting AABB
  70422. */
  70423. transformToRef(transform: Matrix2D, result: Measure): void;
  70424. /**
  70425. * Check equality between this measure and another one
  70426. * @param other defines the other measures
  70427. * @returns true if both measures are equals
  70428. */
  70429. isEqualsTo(other: Measure): boolean;
  70430. /**
  70431. * Creates an empty measure
  70432. * @returns a new measure
  70433. */
  70434. static Empty(): Measure;
  70435. }
  70436. }
  70437. declare module BABYLON.GUI {
  70438. /**
  70439. * Interface used to define a control that can receive focus
  70440. */
  70441. export interface IFocusableControl {
  70442. /**
  70443. * Function called when the control receives the focus
  70444. */
  70445. onFocus(): void;
  70446. /**
  70447. * Function called when the control loses the focus
  70448. */
  70449. onBlur(): void;
  70450. /**
  70451. * Function called to let the control handle keyboard events
  70452. * @param evt defines the current keyboard event
  70453. */
  70454. processKeyboard(evt: KeyboardEvent): void;
  70455. /**
  70456. * Function called to get the list of controls that should not steal the focus from this control
  70457. * @returns an array of controls
  70458. */
  70459. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70460. }
  70461. /**
  70462. * Class used to create texture to support 2D GUI elements
  70463. * @see http://doc.babylonjs.com/how_to/gui
  70464. */
  70465. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70466. private _isDirty;
  70467. private _renderObserver;
  70468. private _resizeObserver;
  70469. private _preKeyboardObserver;
  70470. private _pointerMoveObserver;
  70471. private _pointerObserver;
  70472. private _canvasPointerOutObserver;
  70473. private _background;
  70474. /** @hidden */
  70475. _rootContainer: Container;
  70476. /** @hidden */
  70477. _lastPickedControl: Control;
  70478. /** @hidden */
  70479. _lastControlOver: {
  70480. [pointerId: number]: Control;
  70481. };
  70482. /** @hidden */
  70483. _lastControlDown: {
  70484. [pointerId: number]: Control;
  70485. };
  70486. /** @hidden */
  70487. _capturingControl: {
  70488. [pointerId: number]: Control;
  70489. };
  70490. /** @hidden */
  70491. _shouldBlockPointer: boolean;
  70492. /** @hidden */
  70493. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70494. /** @hidden */
  70495. _linkedControls: Control[];
  70496. private _isFullscreen;
  70497. private _fullscreenViewport;
  70498. private _idealWidth;
  70499. private _idealHeight;
  70500. private _useSmallestIdeal;
  70501. private _renderAtIdealSize;
  70502. private _focusedControl;
  70503. private _blockNextFocusCheck;
  70504. private _renderScale;
  70505. private _rootElement;
  70506. private _cursorChanged;
  70507. private _defaultMousePointerId;
  70508. /** @hidden */
  70509. _numLayoutCalls: number;
  70510. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70511. get numLayoutCalls(): number;
  70512. /** @hidden */
  70513. _numRenderCalls: number;
  70514. /** Gets the number of render calls made the last time the ADT has been rendered */
  70515. get numRenderCalls(): number;
  70516. /**
  70517. * Define type to string to ensure compatibility across browsers
  70518. * Safari doesn't support DataTransfer constructor
  70519. */
  70520. private _clipboardData;
  70521. /**
  70522. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70523. */
  70524. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70525. /**
  70526. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70527. */
  70528. onControlPickedObservable: BABYLON.Observable<Control>;
  70529. /**
  70530. * BABYLON.Observable event triggered before layout is evaluated
  70531. */
  70532. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70533. /**
  70534. * BABYLON.Observable event triggered after the layout was evaluated
  70535. */
  70536. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70537. /**
  70538. * BABYLON.Observable event triggered before the texture is rendered
  70539. */
  70540. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70541. /**
  70542. * BABYLON.Observable event triggered after the texture was rendered
  70543. */
  70544. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70545. /**
  70546. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70547. */
  70548. premulAlpha: boolean;
  70549. /**
  70550. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70551. * Useful when you want more antialiasing
  70552. */
  70553. get renderScale(): number;
  70554. set renderScale(value: number);
  70555. /** Gets or sets the background color */
  70556. get background(): string;
  70557. set background(value: string);
  70558. /**
  70559. * Gets or sets the ideal width used to design controls.
  70560. * The GUI will then rescale everything accordingly
  70561. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70562. */
  70563. get idealWidth(): number;
  70564. set idealWidth(value: number);
  70565. /**
  70566. * Gets or sets the ideal height used to design controls.
  70567. * The GUI will then rescale everything accordingly
  70568. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70569. */
  70570. get idealHeight(): number;
  70571. set idealHeight(value: number);
  70572. /**
  70573. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70574. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70575. */
  70576. get useSmallestIdeal(): boolean;
  70577. set useSmallestIdeal(value: boolean);
  70578. /**
  70579. * Gets or sets a boolean indicating if adaptive scaling must be used
  70580. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70581. */
  70582. get renderAtIdealSize(): boolean;
  70583. set renderAtIdealSize(value: boolean);
  70584. /**
  70585. * Gets the ratio used when in "ideal mode"
  70586. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70587. * */
  70588. get idealRatio(): number;
  70589. /**
  70590. * Gets the underlying layer used to render the texture when in fullscreen mode
  70591. */
  70592. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70593. /**
  70594. * Gets the root container control
  70595. */
  70596. get rootContainer(): Container;
  70597. /**
  70598. * Returns an array containing the root container.
  70599. * This is mostly used to let the Inspector introspects the ADT
  70600. * @returns an array containing the rootContainer
  70601. */
  70602. getChildren(): Array<Container>;
  70603. /**
  70604. * Will return all controls that are inside this texture
  70605. * @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
  70606. * @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
  70607. * @return all child controls
  70608. */
  70609. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70610. /**
  70611. * Gets or sets the current focused control
  70612. */
  70613. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70614. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70615. /**
  70616. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70617. */
  70618. get isForeground(): boolean;
  70619. set isForeground(value: boolean);
  70620. /**
  70621. * Gets or set information about clipboardData
  70622. */
  70623. get clipboardData(): string;
  70624. set clipboardData(value: string);
  70625. /**
  70626. * Creates a new AdvancedDynamicTexture
  70627. * @param name defines the name of the texture
  70628. * @param width defines the width of the texture
  70629. * @param height defines the height of the texture
  70630. * @param scene defines the hosting scene
  70631. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70632. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70633. */
  70634. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70635. /**
  70636. * Get the current class name of the texture useful for serialization or dynamic coding.
  70637. * @returns "AdvancedDynamicTexture"
  70638. */
  70639. getClassName(): string;
  70640. /**
  70641. * Function used to execute a function on all controls
  70642. * @param func defines the function to execute
  70643. * @param container defines the container where controls belong. If null the root container will be used
  70644. */
  70645. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70646. private _useInvalidateRectOptimization;
  70647. /**
  70648. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70649. */
  70650. get useInvalidateRectOptimization(): boolean;
  70651. set useInvalidateRectOptimization(value: boolean);
  70652. private _invalidatedRectangle;
  70653. /**
  70654. * Invalidates a rectangle area on the gui texture
  70655. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70656. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70657. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70658. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70659. */
  70660. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70661. /**
  70662. * Marks the texture as dirty forcing a complete update
  70663. */
  70664. markAsDirty(): void;
  70665. /**
  70666. * Helper function used to create a new style
  70667. * @returns a new style
  70668. * @see http://doc.babylonjs.com/how_to/gui#styles
  70669. */
  70670. createStyle(): Style;
  70671. /**
  70672. * Adds a new control to the root container
  70673. * @param control defines the control to add
  70674. * @returns the current texture
  70675. */
  70676. addControl(control: Control): AdvancedDynamicTexture;
  70677. /**
  70678. * Removes a control from the root container
  70679. * @param control defines the control to remove
  70680. * @returns the current texture
  70681. */
  70682. removeControl(control: Control): AdvancedDynamicTexture;
  70683. /**
  70684. * Release all resources
  70685. */
  70686. dispose(): void;
  70687. private _onResize;
  70688. /** @hidden */
  70689. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70690. /**
  70691. * Get screen coordinates for a vector3
  70692. * @param position defines the position to project
  70693. * @param worldMatrix defines the world matrix to use
  70694. * @returns the projected position
  70695. */
  70696. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70697. private _checkUpdate;
  70698. private _clearMeasure;
  70699. private _render;
  70700. /** @hidden */
  70701. _changeCursor(cursor: string): void;
  70702. /** @hidden */
  70703. _registerLastControlDown(control: Control, pointerId: number): void;
  70704. private _doPicking;
  70705. /** @hidden */
  70706. _cleanControlAfterRemovalFromList(list: {
  70707. [pointerId: number]: Control;
  70708. }, control: Control): void;
  70709. /** @hidden */
  70710. _cleanControlAfterRemoval(control: Control): void;
  70711. /** Attach to all scene events required to support pointer events */
  70712. attach(): void;
  70713. /** @hidden */
  70714. private onClipboardCopy;
  70715. /** @hidden */
  70716. private onClipboardCut;
  70717. /** @hidden */
  70718. private onClipboardPaste;
  70719. /**
  70720. * Register the clipboard Events onto the canvas
  70721. */
  70722. registerClipboardEvents(): void;
  70723. /**
  70724. * Unregister the clipboard Events from the canvas
  70725. */
  70726. unRegisterClipboardEvents(): void;
  70727. /**
  70728. * Connect the texture to a hosting mesh to enable interactions
  70729. * @param mesh defines the mesh to attach to
  70730. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70731. */
  70732. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70733. /**
  70734. * Move the focus to a specific control
  70735. * @param control defines the control which will receive the focus
  70736. */
  70737. moveFocusToControl(control: IFocusableControl): void;
  70738. private _manageFocus;
  70739. private _attachToOnPointerOut;
  70740. /**
  70741. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70742. * @param mesh defines the mesh which will receive the texture
  70743. * @param width defines the texture width (1024 by default)
  70744. * @param height defines the texture height (1024 by default)
  70745. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70746. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70747. * @returns a new AdvancedDynamicTexture
  70748. */
  70749. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70750. /**
  70751. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70752. * In this mode the texture will rely on a layer for its rendering.
  70753. * This allows it to be treated like any other layer.
  70754. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70755. * LayerMask is set through advancedTexture.layer.layerMask
  70756. * @param name defines name for the texture
  70757. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70758. * @param scene defines the hsoting scene
  70759. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70760. * @returns a new AdvancedDynamicTexture
  70761. */
  70762. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70763. }
  70764. }
  70765. declare module BABYLON.GUI {
  70766. /**
  70767. * Root class used for all 2D controls
  70768. * @see http://doc.babylonjs.com/how_to/gui#controls
  70769. */
  70770. export class Control {
  70771. /** defines the name of the control */
  70772. name?: string | undefined;
  70773. /**
  70774. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70775. */
  70776. static AllowAlphaInheritance: boolean;
  70777. private _alpha;
  70778. private _alphaSet;
  70779. private _zIndex;
  70780. /** @hidden */
  70781. _host: AdvancedDynamicTexture;
  70782. /** Gets or sets the control parent */
  70783. parent: BABYLON.Nullable<Container>;
  70784. /** @hidden */
  70785. _currentMeasure: Measure;
  70786. private _fontFamily;
  70787. private _fontStyle;
  70788. private _fontWeight;
  70789. private _fontSize;
  70790. private _font;
  70791. /** @hidden */
  70792. _width: ValueAndUnit;
  70793. /** @hidden */
  70794. _height: ValueAndUnit;
  70795. /** @hidden */
  70796. protected _fontOffset: {
  70797. ascent: number;
  70798. height: number;
  70799. descent: number;
  70800. };
  70801. private _color;
  70802. private _style;
  70803. private _styleObserver;
  70804. /** @hidden */
  70805. protected _horizontalAlignment: number;
  70806. /** @hidden */
  70807. protected _verticalAlignment: number;
  70808. /** @hidden */
  70809. protected _isDirty: boolean;
  70810. /** @hidden */
  70811. protected _wasDirty: boolean;
  70812. /** @hidden */
  70813. _tempParentMeasure: Measure;
  70814. /** @hidden */
  70815. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70816. /** @hidden */
  70817. protected _cachedParentMeasure: Measure;
  70818. private _paddingLeft;
  70819. private _paddingRight;
  70820. private _paddingTop;
  70821. private _paddingBottom;
  70822. /** @hidden */
  70823. _left: ValueAndUnit;
  70824. /** @hidden */
  70825. _top: ValueAndUnit;
  70826. private _scaleX;
  70827. private _scaleY;
  70828. private _rotation;
  70829. private _transformCenterX;
  70830. private _transformCenterY;
  70831. /** @hidden */
  70832. _transformMatrix: Matrix2D;
  70833. /** @hidden */
  70834. protected _invertTransformMatrix: Matrix2D;
  70835. /** @hidden */
  70836. protected _transformedPosition: BABYLON.Vector2;
  70837. private _isMatrixDirty;
  70838. private _cachedOffsetX;
  70839. private _cachedOffsetY;
  70840. private _isVisible;
  70841. private _isHighlighted;
  70842. /** @hidden */
  70843. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70844. private _fontSet;
  70845. private _dummyVector2;
  70846. private _downCount;
  70847. private _enterCount;
  70848. private _doNotRender;
  70849. private _downPointerIds;
  70850. protected _isEnabled: boolean;
  70851. protected _disabledColor: string;
  70852. protected _disabledColorItem: string;
  70853. /** @hidden */
  70854. protected _rebuildLayout: boolean;
  70855. /** @hidden */
  70856. _customData: any;
  70857. /** @hidden */
  70858. _isClipped: boolean;
  70859. /** @hidden */
  70860. _automaticSize: boolean;
  70861. /** @hidden */
  70862. _tag: any;
  70863. /**
  70864. * 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
  70865. */
  70866. uniqueId: number;
  70867. /**
  70868. * Gets or sets an object used to store user defined information for the node
  70869. */
  70870. metadata: any;
  70871. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70872. isHitTestVisible: boolean;
  70873. /** Gets or sets a boolean indicating if the control can block pointer events */
  70874. isPointerBlocker: boolean;
  70875. /** Gets or sets a boolean indicating if the control can be focusable */
  70876. isFocusInvisible: boolean;
  70877. /**
  70878. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70879. * 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
  70880. */
  70881. clipChildren: boolean;
  70882. /**
  70883. * Gets or sets a boolean indicating that control content must be clipped
  70884. * 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
  70885. */
  70886. clipContent: boolean;
  70887. /**
  70888. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70889. */
  70890. useBitmapCache: boolean;
  70891. private _cacheData;
  70892. private _shadowOffsetX;
  70893. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70894. get shadowOffsetX(): number;
  70895. set shadowOffsetX(value: number);
  70896. private _shadowOffsetY;
  70897. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70898. get shadowOffsetY(): number;
  70899. set shadowOffsetY(value: number);
  70900. private _shadowBlur;
  70901. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70902. get shadowBlur(): number;
  70903. set shadowBlur(value: number);
  70904. private _shadowColor;
  70905. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70906. get shadowColor(): string;
  70907. set shadowColor(value: string);
  70908. /** Gets or sets the cursor to use when the control is hovered */
  70909. hoverCursor: string;
  70910. /** @hidden */
  70911. protected _linkOffsetX: ValueAndUnit;
  70912. /** @hidden */
  70913. protected _linkOffsetY: ValueAndUnit;
  70914. /** Gets the control type name */
  70915. get typeName(): string;
  70916. /**
  70917. * Get the current class name of the control.
  70918. * @returns current class name
  70919. */
  70920. getClassName(): string;
  70921. /**
  70922. * An event triggered when pointer wheel is scrolled
  70923. */
  70924. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  70925. /**
  70926. * An event triggered when the pointer move over the control.
  70927. */
  70928. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70929. /**
  70930. * An event triggered when the pointer move out of the control.
  70931. */
  70932. onPointerOutObservable: BABYLON.Observable<Control>;
  70933. /**
  70934. * An event triggered when the pointer taps the control
  70935. */
  70936. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70937. /**
  70938. * An event triggered when pointer up
  70939. */
  70940. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70941. /**
  70942. * An event triggered when a control is clicked on
  70943. */
  70944. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70945. /**
  70946. * An event triggered when pointer enters the control
  70947. */
  70948. onPointerEnterObservable: BABYLON.Observable<Control>;
  70949. /**
  70950. * An event triggered when the control is marked as dirty
  70951. */
  70952. onDirtyObservable: BABYLON.Observable<Control>;
  70953. /**
  70954. * An event triggered before drawing the control
  70955. */
  70956. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70957. /**
  70958. * An event triggered after the control was drawn
  70959. */
  70960. onAfterDrawObservable: BABYLON.Observable<Control>;
  70961. /**
  70962. * Get the hosting AdvancedDynamicTexture
  70963. */
  70964. get host(): AdvancedDynamicTexture;
  70965. /** Gets or set information about font offsets (used to render and align text) */
  70966. get fontOffset(): {
  70967. ascent: number;
  70968. height: number;
  70969. descent: number;
  70970. };
  70971. set fontOffset(offset: {
  70972. ascent: number;
  70973. height: number;
  70974. descent: number;
  70975. });
  70976. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70977. get alpha(): number;
  70978. set alpha(value: number);
  70979. /**
  70980. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70981. */
  70982. get isHighlighted(): boolean;
  70983. set isHighlighted(value: boolean);
  70984. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70985. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70986. */
  70987. get scaleX(): number;
  70988. set scaleX(value: number);
  70989. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70990. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70991. */
  70992. get scaleY(): number;
  70993. set scaleY(value: number);
  70994. /** Gets or sets the rotation angle (0 by default)
  70995. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70996. */
  70997. get rotation(): number;
  70998. set rotation(value: number);
  70999. /** Gets or sets the transformation center on Y axis (0 by default)
  71000. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71001. */
  71002. get transformCenterY(): number;
  71003. set transformCenterY(value: number);
  71004. /** Gets or sets the transformation center on X axis (0 by default)
  71005. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71006. */
  71007. get transformCenterX(): number;
  71008. set transformCenterX(value: number);
  71009. /**
  71010. * Gets or sets the horizontal alignment
  71011. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71012. */
  71013. get horizontalAlignment(): number;
  71014. set horizontalAlignment(value: number);
  71015. /**
  71016. * Gets or sets the vertical alignment
  71017. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71018. */
  71019. get verticalAlignment(): number;
  71020. set verticalAlignment(value: number);
  71021. /**
  71022. * Gets or sets control width
  71023. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71024. */
  71025. get width(): string | number;
  71026. set width(value: string | number);
  71027. /**
  71028. * Gets or sets the control width in pixel
  71029. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71030. */
  71031. get widthInPixels(): number;
  71032. set widthInPixels(value: number);
  71033. /**
  71034. * Gets or sets control height
  71035. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71036. */
  71037. get height(): string | number;
  71038. set height(value: string | number);
  71039. /**
  71040. * Gets or sets control height in pixel
  71041. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71042. */
  71043. get heightInPixels(): number;
  71044. set heightInPixels(value: number);
  71045. /** Gets or set font family */
  71046. get fontFamily(): string;
  71047. set fontFamily(value: string);
  71048. /** Gets or sets font style */
  71049. get fontStyle(): string;
  71050. set fontStyle(value: string);
  71051. /** Gets or sets font weight */
  71052. get fontWeight(): string;
  71053. set fontWeight(value: string);
  71054. /**
  71055. * Gets or sets style
  71056. * @see http://doc.babylonjs.com/how_to/gui#styles
  71057. */
  71058. get style(): BABYLON.Nullable<Style>;
  71059. set style(value: BABYLON.Nullable<Style>);
  71060. /** @hidden */
  71061. get _isFontSizeInPercentage(): boolean;
  71062. /** Gets or sets font size in pixels */
  71063. get fontSizeInPixels(): number;
  71064. set fontSizeInPixels(value: number);
  71065. /** Gets or sets font size */
  71066. get fontSize(): string | number;
  71067. set fontSize(value: string | number);
  71068. /** Gets or sets foreground color */
  71069. get color(): string;
  71070. set color(value: string);
  71071. /** Gets or sets z index which is used to reorder controls on the z axis */
  71072. get zIndex(): number;
  71073. set zIndex(value: number);
  71074. /** Gets or sets a boolean indicating if the control can be rendered */
  71075. get notRenderable(): boolean;
  71076. set notRenderable(value: boolean);
  71077. /** Gets or sets a boolean indicating if the control is visible */
  71078. get isVisible(): boolean;
  71079. set isVisible(value: boolean);
  71080. /** Gets a boolean indicating that the control needs to update its rendering */
  71081. get isDirty(): boolean;
  71082. /**
  71083. * Gets the current linked mesh (or null if none)
  71084. */
  71085. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71086. /**
  71087. * Gets or sets a value indicating the padding to use on the left of the control
  71088. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71089. */
  71090. get paddingLeft(): string | number;
  71091. set paddingLeft(value: string | number);
  71092. /**
  71093. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71094. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71095. */
  71096. get paddingLeftInPixels(): number;
  71097. set paddingLeftInPixels(value: number);
  71098. /**
  71099. * Gets or sets a value indicating the padding to use on the right of the control
  71100. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71101. */
  71102. get paddingRight(): string | number;
  71103. set paddingRight(value: string | number);
  71104. /**
  71105. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71106. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71107. */
  71108. get paddingRightInPixels(): number;
  71109. set paddingRightInPixels(value: number);
  71110. /**
  71111. * Gets or sets a value indicating the padding to use on the top of the control
  71112. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71113. */
  71114. get paddingTop(): string | number;
  71115. set paddingTop(value: string | number);
  71116. /**
  71117. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71118. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71119. */
  71120. get paddingTopInPixels(): number;
  71121. set paddingTopInPixels(value: number);
  71122. /**
  71123. * Gets or sets a value indicating the padding to use on the bottom of the control
  71124. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71125. */
  71126. get paddingBottom(): string | number;
  71127. set paddingBottom(value: string | number);
  71128. /**
  71129. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71130. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71131. */
  71132. get paddingBottomInPixels(): number;
  71133. set paddingBottomInPixels(value: number);
  71134. /**
  71135. * Gets or sets a value indicating the left coordinate of the control
  71136. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71137. */
  71138. get left(): string | number;
  71139. set left(value: string | number);
  71140. /**
  71141. * Gets or sets a value indicating the left coordinate in pixels of the control
  71142. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71143. */
  71144. get leftInPixels(): number;
  71145. set leftInPixels(value: number);
  71146. /**
  71147. * Gets or sets a value indicating the top coordinate of the control
  71148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71149. */
  71150. get top(): string | number;
  71151. set top(value: string | number);
  71152. /**
  71153. * Gets or sets a value indicating the top coordinate in pixels of the control
  71154. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71155. */
  71156. get topInPixels(): number;
  71157. set topInPixels(value: number);
  71158. /**
  71159. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71160. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71161. */
  71162. get linkOffsetX(): string | number;
  71163. set linkOffsetX(value: string | number);
  71164. /**
  71165. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71166. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71167. */
  71168. get linkOffsetXInPixels(): number;
  71169. set linkOffsetXInPixels(value: number);
  71170. /**
  71171. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71172. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71173. */
  71174. get linkOffsetY(): string | number;
  71175. set linkOffsetY(value: string | number);
  71176. /**
  71177. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71178. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71179. */
  71180. get linkOffsetYInPixels(): number;
  71181. set linkOffsetYInPixels(value: number);
  71182. /** Gets the center coordinate on X axis */
  71183. get centerX(): number;
  71184. /** Gets the center coordinate on Y axis */
  71185. get centerY(): number;
  71186. /** Gets or sets if control is Enabled*/
  71187. get isEnabled(): boolean;
  71188. set isEnabled(value: boolean);
  71189. /** Gets or sets background color of control if it's disabled*/
  71190. get disabledColor(): string;
  71191. set disabledColor(value: string);
  71192. /** Gets or sets front color of control if it's disabled*/
  71193. get disabledColorItem(): string;
  71194. set disabledColorItem(value: string);
  71195. /**
  71196. * Creates a new control
  71197. * @param name defines the name of the control
  71198. */
  71199. constructor(
  71200. /** defines the name of the control */
  71201. name?: string | undefined);
  71202. /** @hidden */
  71203. protected _getTypeName(): string;
  71204. /**
  71205. * Gets the first ascendant in the hierarchy of the given type
  71206. * @param className defines the required type
  71207. * @returns the ascendant or null if not found
  71208. */
  71209. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71210. /** @hidden */
  71211. _resetFontCache(): void;
  71212. /**
  71213. * Determines if a container is an ascendant of the current control
  71214. * @param container defines the container to look for
  71215. * @returns true if the container is one of the ascendant of the control
  71216. */
  71217. isAscendant(container: Control): boolean;
  71218. /**
  71219. * Gets coordinates in local control space
  71220. * @param globalCoordinates defines the coordinates to transform
  71221. * @returns the new coordinates in local space
  71222. */
  71223. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71224. /**
  71225. * Gets coordinates in local control space
  71226. * @param globalCoordinates defines the coordinates to transform
  71227. * @param result defines the target vector2 where to store the result
  71228. * @returns the current control
  71229. */
  71230. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71231. /**
  71232. * Gets coordinates in parent local control space
  71233. * @param globalCoordinates defines the coordinates to transform
  71234. * @returns the new coordinates in parent local space
  71235. */
  71236. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71237. /**
  71238. * Move the current control to a vector3 position projected onto the screen.
  71239. * @param position defines the target position
  71240. * @param scene defines the hosting scene
  71241. */
  71242. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71243. /**
  71244. * Will store all controls that have this control as ascendant in a given array
  71245. * @param results defines the array where to store the descendants
  71246. * @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
  71247. * @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
  71248. */
  71249. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71250. /**
  71251. * Will return all controls that have this control as ascendant
  71252. * @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
  71253. * @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
  71254. * @return all child controls
  71255. */
  71256. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71257. /**
  71258. * Link current control with a target mesh
  71259. * @param mesh defines the mesh to link with
  71260. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71261. */
  71262. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71263. /** @hidden */
  71264. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71265. /** @hidden */
  71266. _offsetLeft(offset: number): void;
  71267. /** @hidden */
  71268. _offsetTop(offset: number): void;
  71269. /** @hidden */
  71270. _markMatrixAsDirty(): void;
  71271. /** @hidden */
  71272. _flagDescendantsAsMatrixDirty(): void;
  71273. /** @hidden */
  71274. _intersectsRect(rect: Measure): boolean;
  71275. /** @hidden */
  71276. protected invalidateRect(): void;
  71277. /** @hidden */
  71278. _markAsDirty(force?: boolean): void;
  71279. /** @hidden */
  71280. _markAllAsDirty(): void;
  71281. /** @hidden */
  71282. _link(host: AdvancedDynamicTexture): void;
  71283. /** @hidden */
  71284. protected _transform(context?: CanvasRenderingContext2D): void;
  71285. /** @hidden */
  71286. _renderHighlight(context: CanvasRenderingContext2D): void;
  71287. /** @hidden */
  71288. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71289. /** @hidden */
  71290. protected _applyStates(context: CanvasRenderingContext2D): void;
  71291. /** @hidden */
  71292. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71293. /** @hidden */
  71294. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71295. protected _evaluateClippingState(parentMeasure: Measure): void;
  71296. /** @hidden */
  71297. _measure(): void;
  71298. /** @hidden */
  71299. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71300. /** @hidden */
  71301. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71302. /** @hidden */
  71303. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71304. /** @hidden */
  71305. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71306. private static _ClipMeasure;
  71307. private _tmpMeasureA;
  71308. private _clip;
  71309. /** @hidden */
  71310. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71311. /** @hidden */
  71312. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71313. /**
  71314. * Tests if a given coordinates belong to the current control
  71315. * @param x defines x coordinate to test
  71316. * @param y defines y coordinate to test
  71317. * @returns true if the coordinates are inside the control
  71318. */
  71319. contains(x: number, y: number): boolean;
  71320. /** @hidden */
  71321. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71322. /** @hidden */
  71323. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71324. /** @hidden */
  71325. _onPointerEnter(target: Control): boolean;
  71326. /** @hidden */
  71327. _onPointerOut(target: Control, force?: boolean): void;
  71328. /** @hidden */
  71329. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71330. /** @hidden */
  71331. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71332. /** @hidden */
  71333. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71334. /** @hidden */
  71335. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71336. /** @hidden */
  71337. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71338. private _prepareFont;
  71339. /** Releases associated resources */
  71340. dispose(): void;
  71341. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71342. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71343. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71344. private static _VERTICAL_ALIGNMENT_TOP;
  71345. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71346. private static _VERTICAL_ALIGNMENT_CENTER;
  71347. /** HORIZONTAL_ALIGNMENT_LEFT */
  71348. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71349. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71350. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71351. /** HORIZONTAL_ALIGNMENT_CENTER */
  71352. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71353. /** VERTICAL_ALIGNMENT_TOP */
  71354. static get VERTICAL_ALIGNMENT_TOP(): number;
  71355. /** VERTICAL_ALIGNMENT_BOTTOM */
  71356. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71357. /** VERTICAL_ALIGNMENT_CENTER */
  71358. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71359. private static _FontHeightSizes;
  71360. /** @hidden */
  71361. static _GetFontOffset(font: string): {
  71362. ascent: number;
  71363. height: number;
  71364. descent: number;
  71365. };
  71366. /**
  71367. * Creates a stack panel that can be used to render headers
  71368. * @param control defines the control to associate with the header
  71369. * @param text defines the text of the header
  71370. * @param size defines the size of the header
  71371. * @param options defines options used to configure the header
  71372. * @returns a new StackPanel
  71373. * @ignore
  71374. * @hidden
  71375. */
  71376. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71377. isHorizontal: boolean;
  71378. controlFirst: boolean;
  71379. }) => any;
  71380. /** @hidden */
  71381. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71382. }
  71383. }
  71384. declare module BABYLON.GUI {
  71385. /**
  71386. * Root class for 2D containers
  71387. * @see http://doc.babylonjs.com/how_to/gui#containers
  71388. */
  71389. export class Container extends Control {
  71390. name?: string | undefined;
  71391. /** @hidden */
  71392. _children: Control[];
  71393. /** @hidden */
  71394. protected _measureForChildren: Measure;
  71395. /** @hidden */
  71396. protected _background: string;
  71397. /** @hidden */
  71398. protected _adaptWidthToChildren: boolean;
  71399. /** @hidden */
  71400. protected _adaptHeightToChildren: boolean;
  71401. /**
  71402. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71403. */
  71404. logLayoutCycleErrors: boolean;
  71405. /**
  71406. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71407. */
  71408. maxLayoutCycle: number;
  71409. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71410. get adaptHeightToChildren(): boolean;
  71411. set adaptHeightToChildren(value: boolean);
  71412. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71413. get adaptWidthToChildren(): boolean;
  71414. set adaptWidthToChildren(value: boolean);
  71415. /** Gets or sets background color */
  71416. get background(): string;
  71417. set background(value: string);
  71418. /** Gets the list of children */
  71419. get children(): Control[];
  71420. /**
  71421. * Creates a new Container
  71422. * @param name defines the name of the container
  71423. */
  71424. constructor(name?: string | undefined);
  71425. protected _getTypeName(): string;
  71426. _flagDescendantsAsMatrixDirty(): void;
  71427. /**
  71428. * Gets a child using its name
  71429. * @param name defines the child name to look for
  71430. * @returns the child control if found
  71431. */
  71432. getChildByName(name: string): BABYLON.Nullable<Control>;
  71433. /**
  71434. * Gets a child using its type and its name
  71435. * @param name defines the child name to look for
  71436. * @param type defines the child type to look for
  71437. * @returns the child control if found
  71438. */
  71439. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71440. /**
  71441. * Search for a specific control in children
  71442. * @param control defines the control to look for
  71443. * @returns true if the control is in child list
  71444. */
  71445. containsControl(control: Control): boolean;
  71446. /**
  71447. * Adds a new control to the current container
  71448. * @param control defines the control to add
  71449. * @returns the current container
  71450. */
  71451. addControl(control: BABYLON.Nullable<Control>): Container;
  71452. /**
  71453. * Removes all controls from the current container
  71454. * @returns the current container
  71455. */
  71456. clearControls(): Container;
  71457. /**
  71458. * Removes a control from the current container
  71459. * @param control defines the control to remove
  71460. * @returns the current container
  71461. */
  71462. removeControl(control: Control): Container;
  71463. /** @hidden */
  71464. _reOrderControl(control: Control): void;
  71465. /** @hidden */
  71466. _offsetLeft(offset: number): void;
  71467. /** @hidden */
  71468. _offsetTop(offset: number): void;
  71469. /** @hidden */
  71470. _markAllAsDirty(): void;
  71471. /** @hidden */
  71472. protected _localDraw(context: CanvasRenderingContext2D): void;
  71473. /** @hidden */
  71474. _link(host: AdvancedDynamicTexture): void;
  71475. /** @hidden */
  71476. protected _beforeLayout(): void;
  71477. /** @hidden */
  71478. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71479. /** @hidden */
  71480. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71481. protected _postMeasure(): void;
  71482. /** @hidden */
  71483. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71484. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71485. /** @hidden */
  71486. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71487. /** @hidden */
  71488. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71489. /** Releases associated resources */
  71490. dispose(): void;
  71491. }
  71492. }
  71493. declare module BABYLON.GUI {
  71494. /** Class used to create rectangle container */
  71495. export class Rectangle extends Container {
  71496. name?: string | undefined;
  71497. private _thickness;
  71498. private _cornerRadius;
  71499. /** Gets or sets border thickness */
  71500. get thickness(): number;
  71501. set thickness(value: number);
  71502. /** Gets or sets the corner radius angle */
  71503. get cornerRadius(): number;
  71504. set cornerRadius(value: number);
  71505. /**
  71506. * Creates a new Rectangle
  71507. * @param name defines the control name
  71508. */
  71509. constructor(name?: string | undefined);
  71510. protected _getTypeName(): string;
  71511. protected _localDraw(context: CanvasRenderingContext2D): void;
  71512. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71513. private _drawRoundedRect;
  71514. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71515. }
  71516. }
  71517. declare module BABYLON.GUI {
  71518. /**
  71519. * Enum that determines the text-wrapping mode to use.
  71520. */
  71521. export enum TextWrapping {
  71522. /**
  71523. * Clip the text when it's larger than Control.width; this is the default mode.
  71524. */
  71525. Clip = 0,
  71526. /**
  71527. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71528. */
  71529. WordWrap = 1,
  71530. /**
  71531. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71532. */
  71533. Ellipsis = 2
  71534. }
  71535. /**
  71536. * Class used to create text block control
  71537. */
  71538. export class TextBlock extends Control {
  71539. /**
  71540. * Defines the name of the control
  71541. */
  71542. name?: string | undefined;
  71543. private _text;
  71544. private _textWrapping;
  71545. private _textHorizontalAlignment;
  71546. private _textVerticalAlignment;
  71547. private _lines;
  71548. private _resizeToFit;
  71549. private _lineSpacing;
  71550. private _outlineWidth;
  71551. private _outlineColor;
  71552. /**
  71553. * An event triggered after the text is changed
  71554. */
  71555. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71556. /**
  71557. * An event triggered after the text was broken up into lines
  71558. */
  71559. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71560. /**
  71561. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71562. */
  71563. get lines(): any[];
  71564. /**
  71565. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71566. */
  71567. get resizeToFit(): boolean;
  71568. /**
  71569. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71570. */
  71571. set resizeToFit(value: boolean);
  71572. /**
  71573. * Gets or sets a boolean indicating if text must be wrapped
  71574. */
  71575. get textWrapping(): TextWrapping | boolean;
  71576. /**
  71577. * Gets or sets a boolean indicating if text must be wrapped
  71578. */
  71579. set textWrapping(value: TextWrapping | boolean);
  71580. /**
  71581. * Gets or sets text to display
  71582. */
  71583. get text(): string;
  71584. /**
  71585. * Gets or sets text to display
  71586. */
  71587. set text(value: string);
  71588. /**
  71589. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71590. */
  71591. get textHorizontalAlignment(): number;
  71592. /**
  71593. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71594. */
  71595. set textHorizontalAlignment(value: number);
  71596. /**
  71597. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71598. */
  71599. get textVerticalAlignment(): number;
  71600. /**
  71601. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71602. */
  71603. set textVerticalAlignment(value: number);
  71604. /**
  71605. * Gets or sets line spacing value
  71606. */
  71607. set lineSpacing(value: string | number);
  71608. /**
  71609. * Gets or sets line spacing value
  71610. */
  71611. get lineSpacing(): string | number;
  71612. /**
  71613. * Gets or sets outlineWidth of the text to display
  71614. */
  71615. get outlineWidth(): number;
  71616. /**
  71617. * Gets or sets outlineWidth of the text to display
  71618. */
  71619. set outlineWidth(value: number);
  71620. /**
  71621. * Gets or sets outlineColor of the text to display
  71622. */
  71623. get outlineColor(): string;
  71624. /**
  71625. * Gets or sets outlineColor of the text to display
  71626. */
  71627. set outlineColor(value: string);
  71628. /**
  71629. * Creates a new TextBlock object
  71630. * @param name defines the name of the control
  71631. * @param text defines the text to display (emptry string by default)
  71632. */
  71633. constructor(
  71634. /**
  71635. * Defines the name of the control
  71636. */
  71637. name?: string | undefined, text?: string);
  71638. protected _getTypeName(): string;
  71639. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71640. private _drawText;
  71641. /** @hidden */
  71642. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71643. protected _applyStates(context: CanvasRenderingContext2D): void;
  71644. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71645. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71646. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71647. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71648. protected _renderLines(context: CanvasRenderingContext2D): void;
  71649. /**
  71650. * Given a width constraint applied on the text block, find the expected height
  71651. * @returns expected height
  71652. */
  71653. computeExpectedHeight(): number;
  71654. dispose(): void;
  71655. }
  71656. }
  71657. declare module BABYLON.GUI {
  71658. /**
  71659. * Class used to create 2D images
  71660. */
  71661. export class Image extends Control {
  71662. name?: string | undefined;
  71663. private _workingCanvas;
  71664. private _domImage;
  71665. private _imageWidth;
  71666. private _imageHeight;
  71667. private _loaded;
  71668. private _stretch;
  71669. private _source;
  71670. private _autoScale;
  71671. private _sourceLeft;
  71672. private _sourceTop;
  71673. private _sourceWidth;
  71674. private _sourceHeight;
  71675. private _svgAttributesComputationCompleted;
  71676. private _isSVG;
  71677. private _cellWidth;
  71678. private _cellHeight;
  71679. private _cellId;
  71680. private _populateNinePatchSlicesFromImage;
  71681. private _sliceLeft;
  71682. private _sliceRight;
  71683. private _sliceTop;
  71684. private _sliceBottom;
  71685. private _detectPointerOnOpaqueOnly;
  71686. /**
  71687. * BABYLON.Observable notified when the content is loaded
  71688. */
  71689. onImageLoadedObservable: BABYLON.Observable<Image>;
  71690. /**
  71691. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71692. */
  71693. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71694. /**
  71695. * Gets a boolean indicating that the content is loaded
  71696. */
  71697. get isLoaded(): boolean;
  71698. /**
  71699. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71700. */
  71701. get populateNinePatchSlicesFromImage(): boolean;
  71702. set populateNinePatchSlicesFromImage(value: boolean);
  71703. /**
  71704. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71705. * Beware using this as this will comsume more memory as the image has to be stored twice
  71706. */
  71707. get detectPointerOnOpaqueOnly(): boolean;
  71708. set detectPointerOnOpaqueOnly(value: boolean);
  71709. /**
  71710. * Gets or sets the left value for slicing (9-patch)
  71711. */
  71712. get sliceLeft(): number;
  71713. set sliceLeft(value: number);
  71714. /**
  71715. * Gets or sets the right value for slicing (9-patch)
  71716. */
  71717. get sliceRight(): number;
  71718. set sliceRight(value: number);
  71719. /**
  71720. * Gets or sets the top value for slicing (9-patch)
  71721. */
  71722. get sliceTop(): number;
  71723. set sliceTop(value: number);
  71724. /**
  71725. * Gets or sets the bottom value for slicing (9-patch)
  71726. */
  71727. get sliceBottom(): number;
  71728. set sliceBottom(value: number);
  71729. /**
  71730. * Gets or sets the left coordinate in the source image
  71731. */
  71732. get sourceLeft(): number;
  71733. set sourceLeft(value: number);
  71734. /**
  71735. * Gets or sets the top coordinate in the source image
  71736. */
  71737. get sourceTop(): number;
  71738. set sourceTop(value: number);
  71739. /**
  71740. * Gets or sets the width to capture in the source image
  71741. */
  71742. get sourceWidth(): number;
  71743. set sourceWidth(value: number);
  71744. /**
  71745. * Gets or sets the height to capture in the source image
  71746. */
  71747. get sourceHeight(): number;
  71748. set sourceHeight(value: number);
  71749. /** Indicates if the format of the image is SVG */
  71750. get isSVG(): boolean;
  71751. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71752. get svgAttributesComputationCompleted(): boolean;
  71753. /**
  71754. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71755. * @see http://doc.babylonjs.com/how_to/gui#image
  71756. */
  71757. get autoScale(): boolean;
  71758. set autoScale(value: boolean);
  71759. /** Gets or sets the streching mode used by the image */
  71760. get stretch(): number;
  71761. set stretch(value: number);
  71762. /** @hidden */
  71763. _rotate90(n: number, preserveProperties?: boolean): Image;
  71764. private _handleRotationForSVGImage;
  71765. private _rotate90SourceProperties;
  71766. /**
  71767. * Gets or sets the internal DOM image used to render the control
  71768. */
  71769. set domImage(value: HTMLImageElement);
  71770. get domImage(): HTMLImageElement;
  71771. private _onImageLoaded;
  71772. private _extractNinePatchSliceDataFromImage;
  71773. /**
  71774. * Gets or sets image source url
  71775. */
  71776. set source(value: BABYLON.Nullable<string>);
  71777. /**
  71778. * Checks for svg document with icon id present
  71779. */
  71780. private _svgCheck;
  71781. /**
  71782. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71783. * given external svg file and icon id
  71784. */
  71785. private _getSVGAttribs;
  71786. /**
  71787. * Gets or sets the cell width to use when animation sheet is enabled
  71788. * @see http://doc.babylonjs.com/how_to/gui#image
  71789. */
  71790. get cellWidth(): number;
  71791. set cellWidth(value: number);
  71792. /**
  71793. * Gets or sets the cell height to use when animation sheet is enabled
  71794. * @see http://doc.babylonjs.com/how_to/gui#image
  71795. */
  71796. get cellHeight(): number;
  71797. set cellHeight(value: number);
  71798. /**
  71799. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71800. * @see http://doc.babylonjs.com/how_to/gui#image
  71801. */
  71802. get cellId(): number;
  71803. set cellId(value: number);
  71804. /**
  71805. * Creates a new Image
  71806. * @param name defines the control name
  71807. * @param url defines the image url
  71808. */
  71809. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71810. /**
  71811. * Tests if a given coordinates belong to the current control
  71812. * @param x defines x coordinate to test
  71813. * @param y defines y coordinate to test
  71814. * @returns true if the coordinates are inside the control
  71815. */
  71816. contains(x: number, y: number): boolean;
  71817. protected _getTypeName(): string;
  71818. /** Force the control to synchronize with its content */
  71819. synchronizeSizeWithContent(): void;
  71820. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71821. private _prepareWorkingCanvasForOpaqueDetection;
  71822. private _drawImage;
  71823. _draw(context: CanvasRenderingContext2D): void;
  71824. private _renderCornerPatch;
  71825. private _renderNinePatch;
  71826. dispose(): void;
  71827. /** STRETCH_NONE */
  71828. static readonly STRETCH_NONE: number;
  71829. /** STRETCH_FILL */
  71830. static readonly STRETCH_FILL: number;
  71831. /** STRETCH_UNIFORM */
  71832. static readonly STRETCH_UNIFORM: number;
  71833. /** STRETCH_EXTEND */
  71834. static readonly STRETCH_EXTEND: number;
  71835. /** NINE_PATCH */
  71836. static readonly STRETCH_NINE_PATCH: number;
  71837. }
  71838. }
  71839. declare module BABYLON.GUI {
  71840. /**
  71841. * Class used to create 2D buttons
  71842. */
  71843. export class Button extends Rectangle {
  71844. name?: string | undefined;
  71845. /**
  71846. * Function called to generate a pointer enter animation
  71847. */
  71848. pointerEnterAnimation: () => void;
  71849. /**
  71850. * Function called to generate a pointer out animation
  71851. */
  71852. pointerOutAnimation: () => void;
  71853. /**
  71854. * Function called to generate a pointer down animation
  71855. */
  71856. pointerDownAnimation: () => void;
  71857. /**
  71858. * Function called to generate a pointer up animation
  71859. */
  71860. pointerUpAnimation: () => void;
  71861. /**
  71862. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71863. */
  71864. delegatePickingToChildren: boolean;
  71865. private _image;
  71866. /**
  71867. * Returns the image part of the button (if any)
  71868. */
  71869. get image(): BABYLON.Nullable<Image>;
  71870. private _textBlock;
  71871. /**
  71872. * Returns the image part of the button (if any)
  71873. */
  71874. get textBlock(): BABYLON.Nullable<TextBlock>;
  71875. /**
  71876. * Creates a new Button
  71877. * @param name defines the name of the button
  71878. */
  71879. constructor(name?: string | undefined);
  71880. protected _getTypeName(): string;
  71881. /** @hidden */
  71882. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71883. /** @hidden */
  71884. _onPointerEnter(target: Control): boolean;
  71885. /** @hidden */
  71886. _onPointerOut(target: Control, force?: boolean): void;
  71887. /** @hidden */
  71888. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71889. /** @hidden */
  71890. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71891. /**
  71892. * Creates a new button made with an image and a text
  71893. * @param name defines the name of the button
  71894. * @param text defines the text of the button
  71895. * @param imageUrl defines the url of the image
  71896. * @returns a new Button
  71897. */
  71898. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71899. /**
  71900. * Creates a new button made with an image
  71901. * @param name defines the name of the button
  71902. * @param imageUrl defines the url of the image
  71903. * @returns a new Button
  71904. */
  71905. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71906. /**
  71907. * Creates a new button made with a text
  71908. * @param name defines the name of the button
  71909. * @param text defines the text of the button
  71910. * @returns a new Button
  71911. */
  71912. static CreateSimpleButton(name: string, text: string): Button;
  71913. /**
  71914. * Creates a new button made with an image and a centered text
  71915. * @param name defines the name of the button
  71916. * @param text defines the text of the button
  71917. * @param imageUrl defines the url of the image
  71918. * @returns a new Button
  71919. */
  71920. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71921. }
  71922. }
  71923. declare module BABYLON.GUI {
  71924. /**
  71925. * Class used to create a 2D stack panel container
  71926. */
  71927. export class StackPanel extends Container {
  71928. name?: string | undefined;
  71929. private _isVertical;
  71930. private _manualWidth;
  71931. private _manualHeight;
  71932. private _doNotTrackManualChanges;
  71933. /**
  71934. * Gets or sets a boolean indicating that layou warnings should be ignored
  71935. */
  71936. ignoreLayoutWarnings: boolean;
  71937. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71938. get isVertical(): boolean;
  71939. set isVertical(value: boolean);
  71940. /**
  71941. * Gets or sets panel width.
  71942. * This value should not be set when in horizontal mode as it will be computed automatically
  71943. */
  71944. set width(value: string | number);
  71945. get width(): string | number;
  71946. /**
  71947. * Gets or sets panel height.
  71948. * This value should not be set when in vertical mode as it will be computed automatically
  71949. */
  71950. set height(value: string | number);
  71951. get height(): string | number;
  71952. /**
  71953. * Creates a new StackPanel
  71954. * @param name defines control name
  71955. */
  71956. constructor(name?: string | undefined);
  71957. protected _getTypeName(): string;
  71958. /** @hidden */
  71959. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71960. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71961. protected _postMeasure(): void;
  71962. }
  71963. }
  71964. declare module BABYLON.GUI {
  71965. /**
  71966. * Class used to represent a 2D checkbox
  71967. */
  71968. export class Checkbox extends Control {
  71969. name?: string | undefined;
  71970. private _isChecked;
  71971. private _background;
  71972. private _checkSizeRatio;
  71973. private _thickness;
  71974. /** Gets or sets border thickness */
  71975. get thickness(): number;
  71976. set thickness(value: number);
  71977. /**
  71978. * BABYLON.Observable raised when isChecked property changes
  71979. */
  71980. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71981. /** Gets or sets a value indicating the ratio between overall size and check size */
  71982. get checkSizeRatio(): number;
  71983. set checkSizeRatio(value: number);
  71984. /** Gets or sets background color */
  71985. get background(): string;
  71986. set background(value: string);
  71987. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71988. get isChecked(): boolean;
  71989. set isChecked(value: boolean);
  71990. /**
  71991. * Creates a new CheckBox
  71992. * @param name defines the control name
  71993. */
  71994. constructor(name?: string | undefined);
  71995. protected _getTypeName(): string;
  71996. /** @hidden */
  71997. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71998. /** @hidden */
  71999. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72000. /**
  72001. * Utility function to easily create a checkbox with a header
  72002. * @param title defines the label to use for the header
  72003. * @param onValueChanged defines the callback to call when value changes
  72004. * @returns a StackPanel containing the checkbox and a textBlock
  72005. */
  72006. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72007. }
  72008. }
  72009. declare module BABYLON.GUI {
  72010. /**
  72011. * Class used to store key control properties
  72012. */
  72013. export class KeyPropertySet {
  72014. /** Width */
  72015. width?: string;
  72016. /** Height */
  72017. height?: string;
  72018. /** Left padding */
  72019. paddingLeft?: string;
  72020. /** Right padding */
  72021. paddingRight?: string;
  72022. /** Top padding */
  72023. paddingTop?: string;
  72024. /** Bottom padding */
  72025. paddingBottom?: string;
  72026. /** Foreground color */
  72027. color?: string;
  72028. /** Background color */
  72029. background?: string;
  72030. }
  72031. /**
  72032. * Class used to create virtual keyboard
  72033. */
  72034. export class VirtualKeyboard extends StackPanel {
  72035. /** BABYLON.Observable raised when a key is pressed */
  72036. onKeyPressObservable: BABYLON.Observable<string>;
  72037. /** Gets or sets default key button width */
  72038. defaultButtonWidth: string;
  72039. /** Gets or sets default key button height */
  72040. defaultButtonHeight: string;
  72041. /** Gets or sets default key button left padding */
  72042. defaultButtonPaddingLeft: string;
  72043. /** Gets or sets default key button right padding */
  72044. defaultButtonPaddingRight: string;
  72045. /** Gets or sets default key button top padding */
  72046. defaultButtonPaddingTop: string;
  72047. /** Gets or sets default key button bottom padding */
  72048. defaultButtonPaddingBottom: string;
  72049. /** Gets or sets default key button foreground color */
  72050. defaultButtonColor: string;
  72051. /** Gets or sets default key button background color */
  72052. defaultButtonBackground: string;
  72053. /** Gets or sets shift button foreground color */
  72054. shiftButtonColor: string;
  72055. /** Gets or sets shift button thickness*/
  72056. selectedShiftThickness: number;
  72057. /** Gets shift key state */
  72058. shiftState: number;
  72059. protected _getTypeName(): string;
  72060. private _createKey;
  72061. /**
  72062. * Adds a new row of keys
  72063. * @param keys defines the list of keys to add
  72064. * @param propertySets defines the associated property sets
  72065. */
  72066. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72067. /**
  72068. * Set the shift key to a specific state
  72069. * @param shiftState defines the new shift state
  72070. */
  72071. applyShiftState(shiftState: number): void;
  72072. private _currentlyConnectedInputText;
  72073. private _connectedInputTexts;
  72074. private _onKeyPressObserver;
  72075. /** Gets the input text control currently attached to the keyboard */
  72076. get connectedInputText(): BABYLON.Nullable<InputText>;
  72077. /**
  72078. * Connects the keyboard with an input text control
  72079. *
  72080. * @param input defines the target control
  72081. */
  72082. connect(input: InputText): void;
  72083. /**
  72084. * Disconnects the keyboard from connected InputText controls
  72085. *
  72086. * @param input optionally defines a target control, otherwise all are disconnected
  72087. */
  72088. disconnect(input?: InputText): void;
  72089. private _removeConnectedInputObservables;
  72090. /**
  72091. * Release all resources
  72092. */
  72093. dispose(): void;
  72094. /**
  72095. * Creates a new keyboard using a default layout
  72096. *
  72097. * @param name defines control name
  72098. * @returns a new VirtualKeyboard
  72099. */
  72100. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72101. }
  72102. }
  72103. declare module BABYLON.GUI {
  72104. /**
  72105. * Class used to create input text control
  72106. */
  72107. export class InputText extends Control implements IFocusableControl {
  72108. name?: string | undefined;
  72109. private _text;
  72110. private _placeholderText;
  72111. private _background;
  72112. private _focusedBackground;
  72113. private _focusedColor;
  72114. private _placeholderColor;
  72115. private _thickness;
  72116. private _margin;
  72117. private _autoStretchWidth;
  72118. private _maxWidth;
  72119. private _isFocused;
  72120. private _blinkTimeout;
  72121. private _blinkIsEven;
  72122. private _cursorOffset;
  72123. private _scrollLeft;
  72124. private _textWidth;
  72125. private _clickedCoordinate;
  72126. private _deadKey;
  72127. private _addKey;
  72128. private _currentKey;
  72129. private _isTextHighlightOn;
  72130. private _textHighlightColor;
  72131. private _highligherOpacity;
  72132. private _highlightedText;
  72133. private _startHighlightIndex;
  72134. private _endHighlightIndex;
  72135. private _cursorIndex;
  72136. private _onFocusSelectAll;
  72137. private _isPointerDown;
  72138. private _onClipboardObserver;
  72139. private _onPointerDblTapObserver;
  72140. /** @hidden */
  72141. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72142. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72143. promptMessage: string;
  72144. /** Force disable prompt on mobile device */
  72145. disableMobilePrompt: boolean;
  72146. /** BABYLON.Observable raised when the text changes */
  72147. onTextChangedObservable: BABYLON.Observable<InputText>;
  72148. /** BABYLON.Observable raised just before an entered character is to be added */
  72149. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72150. /** BABYLON.Observable raised when the control gets the focus */
  72151. onFocusObservable: BABYLON.Observable<InputText>;
  72152. /** BABYLON.Observable raised when the control loses the focus */
  72153. onBlurObservable: BABYLON.Observable<InputText>;
  72154. /**Observable raised when the text is highlighted */
  72155. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72156. /**Observable raised when copy event is triggered */
  72157. onTextCopyObservable: BABYLON.Observable<InputText>;
  72158. /** BABYLON.Observable raised when cut event is triggered */
  72159. onTextCutObservable: BABYLON.Observable<InputText>;
  72160. /** BABYLON.Observable raised when paste event is triggered */
  72161. onTextPasteObservable: BABYLON.Observable<InputText>;
  72162. /** BABYLON.Observable raised when a key event was processed */
  72163. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72164. /** Gets or sets the maximum width allowed by the control */
  72165. get maxWidth(): string | number;
  72166. /** Gets the maximum width allowed by the control in pixels */
  72167. get maxWidthInPixels(): number;
  72168. set maxWidth(value: string | number);
  72169. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72170. get highligherOpacity(): number;
  72171. set highligherOpacity(value: number);
  72172. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72173. get onFocusSelectAll(): boolean;
  72174. set onFocusSelectAll(value: boolean);
  72175. /** Gets or sets the text hightlight color */
  72176. get textHighlightColor(): string;
  72177. set textHighlightColor(value: string);
  72178. /** Gets or sets control margin */
  72179. get margin(): string;
  72180. /** Gets control margin in pixels */
  72181. get marginInPixels(): number;
  72182. set margin(value: string);
  72183. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72184. get autoStretchWidth(): boolean;
  72185. set autoStretchWidth(value: boolean);
  72186. /** Gets or sets border thickness */
  72187. get thickness(): number;
  72188. set thickness(value: number);
  72189. /** Gets or sets the background color when focused */
  72190. get focusedBackground(): string;
  72191. set focusedBackground(value: string);
  72192. /** Gets or sets the background color when focused */
  72193. get focusedColor(): string;
  72194. set focusedColor(value: string);
  72195. /** Gets or sets the background color */
  72196. get background(): string;
  72197. set background(value: string);
  72198. /** Gets or sets the placeholder color */
  72199. get placeholderColor(): string;
  72200. set placeholderColor(value: string);
  72201. /** Gets or sets the text displayed when the control is empty */
  72202. get placeholderText(): string;
  72203. set placeholderText(value: string);
  72204. /** Gets or sets the dead key flag */
  72205. get deadKey(): boolean;
  72206. set deadKey(flag: boolean);
  72207. /** Gets or sets the highlight text */
  72208. get highlightedText(): string;
  72209. set highlightedText(text: string);
  72210. /** Gets or sets if the current key should be added */
  72211. get addKey(): boolean;
  72212. set addKey(flag: boolean);
  72213. /** Gets or sets the value of the current key being entered */
  72214. get currentKey(): string;
  72215. set currentKey(key: string);
  72216. /** Gets or sets the text displayed in the control */
  72217. get text(): string;
  72218. set text(value: string);
  72219. /** Gets or sets control width */
  72220. get width(): string | number;
  72221. set width(value: string | number);
  72222. /**
  72223. * Creates a new InputText
  72224. * @param name defines the control name
  72225. * @param text defines the text of the control
  72226. */
  72227. constructor(name?: string | undefined, text?: string);
  72228. /** @hidden */
  72229. onBlur(): void;
  72230. /** @hidden */
  72231. onFocus(): void;
  72232. protected _getTypeName(): string;
  72233. /**
  72234. * Function called to get the list of controls that should not steal the focus from this control
  72235. * @returns an array of controls
  72236. */
  72237. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72238. /** @hidden */
  72239. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72240. /** @hidden */
  72241. private _updateValueFromCursorIndex;
  72242. /** @hidden */
  72243. private _processDblClick;
  72244. /** @hidden */
  72245. private _selectAllText;
  72246. /**
  72247. * Handles the keyboard event
  72248. * @param evt Defines the KeyboardEvent
  72249. */
  72250. processKeyboard(evt: KeyboardEvent): void;
  72251. /** @hidden */
  72252. private _onCopyText;
  72253. /** @hidden */
  72254. private _onCutText;
  72255. /** @hidden */
  72256. private _onPasteText;
  72257. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72258. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72259. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72260. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72261. protected _beforeRenderText(text: string): string;
  72262. dispose(): void;
  72263. }
  72264. }
  72265. declare module BABYLON.GUI {
  72266. /**
  72267. * Class used to create a 2D grid container
  72268. */
  72269. export class Grid extends Container {
  72270. name?: string | undefined;
  72271. private _rowDefinitions;
  72272. private _columnDefinitions;
  72273. private _cells;
  72274. private _childControls;
  72275. /**
  72276. * Gets the number of columns
  72277. */
  72278. get columnCount(): number;
  72279. /**
  72280. * Gets the number of rows
  72281. */
  72282. get rowCount(): number;
  72283. /** Gets the list of children */
  72284. get children(): Control[];
  72285. /** Gets the list of cells (e.g. the containers) */
  72286. get cells(): {
  72287. [key: string]: Container;
  72288. };
  72289. /**
  72290. * Gets the definition of a specific row
  72291. * @param index defines the index of the row
  72292. * @returns the row definition
  72293. */
  72294. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72295. /**
  72296. * Gets the definition of a specific column
  72297. * @param index defines the index of the column
  72298. * @returns the column definition
  72299. */
  72300. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72301. /**
  72302. * Adds a new row to the grid
  72303. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72304. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72305. * @returns the current grid
  72306. */
  72307. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72308. /**
  72309. * Adds a new column to the grid
  72310. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72311. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72312. * @returns the current grid
  72313. */
  72314. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72315. /**
  72316. * Update a row definition
  72317. * @param index defines the index of the row to update
  72318. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72319. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72320. * @returns the current grid
  72321. */
  72322. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72323. /**
  72324. * Update a column definition
  72325. * @param index defines the index of the column to update
  72326. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72327. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72328. * @returns the current grid
  72329. */
  72330. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72331. /**
  72332. * Gets the list of children stored in a specific cell
  72333. * @param row defines the row to check
  72334. * @param column defines the column to check
  72335. * @returns the list of controls
  72336. */
  72337. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72338. /**
  72339. * Gets a string representing the child cell info (row x column)
  72340. * @param child defines the control to get info from
  72341. * @returns a string containing the child cell info (row x column)
  72342. */
  72343. getChildCellInfo(child: Control): string;
  72344. private _removeCell;
  72345. private _offsetCell;
  72346. /**
  72347. * Remove a column definition at specified index
  72348. * @param index defines the index of the column to remove
  72349. * @returns the current grid
  72350. */
  72351. removeColumnDefinition(index: number): Grid;
  72352. /**
  72353. * Remove a row definition at specified index
  72354. * @param index defines the index of the row to remove
  72355. * @returns the current grid
  72356. */
  72357. removeRowDefinition(index: number): Grid;
  72358. /**
  72359. * Adds a new control to the current grid
  72360. * @param control defines the control to add
  72361. * @param row defines the row where to add the control (0 by default)
  72362. * @param column defines the column where to add the control (0 by default)
  72363. * @returns the current grid
  72364. */
  72365. addControl(control: Control, row?: number, column?: number): Grid;
  72366. /**
  72367. * Removes a control from the current container
  72368. * @param control defines the control to remove
  72369. * @returns the current container
  72370. */
  72371. removeControl(control: Control): Container;
  72372. /**
  72373. * Creates a new Grid
  72374. * @param name defines control name
  72375. */
  72376. constructor(name?: string | undefined);
  72377. protected _getTypeName(): string;
  72378. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72379. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72380. _flagDescendantsAsMatrixDirty(): void;
  72381. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72382. /** Releases associated resources */
  72383. dispose(): void;
  72384. }
  72385. }
  72386. declare module BABYLON.GUI {
  72387. /** Class used to create color pickers */
  72388. export class ColorPicker extends Control {
  72389. name?: string | undefined;
  72390. private static _Epsilon;
  72391. private _colorWheelCanvas;
  72392. private _value;
  72393. private _tmpColor;
  72394. private _pointerStartedOnSquare;
  72395. private _pointerStartedOnWheel;
  72396. private _squareLeft;
  72397. private _squareTop;
  72398. private _squareSize;
  72399. private _h;
  72400. private _s;
  72401. private _v;
  72402. private _lastPointerDownID;
  72403. /**
  72404. * BABYLON.Observable raised when the value changes
  72405. */
  72406. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72407. /** Gets or sets the color of the color picker */
  72408. get value(): BABYLON.Color3;
  72409. set value(value: BABYLON.Color3);
  72410. /**
  72411. * Gets or sets control width
  72412. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72413. */
  72414. get width(): string | number;
  72415. set width(value: string | number);
  72416. /**
  72417. * Gets or sets control height
  72418. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72419. */
  72420. get height(): string | number;
  72421. /** Gets or sets control height */
  72422. set height(value: string | number);
  72423. /** Gets or sets control size */
  72424. get size(): string | number;
  72425. set size(value: string | number);
  72426. /**
  72427. * Creates a new ColorPicker
  72428. * @param name defines the control name
  72429. */
  72430. constructor(name?: string | undefined);
  72431. protected _getTypeName(): string;
  72432. /** @hidden */
  72433. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72434. private _updateSquareProps;
  72435. private _drawGradientSquare;
  72436. private _drawCircle;
  72437. private _createColorWheelCanvas;
  72438. /** @hidden */
  72439. _draw(context: CanvasRenderingContext2D): void;
  72440. private _pointerIsDown;
  72441. private _updateValueFromPointer;
  72442. private _isPointOnSquare;
  72443. private _isPointOnWheel;
  72444. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72445. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72446. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72447. /**
  72448. * This function expands the color picker by creating a color picker dialog with manual
  72449. * color value input and the ability to save colors into an array to be used later in
  72450. * subsequent launches of the dialogue.
  72451. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72452. * @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.
  72453. * @returns picked color as a hex string and the saved colors array as hex strings.
  72454. */
  72455. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72456. pickerWidth?: string;
  72457. pickerHeight?: string;
  72458. headerHeight?: string;
  72459. lastColor?: string;
  72460. swatchLimit?: number;
  72461. numSwatchesPerLine?: number;
  72462. savedColors?: Array<string>;
  72463. }): Promise<{
  72464. savedColors?: string[];
  72465. pickedColor: string;
  72466. }>;
  72467. }
  72468. }
  72469. declare module BABYLON.GUI {
  72470. /** Class used to create 2D ellipse containers */
  72471. export class Ellipse extends Container {
  72472. name?: string | undefined;
  72473. private _thickness;
  72474. /** Gets or sets border thickness */
  72475. get thickness(): number;
  72476. set thickness(value: number);
  72477. /**
  72478. * Creates a new Ellipse
  72479. * @param name defines the control name
  72480. */
  72481. constructor(name?: string | undefined);
  72482. protected _getTypeName(): string;
  72483. protected _localDraw(context: CanvasRenderingContext2D): void;
  72484. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72485. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72486. }
  72487. }
  72488. declare module BABYLON.GUI {
  72489. /**
  72490. * Class used to create a password control
  72491. */
  72492. export class InputPassword extends InputText {
  72493. protected _beforeRenderText(text: string): string;
  72494. }
  72495. }
  72496. declare module BABYLON.GUI {
  72497. /** Class used to render 2D lines */
  72498. export class Line extends Control {
  72499. name?: string | undefined;
  72500. private _lineWidth;
  72501. private _x1;
  72502. private _y1;
  72503. private _x2;
  72504. private _y2;
  72505. private _dash;
  72506. private _connectedControl;
  72507. private _connectedControlDirtyObserver;
  72508. /** Gets or sets the dash pattern */
  72509. get dash(): Array<number>;
  72510. set dash(value: Array<number>);
  72511. /** Gets or sets the control connected with the line end */
  72512. get connectedControl(): Control;
  72513. set connectedControl(value: Control);
  72514. /** Gets or sets start coordinates on X axis */
  72515. get x1(): string | number;
  72516. set x1(value: string | number);
  72517. /** Gets or sets start coordinates on Y axis */
  72518. get y1(): string | number;
  72519. set y1(value: string | number);
  72520. /** Gets or sets end coordinates on X axis */
  72521. get x2(): string | number;
  72522. set x2(value: string | number);
  72523. /** Gets or sets end coordinates on Y axis */
  72524. get y2(): string | number;
  72525. set y2(value: string | number);
  72526. /** Gets or sets line width */
  72527. get lineWidth(): number;
  72528. set lineWidth(value: number);
  72529. /** Gets or sets horizontal alignment */
  72530. set horizontalAlignment(value: number);
  72531. /** Gets or sets vertical alignment */
  72532. set verticalAlignment(value: number);
  72533. private get _effectiveX2();
  72534. private get _effectiveY2();
  72535. /**
  72536. * Creates a new Line
  72537. * @param name defines the control name
  72538. */
  72539. constructor(name?: string | undefined);
  72540. protected _getTypeName(): string;
  72541. _draw(context: CanvasRenderingContext2D): void;
  72542. _measure(): void;
  72543. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72544. /**
  72545. * Move one end of the line given 3D cartesian coordinates.
  72546. * @param position Targeted world position
  72547. * @param scene BABYLON.Scene
  72548. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72549. */
  72550. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72551. /**
  72552. * Move one end of the line to a position in screen absolute space.
  72553. * @param projectedPosition Position in screen absolute space (X, Y)
  72554. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72555. */
  72556. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72557. }
  72558. }
  72559. declare module BABYLON.GUI {
  72560. /**
  72561. * Class used to store a point for a MultiLine object.
  72562. * The point can be pure 2D coordinates, a mesh or a control
  72563. */
  72564. export class MultiLinePoint {
  72565. private _multiLine;
  72566. private _x;
  72567. private _y;
  72568. private _control;
  72569. private _mesh;
  72570. private _controlObserver;
  72571. private _meshObserver;
  72572. /** @hidden */
  72573. _point: BABYLON.Vector2;
  72574. /**
  72575. * Creates a new MultiLinePoint
  72576. * @param multiLine defines the source MultiLine object
  72577. */
  72578. constructor(multiLine: MultiLine);
  72579. /** Gets or sets x coordinate */
  72580. get x(): string | number;
  72581. set x(value: string | number);
  72582. /** Gets or sets y coordinate */
  72583. get y(): string | number;
  72584. set y(value: string | number);
  72585. /** Gets or sets the control associated with this point */
  72586. get control(): BABYLON.Nullable<Control>;
  72587. set control(value: BABYLON.Nullable<Control>);
  72588. /** Gets or sets the mesh associated with this point */
  72589. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72590. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72591. /** Resets links */
  72592. resetLinks(): void;
  72593. /**
  72594. * Gets a translation vector
  72595. * @returns the translation vector
  72596. */
  72597. translate(): BABYLON.Vector2;
  72598. private _translatePoint;
  72599. /** Release associated resources */
  72600. dispose(): void;
  72601. }
  72602. }
  72603. declare module BABYLON.GUI {
  72604. /**
  72605. * Class used to create multi line control
  72606. */
  72607. export class MultiLine extends Control {
  72608. name?: string | undefined;
  72609. private _lineWidth;
  72610. private _dash;
  72611. private _points;
  72612. private _minX;
  72613. private _minY;
  72614. private _maxX;
  72615. private _maxY;
  72616. /**
  72617. * Creates a new MultiLine
  72618. * @param name defines the control name
  72619. */
  72620. constructor(name?: string | undefined);
  72621. /** Gets or sets dash pattern */
  72622. get dash(): Array<number>;
  72623. set dash(value: Array<number>);
  72624. /**
  72625. * Gets point stored at specified index
  72626. * @param index defines the index to look for
  72627. * @returns the requested point if found
  72628. */
  72629. getAt(index: number): MultiLinePoint;
  72630. /** Function called when a point is updated */
  72631. onPointUpdate: () => void;
  72632. /**
  72633. * Adds new points to the point collection
  72634. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72635. * @returns the list of created MultiLinePoint
  72636. */
  72637. add(...items: (AbstractMesh | Control | {
  72638. x: string | number;
  72639. y: string | number;
  72640. })[]): MultiLinePoint[];
  72641. /**
  72642. * Adds a new point to the point collection
  72643. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72644. * @returns the created MultiLinePoint
  72645. */
  72646. push(item?: (AbstractMesh | Control | {
  72647. x: string | number;
  72648. y: string | number;
  72649. })): MultiLinePoint;
  72650. /**
  72651. * Remove a specific value or point from the active point collection
  72652. * @param value defines the value or point to remove
  72653. */
  72654. remove(value: number | MultiLinePoint): void;
  72655. /**
  72656. * Resets this object to initial state (no point)
  72657. */
  72658. reset(): void;
  72659. /**
  72660. * Resets all links
  72661. */
  72662. resetLinks(): void;
  72663. /** Gets or sets line width */
  72664. get lineWidth(): number;
  72665. set lineWidth(value: number);
  72666. set horizontalAlignment(value: number);
  72667. set verticalAlignment(value: number);
  72668. protected _getTypeName(): string;
  72669. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72670. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72671. _measure(): void;
  72672. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72673. dispose(): void;
  72674. }
  72675. }
  72676. declare module BABYLON.GUI {
  72677. /**
  72678. * Class used to create radio button controls
  72679. */
  72680. export class RadioButton extends Control {
  72681. name?: string | undefined;
  72682. private _isChecked;
  72683. private _background;
  72684. private _checkSizeRatio;
  72685. private _thickness;
  72686. /** Gets or sets border thickness */
  72687. get thickness(): number;
  72688. set thickness(value: number);
  72689. /** Gets or sets group name */
  72690. group: string;
  72691. /** BABYLON.Observable raised when isChecked is changed */
  72692. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72693. /** Gets or sets a value indicating the ratio between overall size and check size */
  72694. get checkSizeRatio(): number;
  72695. set checkSizeRatio(value: number);
  72696. /** Gets or sets background color */
  72697. get background(): string;
  72698. set background(value: string);
  72699. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72700. get isChecked(): boolean;
  72701. set isChecked(value: boolean);
  72702. /**
  72703. * Creates a new RadioButton
  72704. * @param name defines the control name
  72705. */
  72706. constructor(name?: string | undefined);
  72707. protected _getTypeName(): string;
  72708. _draw(context: CanvasRenderingContext2D): void;
  72709. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72710. /**
  72711. * Utility function to easily create a radio button with a header
  72712. * @param title defines the label to use for the header
  72713. * @param group defines the group to use for the radio button
  72714. * @param isChecked defines the initial state of the radio button
  72715. * @param onValueChanged defines the callback to call when value changes
  72716. * @returns a StackPanel containing the radio button and a textBlock
  72717. */
  72718. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72719. }
  72720. }
  72721. declare module BABYLON.GUI {
  72722. /**
  72723. * Class used to create slider controls
  72724. */
  72725. export class BaseSlider extends Control {
  72726. name?: string | undefined;
  72727. protected _thumbWidth: ValueAndUnit;
  72728. private _minimum;
  72729. private _maximum;
  72730. private _value;
  72731. private _isVertical;
  72732. protected _barOffset: ValueAndUnit;
  72733. private _isThumbClamped;
  72734. protected _displayThumb: boolean;
  72735. private _step;
  72736. private _lastPointerDownID;
  72737. protected _effectiveBarOffset: number;
  72738. protected _renderLeft: number;
  72739. protected _renderTop: number;
  72740. protected _renderWidth: number;
  72741. protected _renderHeight: number;
  72742. protected _backgroundBoxLength: number;
  72743. protected _backgroundBoxThickness: number;
  72744. protected _effectiveThumbThickness: number;
  72745. /** BABYLON.Observable raised when the sldier value changes */
  72746. onValueChangedObservable: BABYLON.Observable<number>;
  72747. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72748. get displayThumb(): boolean;
  72749. set displayThumb(value: boolean);
  72750. /** Gets or sets a step to apply to values (0 by default) */
  72751. get step(): number;
  72752. set step(value: number);
  72753. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72754. get barOffset(): string | number;
  72755. /** Gets main bar offset in pixels*/
  72756. get barOffsetInPixels(): number;
  72757. set barOffset(value: string | number);
  72758. /** Gets or sets thumb width */
  72759. get thumbWidth(): string | number;
  72760. /** Gets thumb width in pixels */
  72761. get thumbWidthInPixels(): number;
  72762. set thumbWidth(value: string | number);
  72763. /** Gets or sets minimum value */
  72764. get minimum(): number;
  72765. set minimum(value: number);
  72766. /** Gets or sets maximum value */
  72767. get maximum(): number;
  72768. set maximum(value: number);
  72769. /** Gets or sets current value */
  72770. get value(): number;
  72771. set value(value: number);
  72772. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72773. get isVertical(): boolean;
  72774. set isVertical(value: boolean);
  72775. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72776. get isThumbClamped(): boolean;
  72777. set isThumbClamped(value: boolean);
  72778. /**
  72779. * Creates a new BaseSlider
  72780. * @param name defines the control name
  72781. */
  72782. constructor(name?: string | undefined);
  72783. protected _getTypeName(): string;
  72784. protected _getThumbPosition(): number;
  72785. protected _getThumbThickness(type: string): number;
  72786. protected _prepareRenderingData(type: string): void;
  72787. private _pointerIsDown;
  72788. /** @hidden */
  72789. protected _updateValueFromPointer(x: number, y: number): void;
  72790. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72791. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72792. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72793. }
  72794. }
  72795. declare module BABYLON.GUI {
  72796. /**
  72797. * Class used to create slider controls
  72798. */
  72799. export class Slider extends BaseSlider {
  72800. name?: string | undefined;
  72801. private _background;
  72802. private _borderColor;
  72803. private _isThumbCircle;
  72804. protected _displayValueBar: boolean;
  72805. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72806. get displayValueBar(): boolean;
  72807. set displayValueBar(value: boolean);
  72808. /** Gets or sets border color */
  72809. get borderColor(): string;
  72810. set borderColor(value: string);
  72811. /** Gets or sets background color */
  72812. get background(): string;
  72813. set background(value: string);
  72814. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72815. get isThumbCircle(): boolean;
  72816. set isThumbCircle(value: boolean);
  72817. /**
  72818. * Creates a new Slider
  72819. * @param name defines the control name
  72820. */
  72821. constructor(name?: string | undefined);
  72822. protected _getTypeName(): string;
  72823. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72824. }
  72825. }
  72826. declare module BABYLON.GUI {
  72827. /** Class used to create a RadioGroup
  72828. * which contains groups of radio buttons
  72829. */
  72830. export class SelectorGroup {
  72831. /** name of SelectorGroup */
  72832. name: string;
  72833. private _groupPanel;
  72834. private _selectors;
  72835. private _groupHeader;
  72836. /**
  72837. * Creates a new SelectorGroup
  72838. * @param name of group, used as a group heading
  72839. */
  72840. constructor(
  72841. /** name of SelectorGroup */
  72842. name: string);
  72843. /** Gets the groupPanel of the SelectorGroup */
  72844. get groupPanel(): StackPanel;
  72845. /** Gets the selectors array */
  72846. get selectors(): StackPanel[];
  72847. /** Gets and sets the group header */
  72848. get header(): string;
  72849. set header(label: string);
  72850. /** @hidden */
  72851. private _addGroupHeader;
  72852. /** @hidden*/
  72853. _getSelector(selectorNb: number): StackPanel | undefined;
  72854. /** Removes the selector at the given position
  72855. * @param selectorNb the position of the selector within the group
  72856. */
  72857. removeSelector(selectorNb: number): void;
  72858. }
  72859. /** Class used to create a CheckboxGroup
  72860. * which contains groups of checkbox buttons
  72861. */
  72862. export class CheckboxGroup extends SelectorGroup {
  72863. /** Adds a checkbox as a control
  72864. * @param text is the label for the selector
  72865. * @param func is the function called when the Selector is checked
  72866. * @param checked is true when Selector is checked
  72867. */
  72868. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72869. /** @hidden */
  72870. _setSelectorLabel(selectorNb: number, label: string): void;
  72871. /** @hidden */
  72872. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72873. /** @hidden */
  72874. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72875. /** @hidden */
  72876. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72877. }
  72878. /** Class used to create a RadioGroup
  72879. * which contains groups of radio buttons
  72880. */
  72881. export class RadioGroup extends SelectorGroup {
  72882. private _selectNb;
  72883. /** Adds a radio button as a control
  72884. * @param label is the label for the selector
  72885. * @param func is the function called when the Selector is checked
  72886. * @param checked is true when Selector is checked
  72887. */
  72888. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72889. /** @hidden */
  72890. _setSelectorLabel(selectorNb: number, label: string): void;
  72891. /** @hidden */
  72892. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72893. /** @hidden */
  72894. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72895. /** @hidden */
  72896. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72897. }
  72898. /** Class used to create a SliderGroup
  72899. * which contains groups of slider buttons
  72900. */
  72901. export class SliderGroup extends SelectorGroup {
  72902. /**
  72903. * Adds a slider to the SelectorGroup
  72904. * @param label is the label for the SliderBar
  72905. * @param func is the function called when the Slider moves
  72906. * @param unit is a string describing the units used, eg degrees or metres
  72907. * @param min is the minimum value for the Slider
  72908. * @param max is the maximum value for the Slider
  72909. * @param value is the start value for the Slider between min and max
  72910. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72911. */
  72912. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72913. /** @hidden */
  72914. _setSelectorLabel(selectorNb: number, label: string): void;
  72915. /** @hidden */
  72916. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72917. /** @hidden */
  72918. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72919. /** @hidden */
  72920. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72921. }
  72922. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72923. * @see http://doc.babylonjs.com/how_to/selector
  72924. */
  72925. export class SelectionPanel extends Rectangle {
  72926. /** name of SelectionPanel */
  72927. name: string;
  72928. /** an array of SelectionGroups */
  72929. groups: SelectorGroup[];
  72930. private _panel;
  72931. private _buttonColor;
  72932. private _buttonBackground;
  72933. private _headerColor;
  72934. private _barColor;
  72935. private _barHeight;
  72936. private _spacerHeight;
  72937. private _labelColor;
  72938. private _groups;
  72939. private _bars;
  72940. /**
  72941. * Creates a new SelectionPanel
  72942. * @param name of SelectionPanel
  72943. * @param groups is an array of SelectionGroups
  72944. */
  72945. constructor(
  72946. /** name of SelectionPanel */
  72947. name: string,
  72948. /** an array of SelectionGroups */
  72949. groups?: SelectorGroup[]);
  72950. protected _getTypeName(): string;
  72951. /** Gets or sets the headerColor */
  72952. get headerColor(): string;
  72953. set headerColor(color: string);
  72954. private _setHeaderColor;
  72955. /** Gets or sets the button color */
  72956. get buttonColor(): string;
  72957. set buttonColor(color: string);
  72958. private _setbuttonColor;
  72959. /** Gets or sets the label color */
  72960. get labelColor(): string;
  72961. set labelColor(color: string);
  72962. private _setLabelColor;
  72963. /** Gets or sets the button background */
  72964. get buttonBackground(): string;
  72965. set buttonBackground(color: string);
  72966. private _setButtonBackground;
  72967. /** Gets or sets the color of separator bar */
  72968. get barColor(): string;
  72969. set barColor(color: string);
  72970. private _setBarColor;
  72971. /** Gets or sets the height of separator bar */
  72972. get barHeight(): string;
  72973. set barHeight(value: string);
  72974. private _setBarHeight;
  72975. /** Gets or sets the height of spacers*/
  72976. get spacerHeight(): string;
  72977. set spacerHeight(value: string);
  72978. private _setSpacerHeight;
  72979. /** Adds a bar between groups */
  72980. private _addSpacer;
  72981. /** Add a group to the selection panel
  72982. * @param group is the selector group to add
  72983. */
  72984. addGroup(group: SelectorGroup): void;
  72985. /** Remove the group from the given position
  72986. * @param groupNb is the position of the group in the list
  72987. */
  72988. removeGroup(groupNb: number): void;
  72989. /** Change a group header label
  72990. * @param label is the new group header label
  72991. * @param groupNb is the number of the group to relabel
  72992. * */
  72993. setHeaderName(label: string, groupNb: number): void;
  72994. /** Change selector label to the one given
  72995. * @param label is the new selector label
  72996. * @param groupNb is the number of the groupcontaining the selector
  72997. * @param selectorNb is the number of the selector within a group to relabel
  72998. * */
  72999. relabel(label: string, groupNb: number, selectorNb: number): void;
  73000. /** For a given group position remove the selector at the given position
  73001. * @param groupNb is the number of the group to remove the selector from
  73002. * @param selectorNb is the number of the selector within the group
  73003. */
  73004. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73005. /** For a given group position of correct type add a checkbox button
  73006. * @param groupNb is the number of the group to remove the selector from
  73007. * @param label is the label for the selector
  73008. * @param func is the function called when the Selector is checked
  73009. * @param checked is true when Selector is checked
  73010. */
  73011. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73012. /** For a given group position of correct type add a radio button
  73013. * @param groupNb is the number of the group to remove the selector from
  73014. * @param label is the label for the selector
  73015. * @param func is the function called when the Selector is checked
  73016. * @param checked is true when Selector is checked
  73017. */
  73018. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73019. /**
  73020. * For a given slider group add a slider
  73021. * @param groupNb is the number of the group to add the slider to
  73022. * @param label is the label for the Slider
  73023. * @param func is the function called when the Slider moves
  73024. * @param unit is a string describing the units used, eg degrees or metres
  73025. * @param min is the minimum value for the Slider
  73026. * @param max is the maximum value for the Slider
  73027. * @param value is the start value for the Slider between min and max
  73028. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73029. */
  73030. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73031. }
  73032. }
  73033. declare module BABYLON.GUI {
  73034. /**
  73035. * Class used to hold a the container for ScrollViewer
  73036. * @hidden
  73037. */
  73038. export class _ScrollViewerWindow extends Container {
  73039. parentClientWidth: number;
  73040. parentClientHeight: number;
  73041. private _freezeControls;
  73042. private _parentMeasure;
  73043. private _oldLeft;
  73044. private _oldTop;
  73045. get freezeControls(): boolean;
  73046. set freezeControls(value: boolean);
  73047. private _bucketWidth;
  73048. private _bucketHeight;
  73049. private _buckets;
  73050. private _bucketLen;
  73051. get bucketWidth(): number;
  73052. get bucketHeight(): number;
  73053. setBucketSizes(width: number, height: number): void;
  73054. private _useBuckets;
  73055. private _makeBuckets;
  73056. private _dispatchInBuckets;
  73057. private _updateMeasures;
  73058. private _updateChildrenMeasures;
  73059. /**
  73060. * Creates a new ScrollViewerWindow
  73061. * @param name of ScrollViewerWindow
  73062. */
  73063. constructor(name?: string);
  73064. protected _getTypeName(): string;
  73065. /** @hidden */
  73066. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73067. /** @hidden */
  73068. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73069. private _scrollChildren;
  73070. private _scrollChildrenWithBuckets;
  73071. /** @hidden */
  73072. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73073. protected _postMeasure(): void;
  73074. }
  73075. }
  73076. declare module BABYLON.GUI {
  73077. /**
  73078. * Class used to create slider controls
  73079. */
  73080. export class ScrollBar extends BaseSlider {
  73081. name?: string | undefined;
  73082. private _background;
  73083. private _borderColor;
  73084. private _tempMeasure;
  73085. /** Gets or sets border color */
  73086. get borderColor(): string;
  73087. set borderColor(value: string);
  73088. /** Gets or sets background color */
  73089. get background(): string;
  73090. set background(value: string);
  73091. /**
  73092. * Creates a new Slider
  73093. * @param name defines the control name
  73094. */
  73095. constructor(name?: string | undefined);
  73096. protected _getTypeName(): string;
  73097. protected _getThumbThickness(): number;
  73098. _draw(context: CanvasRenderingContext2D): void;
  73099. private _first;
  73100. private _originX;
  73101. private _originY;
  73102. /** @hidden */
  73103. protected _updateValueFromPointer(x: number, y: number): void;
  73104. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73105. }
  73106. }
  73107. declare module BABYLON.GUI {
  73108. /**
  73109. * Class used to create slider controls
  73110. */
  73111. export class ImageScrollBar extends BaseSlider {
  73112. name?: string | undefined;
  73113. private _backgroundBaseImage;
  73114. private _backgroundImage;
  73115. private _thumbImage;
  73116. private _thumbBaseImage;
  73117. private _thumbLength;
  73118. private _thumbHeight;
  73119. private _barImageHeight;
  73120. private _tempMeasure;
  73121. /** Number of 90° rotation to apply on the images when in vertical mode */
  73122. num90RotationInVerticalMode: number;
  73123. /**
  73124. * Gets or sets the image used to render the background for horizontal bar
  73125. */
  73126. get backgroundImage(): Image;
  73127. set backgroundImage(value: Image);
  73128. /**
  73129. * Gets or sets the image used to render the thumb
  73130. */
  73131. get thumbImage(): Image;
  73132. set thumbImage(value: Image);
  73133. /**
  73134. * Gets or sets the length of the thumb
  73135. */
  73136. get thumbLength(): number;
  73137. set thumbLength(value: number);
  73138. /**
  73139. * Gets or sets the height of the thumb
  73140. */
  73141. get thumbHeight(): number;
  73142. set thumbHeight(value: number);
  73143. /**
  73144. * Gets or sets the height of the bar image
  73145. */
  73146. get barImageHeight(): number;
  73147. set barImageHeight(value: number);
  73148. /**
  73149. * Creates a new ImageScrollBar
  73150. * @param name defines the control name
  73151. */
  73152. constructor(name?: string | undefined);
  73153. protected _getTypeName(): string;
  73154. protected _getThumbThickness(): number;
  73155. _draw(context: CanvasRenderingContext2D): void;
  73156. private _first;
  73157. private _originX;
  73158. private _originY;
  73159. /** @hidden */
  73160. protected _updateValueFromPointer(x: number, y: number): void;
  73161. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73162. }
  73163. }
  73164. declare module BABYLON.GUI {
  73165. /**
  73166. * Class used to hold a viewer window and sliders in a grid
  73167. */
  73168. export class ScrollViewer extends Rectangle {
  73169. private _grid;
  73170. private _horizontalBarSpace;
  73171. private _verticalBarSpace;
  73172. private _dragSpace;
  73173. private _horizontalBar;
  73174. private _verticalBar;
  73175. private _barColor;
  73176. private _barBackground;
  73177. private _barImage;
  73178. private _horizontalBarImage;
  73179. private _verticalBarImage;
  73180. private _barBackgroundImage;
  73181. private _horizontalBarBackgroundImage;
  73182. private _verticalBarBackgroundImage;
  73183. private _barSize;
  73184. private _window;
  73185. private _pointerIsOver;
  73186. private _wheelPrecision;
  73187. private _onWheelObserver;
  73188. private _clientWidth;
  73189. private _clientHeight;
  73190. private _useImageBar;
  73191. private _thumbLength;
  73192. private _thumbHeight;
  73193. private _barImageHeight;
  73194. private _horizontalBarImageHeight;
  73195. private _verticalBarImageHeight;
  73196. /**
  73197. * Gets the horizontal scrollbar
  73198. */
  73199. get horizontalBar(): ScrollBar | ImageScrollBar;
  73200. /**
  73201. * Gets the vertical scrollbar
  73202. */
  73203. get verticalBar(): ScrollBar | ImageScrollBar;
  73204. /**
  73205. * Adds a new control to the current container
  73206. * @param control defines the control to add
  73207. * @returns the current container
  73208. */
  73209. addControl(control: BABYLON.Nullable<Control>): Container;
  73210. /**
  73211. * Removes a control from the current container
  73212. * @param control defines the control to remove
  73213. * @returns the current container
  73214. */
  73215. removeControl(control: Control): Container;
  73216. /** Gets the list of children */
  73217. get children(): Control[];
  73218. _flagDescendantsAsMatrixDirty(): void;
  73219. /**
  73220. * Freezes or unfreezes the controls in the window.
  73221. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73222. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73223. */
  73224. get freezeControls(): boolean;
  73225. set freezeControls(value: boolean);
  73226. /** Gets the bucket width */
  73227. get bucketWidth(): number;
  73228. /** Gets the bucket height */
  73229. get bucketHeight(): number;
  73230. /**
  73231. * Sets the bucket sizes.
  73232. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73233. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73234. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73235. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73236. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73237. * used), that's why it is not enabled by default.
  73238. * @param width width of the bucket
  73239. * @param height height of the bucket
  73240. */
  73241. setBucketSizes(width: number, height: number): void;
  73242. private _forceHorizontalBar;
  73243. private _forceVerticalBar;
  73244. /**
  73245. * Forces the horizontal scroll bar to be displayed
  73246. */
  73247. get forceHorizontalBar(): boolean;
  73248. set forceHorizontalBar(value: boolean);
  73249. /**
  73250. * Forces the vertical scroll bar to be displayed
  73251. */
  73252. get forceVerticalBar(): boolean;
  73253. set forceVerticalBar(value: boolean);
  73254. /**
  73255. * Creates a new ScrollViewer
  73256. * @param name of ScrollViewer
  73257. */
  73258. constructor(name?: string, isImageBased?: boolean);
  73259. /** Reset the scroll viewer window to initial size */
  73260. resetWindow(): void;
  73261. protected _getTypeName(): string;
  73262. private _buildClientSizes;
  73263. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73264. protected _postMeasure(): void;
  73265. /**
  73266. * Gets or sets the mouse wheel precision
  73267. * from 0 to 1 with a default value of 0.05
  73268. * */
  73269. get wheelPrecision(): number;
  73270. set wheelPrecision(value: number);
  73271. /** Gets or sets the scroll bar container background color */
  73272. get scrollBackground(): string;
  73273. set scrollBackground(color: string);
  73274. /** Gets or sets the bar color */
  73275. get barColor(): string;
  73276. set barColor(color: string);
  73277. /** Gets or sets the bar image */
  73278. get thumbImage(): Image;
  73279. set thumbImage(value: Image);
  73280. /** Gets or sets the horizontal bar image */
  73281. get horizontalThumbImage(): Image;
  73282. set horizontalThumbImage(value: Image);
  73283. /** Gets or sets the vertical bar image */
  73284. get verticalThumbImage(): Image;
  73285. set verticalThumbImage(value: Image);
  73286. /** Gets or sets the size of the bar */
  73287. get barSize(): number;
  73288. set barSize(value: number);
  73289. /** Gets or sets the length of the thumb */
  73290. get thumbLength(): number;
  73291. set thumbLength(value: number);
  73292. /** Gets or sets the height of the thumb */
  73293. get thumbHeight(): number;
  73294. set thumbHeight(value: number);
  73295. /** Gets or sets the height of the bar image */
  73296. get barImageHeight(): number;
  73297. set barImageHeight(value: number);
  73298. /** Gets or sets the height of the horizontal bar image */
  73299. get horizontalBarImageHeight(): number;
  73300. set horizontalBarImageHeight(value: number);
  73301. /** Gets or sets the height of the vertical bar image */
  73302. get verticalBarImageHeight(): number;
  73303. set verticalBarImageHeight(value: number);
  73304. /** Gets or sets the bar background */
  73305. get barBackground(): string;
  73306. set barBackground(color: string);
  73307. /** Gets or sets the bar background image */
  73308. get barImage(): Image;
  73309. set barImage(value: Image);
  73310. /** Gets or sets the horizontal bar background image */
  73311. get horizontalBarImage(): Image;
  73312. set horizontalBarImage(value: Image);
  73313. /** Gets or sets the vertical bar background image */
  73314. get verticalBarImage(): Image;
  73315. set verticalBarImage(value: Image);
  73316. private _setWindowPosition;
  73317. /** @hidden */
  73318. private _updateScroller;
  73319. _link(host: AdvancedDynamicTexture): void;
  73320. /** @hidden */
  73321. private _addBar;
  73322. /** @hidden */
  73323. private _attachWheel;
  73324. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73325. /** Releases associated resources */
  73326. dispose(): void;
  73327. }
  73328. }
  73329. declare module BABYLON.GUI {
  73330. /** Class used to render a grid */
  73331. export class DisplayGrid extends Control {
  73332. name?: string | undefined;
  73333. private _cellWidth;
  73334. private _cellHeight;
  73335. private _minorLineTickness;
  73336. private _minorLineColor;
  73337. private _majorLineTickness;
  73338. private _majorLineColor;
  73339. private _majorLineFrequency;
  73340. private _background;
  73341. private _displayMajorLines;
  73342. private _displayMinorLines;
  73343. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73344. get displayMinorLines(): boolean;
  73345. set displayMinorLines(value: boolean);
  73346. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73347. get displayMajorLines(): boolean;
  73348. set displayMajorLines(value: boolean);
  73349. /** Gets or sets background color (Black by default) */
  73350. get background(): string;
  73351. set background(value: string);
  73352. /** Gets or sets the width of each cell (20 by default) */
  73353. get cellWidth(): number;
  73354. set cellWidth(value: number);
  73355. /** Gets or sets the height of each cell (20 by default) */
  73356. get cellHeight(): number;
  73357. set cellHeight(value: number);
  73358. /** Gets or sets the tickness of minor lines (1 by default) */
  73359. get minorLineTickness(): number;
  73360. set minorLineTickness(value: number);
  73361. /** Gets or sets the color of minor lines (DarkGray by default) */
  73362. get minorLineColor(): string;
  73363. set minorLineColor(value: string);
  73364. /** Gets or sets the tickness of major lines (2 by default) */
  73365. get majorLineTickness(): number;
  73366. set majorLineTickness(value: number);
  73367. /** Gets or sets the color of major lines (White by default) */
  73368. get majorLineColor(): string;
  73369. set majorLineColor(value: string);
  73370. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73371. get majorLineFrequency(): number;
  73372. set majorLineFrequency(value: number);
  73373. /**
  73374. * Creates a new GridDisplayRectangle
  73375. * @param name defines the control name
  73376. */
  73377. constructor(name?: string | undefined);
  73378. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73379. protected _getTypeName(): string;
  73380. }
  73381. }
  73382. declare module BABYLON.GUI {
  73383. /**
  73384. * Class used to create slider controls based on images
  73385. */
  73386. export class ImageBasedSlider extends BaseSlider {
  73387. name?: string | undefined;
  73388. private _backgroundImage;
  73389. private _thumbImage;
  73390. private _valueBarImage;
  73391. private _tempMeasure;
  73392. get displayThumb(): boolean;
  73393. set displayThumb(value: boolean);
  73394. /**
  73395. * Gets or sets the image used to render the background
  73396. */
  73397. get backgroundImage(): Image;
  73398. set backgroundImage(value: Image);
  73399. /**
  73400. * Gets or sets the image used to render the value bar
  73401. */
  73402. get valueBarImage(): Image;
  73403. set valueBarImage(value: Image);
  73404. /**
  73405. * Gets or sets the image used to render the thumb
  73406. */
  73407. get thumbImage(): Image;
  73408. set thumbImage(value: Image);
  73409. /**
  73410. * Creates a new ImageBasedSlider
  73411. * @param name defines the control name
  73412. */
  73413. constructor(name?: string | undefined);
  73414. protected _getTypeName(): string;
  73415. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73416. }
  73417. }
  73418. declare module BABYLON.GUI {
  73419. /**
  73420. * Forcing an export so that this code will execute
  73421. * @hidden
  73422. */
  73423. const name = "Statics";
  73424. }
  73425. declare module BABYLON.GUI {
  73426. /**
  73427. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73428. */
  73429. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73430. /**
  73431. * Define the instrumented AdvancedDynamicTexture.
  73432. */
  73433. texture: AdvancedDynamicTexture;
  73434. private _captureRenderTime;
  73435. private _renderTime;
  73436. private _captureLayoutTime;
  73437. private _layoutTime;
  73438. private _onBeginRenderObserver;
  73439. private _onEndRenderObserver;
  73440. private _onBeginLayoutObserver;
  73441. private _onEndLayoutObserver;
  73442. /**
  73443. * Gets the perf counter used to capture render time
  73444. */
  73445. get renderTimeCounter(): BABYLON.PerfCounter;
  73446. /**
  73447. * Gets the perf counter used to capture layout time
  73448. */
  73449. get layoutTimeCounter(): BABYLON.PerfCounter;
  73450. /**
  73451. * Enable or disable the render time capture
  73452. */
  73453. get captureRenderTime(): boolean;
  73454. set captureRenderTime(value: boolean);
  73455. /**
  73456. * Enable or disable the layout time capture
  73457. */
  73458. get captureLayoutTime(): boolean;
  73459. set captureLayoutTime(value: boolean);
  73460. /**
  73461. * Instantiates a new advanced dynamic texture instrumentation.
  73462. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73463. * @param texture Defines the AdvancedDynamicTexture to instrument
  73464. */
  73465. constructor(
  73466. /**
  73467. * Define the instrumented AdvancedDynamicTexture.
  73468. */
  73469. texture: AdvancedDynamicTexture);
  73470. /**
  73471. * Dispose and release associated resources.
  73472. */
  73473. dispose(): void;
  73474. }
  73475. }
  73476. declare module BABYLON.GUI {
  73477. /**
  73478. * Class used to load GUI via XML.
  73479. */
  73480. export class XmlLoader {
  73481. private _nodes;
  73482. private _nodeTypes;
  73483. private _isLoaded;
  73484. private _objectAttributes;
  73485. private _parentClass;
  73486. /**
  73487. * Create a new xml loader
  73488. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73489. */
  73490. constructor(parentClass?: null);
  73491. private _getChainElement;
  73492. private _getClassAttribute;
  73493. private _createGuiElement;
  73494. private _parseGrid;
  73495. private _parseElement;
  73496. private _prepareSourceElement;
  73497. private _parseElementsFromSource;
  73498. private _parseXml;
  73499. /**
  73500. * Gets if the loading has finished.
  73501. * @returns whether the loading has finished or not
  73502. */
  73503. isLoaded(): boolean;
  73504. /**
  73505. * Gets a loaded node / control by id.
  73506. * @param id the Controls id set in the xml
  73507. * @returns element of type Control
  73508. */
  73509. getNodeById(id: string): any;
  73510. /**
  73511. * Gets all loaded nodes / controls
  73512. * @returns Array of controls
  73513. */
  73514. getNodes(): any;
  73515. /**
  73516. * Initiates the xml layout loading
  73517. * @param xmlFile defines the xml layout to load
  73518. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73519. * @param callback defines the callback called on layout load.
  73520. */
  73521. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73522. }
  73523. }
  73524. declare module BABYLON.GUI {
  73525. /**
  73526. * Class used to create containers for controls
  73527. */
  73528. export class Container3D extends Control3D {
  73529. private _blockLayout;
  73530. /**
  73531. * Gets the list of child controls
  73532. */
  73533. protected _children: Control3D[];
  73534. /**
  73535. * Gets the list of child controls
  73536. */
  73537. get children(): Array<Control3D>;
  73538. /**
  73539. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73540. * This is helpful to optimize layout operation when adding multiple children in a row
  73541. */
  73542. get blockLayout(): boolean;
  73543. set blockLayout(value: boolean);
  73544. /**
  73545. * Creates a new container
  73546. * @param name defines the container name
  73547. */
  73548. constructor(name?: string);
  73549. /**
  73550. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73551. * @returns the current container
  73552. */
  73553. updateLayout(): Container3D;
  73554. /**
  73555. * Gets a boolean indicating if the given control is in the children of this control
  73556. * @param control defines the control to check
  73557. * @returns true if the control is in the child list
  73558. */
  73559. containsControl(control: Control3D): boolean;
  73560. /**
  73561. * Adds a control to the children of this control
  73562. * @param control defines the control to add
  73563. * @returns the current container
  73564. */
  73565. addControl(control: Control3D): Container3D;
  73566. /**
  73567. * This function will be called everytime a new control is added
  73568. */
  73569. protected _arrangeChildren(): void;
  73570. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73571. /**
  73572. * Removes a control from the children of this control
  73573. * @param control defines the control to remove
  73574. * @returns the current container
  73575. */
  73576. removeControl(control: Control3D): Container3D;
  73577. protected _getTypeName(): string;
  73578. /**
  73579. * Releases all associated resources
  73580. */
  73581. dispose(): void;
  73582. /** Control rotation will remain unchanged */
  73583. static readonly UNSET_ORIENTATION: number;
  73584. /** Control will rotate to make it look at sphere central axis */
  73585. static readonly FACEORIGIN_ORIENTATION: number;
  73586. /** Control will rotate to make it look back at sphere central axis */
  73587. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73588. /** Control will rotate to look at z axis (0, 0, 1) */
  73589. static readonly FACEFORWARD_ORIENTATION: number;
  73590. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73591. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73592. }
  73593. }
  73594. declare module BABYLON.GUI {
  73595. /**
  73596. * Class used to manage 3D user interface
  73597. * @see http://doc.babylonjs.com/how_to/gui3d
  73598. */
  73599. export class GUI3DManager implements BABYLON.IDisposable {
  73600. private _scene;
  73601. private _sceneDisposeObserver;
  73602. private _utilityLayer;
  73603. private _rootContainer;
  73604. private _pointerObserver;
  73605. private _pointerOutObserver;
  73606. /** @hidden */
  73607. _lastPickedControl: Control3D;
  73608. /** @hidden */
  73609. _lastControlOver: {
  73610. [pointerId: number]: Control3D;
  73611. };
  73612. /** @hidden */
  73613. _lastControlDown: {
  73614. [pointerId: number]: Control3D;
  73615. };
  73616. /**
  73617. * BABYLON.Observable raised when the point picked by the pointer events changed
  73618. */
  73619. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73620. /** @hidden */
  73621. _sharedMaterials: {
  73622. [key: string]: BABYLON.Material;
  73623. };
  73624. /** Gets the hosting scene */
  73625. get scene(): BABYLON.Scene;
  73626. /** Gets associated utility layer */
  73627. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73628. /**
  73629. * Creates a new GUI3DManager
  73630. * @param scene
  73631. */
  73632. constructor(scene?: BABYLON.Scene);
  73633. private _handlePointerOut;
  73634. private _doPicking;
  73635. /**
  73636. * Gets the root container
  73637. */
  73638. get rootContainer(): Container3D;
  73639. /**
  73640. * Gets a boolean indicating if the given control is in the root child list
  73641. * @param control defines the control to check
  73642. * @returns true if the control is in the root child list
  73643. */
  73644. containsControl(control: Control3D): boolean;
  73645. /**
  73646. * Adds a control to the root child list
  73647. * @param control defines the control to add
  73648. * @returns the current manager
  73649. */
  73650. addControl(control: Control3D): GUI3DManager;
  73651. /**
  73652. * Removes a control from the root child list
  73653. * @param control defines the control to remove
  73654. * @returns the current container
  73655. */
  73656. removeControl(control: Control3D): GUI3DManager;
  73657. /**
  73658. * Releases all associated resources
  73659. */
  73660. dispose(): void;
  73661. }
  73662. }
  73663. declare module BABYLON.GUI {
  73664. /**
  73665. * Class used to transport BABYLON.Vector3 information for pointer events
  73666. */
  73667. export class Vector3WithInfo extends BABYLON.Vector3 {
  73668. /** defines the current mouse button index */
  73669. buttonIndex: number;
  73670. /**
  73671. * Creates a new Vector3WithInfo
  73672. * @param source defines the vector3 data to transport
  73673. * @param buttonIndex defines the current mouse button index
  73674. */
  73675. constructor(source: BABYLON.Vector3,
  73676. /** defines the current mouse button index */
  73677. buttonIndex?: number);
  73678. }
  73679. }
  73680. declare module BABYLON.GUI {
  73681. /**
  73682. * Class used as base class for controls
  73683. */
  73684. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73685. /** Defines the control name */
  73686. name?: string | undefined;
  73687. /** @hidden */
  73688. _host: GUI3DManager;
  73689. private _node;
  73690. private _downCount;
  73691. private _enterCount;
  73692. private _downPointerIds;
  73693. private _isVisible;
  73694. /** Gets or sets the control position in world space */
  73695. get position(): BABYLON.Vector3;
  73696. set position(value: BABYLON.Vector3);
  73697. /** Gets or sets the control scaling in world space */
  73698. get scaling(): BABYLON.Vector3;
  73699. set scaling(value: BABYLON.Vector3);
  73700. /** Callback used to start pointer enter animation */
  73701. pointerEnterAnimation: () => void;
  73702. /** Callback used to start pointer out animation */
  73703. pointerOutAnimation: () => void;
  73704. /** Callback used to start pointer down animation */
  73705. pointerDownAnimation: () => void;
  73706. /** Callback used to start pointer up animation */
  73707. pointerUpAnimation: () => void;
  73708. /**
  73709. * An event triggered when the pointer move over the control
  73710. */
  73711. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73712. /**
  73713. * An event triggered when the pointer move out of the control
  73714. */
  73715. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73716. /**
  73717. * An event triggered when the pointer taps the control
  73718. */
  73719. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73720. /**
  73721. * An event triggered when pointer is up
  73722. */
  73723. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73724. /**
  73725. * An event triggered when a control is clicked on (with a mouse)
  73726. */
  73727. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73728. /**
  73729. * An event triggered when pointer enters the control
  73730. */
  73731. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73732. /**
  73733. * Gets or sets the parent container
  73734. */
  73735. parent: BABYLON.Nullable<Container3D>;
  73736. private _behaviors;
  73737. /**
  73738. * Gets the list of attached behaviors
  73739. * @see http://doc.babylonjs.com/features/behaviour
  73740. */
  73741. get behaviors(): BABYLON.Behavior<Control3D>[];
  73742. /**
  73743. * Attach a behavior to the control
  73744. * @see http://doc.babylonjs.com/features/behaviour
  73745. * @param behavior defines the behavior to attach
  73746. * @returns the current control
  73747. */
  73748. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73749. /**
  73750. * Remove an attached behavior
  73751. * @see http://doc.babylonjs.com/features/behaviour
  73752. * @param behavior defines the behavior to attach
  73753. * @returns the current control
  73754. */
  73755. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73756. /**
  73757. * Gets an attached behavior by name
  73758. * @param name defines the name of the behavior to look for
  73759. * @see http://doc.babylonjs.com/features/behaviour
  73760. * @returns null if behavior was not found else the requested behavior
  73761. */
  73762. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73763. /** Gets or sets a boolean indicating if the control is visible */
  73764. get isVisible(): boolean;
  73765. set isVisible(value: boolean);
  73766. /**
  73767. * Creates a new control
  73768. * @param name defines the control name
  73769. */
  73770. constructor(
  73771. /** Defines the control name */
  73772. name?: string | undefined);
  73773. /**
  73774. * Gets a string representing the class name
  73775. */
  73776. get typeName(): string;
  73777. /**
  73778. * Get the current class name of the control.
  73779. * @returns current class name
  73780. */
  73781. getClassName(): string;
  73782. protected _getTypeName(): string;
  73783. /**
  73784. * Gets the transform node used by this control
  73785. */
  73786. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73787. /**
  73788. * Gets the mesh used to render this control
  73789. */
  73790. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73791. /**
  73792. * Link the control as child of the given node
  73793. * @param node defines the node to link to. Use null to unlink the control
  73794. * @returns the current control
  73795. */
  73796. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73797. /** @hidden **/
  73798. _prepareNode(scene: BABYLON.Scene): void;
  73799. /**
  73800. * Node creation.
  73801. * Can be overriden by children
  73802. * @param scene defines the scene where the node must be attached
  73803. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73804. */
  73805. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73806. /**
  73807. * Affect a material to the given mesh
  73808. * @param mesh defines the mesh which will represent the control
  73809. */
  73810. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73811. /** @hidden */
  73812. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73813. /** @hidden */
  73814. _onPointerEnter(target: Control3D): boolean;
  73815. /** @hidden */
  73816. _onPointerOut(target: Control3D): void;
  73817. /** @hidden */
  73818. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73819. /** @hidden */
  73820. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73821. /** @hidden */
  73822. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73823. /** @hidden */
  73824. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73825. /** @hidden */
  73826. _disposeNode(): void;
  73827. /**
  73828. * Releases all associated resources
  73829. */
  73830. dispose(): void;
  73831. }
  73832. }
  73833. declare module BABYLON.GUI {
  73834. /**
  73835. * Class used as a root to all buttons
  73836. */
  73837. export class AbstractButton3D extends Control3D {
  73838. /**
  73839. * Creates a new button
  73840. * @param name defines the control name
  73841. */
  73842. constructor(name?: string);
  73843. protected _getTypeName(): string;
  73844. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73845. }
  73846. }
  73847. declare module BABYLON.GUI {
  73848. /**
  73849. * Class used to create a button in 3D
  73850. */
  73851. export class Button3D extends AbstractButton3D {
  73852. /** @hidden */
  73853. protected _currentMaterial: BABYLON.Material;
  73854. private _facadeTexture;
  73855. private _content;
  73856. private _contentResolution;
  73857. private _contentScaleRatio;
  73858. /**
  73859. * Gets or sets the texture resolution used to render content (512 by default)
  73860. */
  73861. get contentResolution(): BABYLON.int;
  73862. set contentResolution(value: BABYLON.int);
  73863. /**
  73864. * Gets or sets the texture scale ratio used to render content (2 by default)
  73865. */
  73866. get contentScaleRatio(): number;
  73867. set contentScaleRatio(value: number);
  73868. protected _disposeFacadeTexture(): void;
  73869. protected _resetContent(): void;
  73870. /**
  73871. * Creates a new button
  73872. * @param name defines the control name
  73873. */
  73874. constructor(name?: string);
  73875. /**
  73876. * Gets or sets the GUI 2D content used to display the button's facade
  73877. */
  73878. get content(): Control;
  73879. set content(value: Control);
  73880. /**
  73881. * Apply the facade texture (created from the content property).
  73882. * This function can be overloaded by child classes
  73883. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73884. */
  73885. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73886. protected _getTypeName(): string;
  73887. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73888. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73889. /**
  73890. * Releases all associated resources
  73891. */
  73892. dispose(): void;
  73893. }
  73894. }
  73895. declare module BABYLON.GUI {
  73896. /**
  73897. * Abstract class used to create a container panel deployed on the surface of a volume
  73898. */
  73899. export abstract class VolumeBasedPanel extends Container3D {
  73900. private _columns;
  73901. private _rows;
  73902. private _rowThenColum;
  73903. private _orientation;
  73904. protected _cellWidth: number;
  73905. protected _cellHeight: number;
  73906. /**
  73907. * Gets or sets the distance between elements
  73908. */
  73909. margin: number;
  73910. /**
  73911. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73912. * | Value | Type | Description |
  73913. * | ----- | ----------------------------------- | ----------- |
  73914. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73915. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73916. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73917. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73918. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73919. */
  73920. get orientation(): number;
  73921. set orientation(value: number);
  73922. /**
  73923. * Gets or sets the number of columns requested (10 by default).
  73924. * The panel will automatically compute the number of rows based on number of child controls.
  73925. */
  73926. get columns(): BABYLON.int;
  73927. set columns(value: BABYLON.int);
  73928. /**
  73929. * Gets or sets a the number of rows requested.
  73930. * The panel will automatically compute the number of columns based on number of child controls.
  73931. */
  73932. get rows(): BABYLON.int;
  73933. set rows(value: BABYLON.int);
  73934. /**
  73935. * Creates new VolumeBasedPanel
  73936. */
  73937. constructor();
  73938. protected _arrangeChildren(): void;
  73939. /** Child classes must implement this function to provide correct control positioning */
  73940. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73941. /** Child classes can implement this function to provide additional processing */
  73942. protected _finalProcessing(): void;
  73943. }
  73944. }
  73945. declare module BABYLON.GUI {
  73946. /**
  73947. * Class used to create a container panel deployed on the surface of a cylinder
  73948. */
  73949. export class CylinderPanel extends VolumeBasedPanel {
  73950. private _radius;
  73951. /**
  73952. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73953. */
  73954. get radius(): BABYLON.float;
  73955. set radius(value: BABYLON.float);
  73956. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73957. private _cylindricalMapping;
  73958. }
  73959. }
  73960. declare module BABYLON.GUI {
  73961. /** @hidden */
  73962. export var fluentVertexShader: {
  73963. name: string;
  73964. shader: string;
  73965. };
  73966. }
  73967. declare module BABYLON.GUI {
  73968. /** @hidden */
  73969. export var fluentPixelShader: {
  73970. name: string;
  73971. shader: string;
  73972. };
  73973. }
  73974. declare module BABYLON.GUI {
  73975. /** @hidden */
  73976. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73977. INNERGLOW: boolean;
  73978. BORDER: boolean;
  73979. HOVERLIGHT: boolean;
  73980. TEXTURE: boolean;
  73981. constructor();
  73982. }
  73983. /**
  73984. * Class used to render controls with fluent desgin
  73985. */
  73986. export class FluentMaterial extends BABYLON.PushMaterial {
  73987. /**
  73988. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73989. */
  73990. innerGlowColorIntensity: number;
  73991. /**
  73992. * Gets or sets the inner glow color (white by default)
  73993. */
  73994. innerGlowColor: BABYLON.Color3;
  73995. /**
  73996. * Gets or sets alpha value (default is 1.0)
  73997. */
  73998. alpha: number;
  73999. /**
  74000. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74001. */
  74002. albedoColor: BABYLON.Color3;
  74003. /**
  74004. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74005. */
  74006. renderBorders: boolean;
  74007. /**
  74008. * Gets or sets border width (default is 0.5)
  74009. */
  74010. borderWidth: number;
  74011. /**
  74012. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74013. */
  74014. edgeSmoothingValue: number;
  74015. /**
  74016. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74017. */
  74018. borderMinValue: number;
  74019. /**
  74020. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74021. */
  74022. renderHoverLight: boolean;
  74023. /**
  74024. * Gets or sets the radius used to render the hover light (default is 1.0)
  74025. */
  74026. hoverRadius: number;
  74027. /**
  74028. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74029. */
  74030. hoverColor: BABYLON.Color4;
  74031. /**
  74032. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74033. */
  74034. hoverPosition: BABYLON.Vector3;
  74035. private _albedoTexture;
  74036. /** Gets or sets the texture to use for albedo color */
  74037. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74038. /**
  74039. * Creates a new Fluent material
  74040. * @param name defines the name of the material
  74041. * @param scene defines the hosting scene
  74042. */
  74043. constructor(name: string, scene: BABYLON.Scene);
  74044. needAlphaBlending(): boolean;
  74045. needAlphaTesting(): boolean;
  74046. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74047. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74048. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74049. getActiveTextures(): BABYLON.BaseTexture[];
  74050. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74051. dispose(forceDisposeEffect?: boolean): void;
  74052. clone(name: string): FluentMaterial;
  74053. serialize(): any;
  74054. getClassName(): string;
  74055. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74056. }
  74057. }
  74058. declare module BABYLON.GUI {
  74059. /**
  74060. * Class used to create a holographic button in 3D
  74061. */
  74062. export class HolographicButton extends Button3D {
  74063. private _backPlate;
  74064. private _textPlate;
  74065. private _frontPlate;
  74066. private _text;
  74067. private _imageUrl;
  74068. private _shareMaterials;
  74069. private _frontMaterial;
  74070. private _backMaterial;
  74071. private _plateMaterial;
  74072. private _pickedPointObserver;
  74073. private _tooltipFade;
  74074. private _tooltipTextBlock;
  74075. private _tooltipTexture;
  74076. private _tooltipMesh;
  74077. private _tooltipHoverObserver;
  74078. private _tooltipOutObserver;
  74079. private _disposeTooltip;
  74080. /**
  74081. * Rendering ground id of all the mesh in the button
  74082. */
  74083. set renderingGroupId(id: number);
  74084. get renderingGroupId(): number;
  74085. /**
  74086. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74087. */
  74088. set tooltipText(text: BABYLON.Nullable<string>);
  74089. get tooltipText(): BABYLON.Nullable<string>;
  74090. /**
  74091. * Gets or sets text for the button
  74092. */
  74093. get text(): string;
  74094. set text(value: string);
  74095. /**
  74096. * Gets or sets the image url for the button
  74097. */
  74098. get imageUrl(): string;
  74099. set imageUrl(value: string);
  74100. /**
  74101. * Gets the back material used by this button
  74102. */
  74103. get backMaterial(): FluentMaterial;
  74104. /**
  74105. * Gets the front material used by this button
  74106. */
  74107. get frontMaterial(): FluentMaterial;
  74108. /**
  74109. * Gets the plate material used by this button
  74110. */
  74111. get plateMaterial(): BABYLON.StandardMaterial;
  74112. /**
  74113. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74114. */
  74115. get shareMaterials(): boolean;
  74116. /**
  74117. * Creates a new button
  74118. * @param name defines the control name
  74119. */
  74120. constructor(name?: string, shareMaterials?: boolean);
  74121. protected _getTypeName(): string;
  74122. private _rebuildContent;
  74123. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74124. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74125. private _createBackMaterial;
  74126. private _createFrontMaterial;
  74127. private _createPlateMaterial;
  74128. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74129. /**
  74130. * Releases all associated resources
  74131. */
  74132. dispose(): void;
  74133. }
  74134. }
  74135. declare module BABYLON.GUI {
  74136. /**
  74137. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74138. */
  74139. export class MeshButton3D extends Button3D {
  74140. /** @hidden */
  74141. protected _currentMesh: BABYLON.Mesh;
  74142. /**
  74143. * Creates a new 3D button based on a mesh
  74144. * @param mesh mesh to become a 3D button
  74145. * @param name defines the control name
  74146. */
  74147. constructor(mesh: BABYLON.Mesh, name?: string);
  74148. protected _getTypeName(): string;
  74149. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74150. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74151. }
  74152. }
  74153. declare module BABYLON.GUI {
  74154. /**
  74155. * Class used to create a container panel deployed on the surface of a plane
  74156. */
  74157. export class PlanePanel extends VolumeBasedPanel {
  74158. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74159. }
  74160. }
  74161. declare module BABYLON.GUI {
  74162. /**
  74163. * Class used to create a container panel where items get randomized planar mapping
  74164. */
  74165. export class ScatterPanel extends VolumeBasedPanel {
  74166. private _iteration;
  74167. /**
  74168. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74169. */
  74170. get iteration(): BABYLON.float;
  74171. set iteration(value: BABYLON.float);
  74172. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74173. private _scatterMapping;
  74174. protected _finalProcessing(): void;
  74175. }
  74176. }
  74177. declare module BABYLON.GUI {
  74178. /**
  74179. * Class used to create a container panel deployed on the surface of a sphere
  74180. */
  74181. export class SpherePanel extends VolumeBasedPanel {
  74182. private _radius;
  74183. /**
  74184. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74185. */
  74186. get radius(): BABYLON.float;
  74187. set radius(value: BABYLON.float);
  74188. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74189. private _sphericalMapping;
  74190. }
  74191. }
  74192. declare module BABYLON.GUI {
  74193. /**
  74194. * Class used to create a stack panel in 3D on XY plane
  74195. */
  74196. export class StackPanel3D extends Container3D {
  74197. private _isVertical;
  74198. /**
  74199. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74200. */
  74201. get isVertical(): boolean;
  74202. set isVertical(value: boolean);
  74203. /**
  74204. * Gets or sets the distance between elements
  74205. */
  74206. margin: number;
  74207. /**
  74208. * Creates new StackPanel
  74209. * @param isVertical
  74210. */
  74211. constructor(isVertical?: boolean);
  74212. protected _arrangeChildren(): void;
  74213. }
  74214. }
  74215. declare module BABYLON {
  74216. /**
  74217. * Configuration for glTF validation
  74218. */
  74219. export interface IGLTFValidationConfiguration {
  74220. /**
  74221. * The url of the glTF validator.
  74222. */
  74223. url: string;
  74224. }
  74225. /**
  74226. * glTF validation
  74227. */
  74228. export class GLTFValidation {
  74229. /**
  74230. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74231. */
  74232. static Configuration: IGLTFValidationConfiguration;
  74233. private static _LoadScriptPromise;
  74234. /**
  74235. * Validate a glTF asset using the glTF-Validator.
  74236. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74237. * @param rootUrl The root url for the glTF
  74238. * @param fileName The file name for the glTF
  74239. * @param getExternalResource The callback to get external resources for the glTF validator
  74240. * @returns A promise that resolves with the glTF validation results once complete
  74241. */
  74242. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74243. }
  74244. }
  74245. declare module BABYLON {
  74246. /**
  74247. * Mode that determines the coordinate system to use.
  74248. */
  74249. export enum GLTFLoaderCoordinateSystemMode {
  74250. /**
  74251. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74252. */
  74253. AUTO = 0,
  74254. /**
  74255. * Sets the useRightHandedSystem flag on the scene.
  74256. */
  74257. FORCE_RIGHT_HANDED = 1
  74258. }
  74259. /**
  74260. * Mode that determines what animations will start.
  74261. */
  74262. export enum GLTFLoaderAnimationStartMode {
  74263. /**
  74264. * No animation will start.
  74265. */
  74266. NONE = 0,
  74267. /**
  74268. * The first animation will start.
  74269. */
  74270. FIRST = 1,
  74271. /**
  74272. * All animations will start.
  74273. */
  74274. ALL = 2
  74275. }
  74276. /**
  74277. * Interface that contains the data for the glTF asset.
  74278. */
  74279. export interface IGLTFLoaderData {
  74280. /**
  74281. * The object that represents the glTF JSON.
  74282. */
  74283. json: Object;
  74284. /**
  74285. * The BIN chunk of a binary glTF.
  74286. */
  74287. bin: Nullable<IDataBuffer>;
  74288. }
  74289. /**
  74290. * Interface for extending the loader.
  74291. */
  74292. export interface IGLTFLoaderExtension {
  74293. /**
  74294. * The name of this extension.
  74295. */
  74296. readonly name: string;
  74297. /**
  74298. * Defines whether this extension is enabled.
  74299. */
  74300. enabled: boolean;
  74301. /**
  74302. * Defines the order of this extension.
  74303. * The loader sorts the extensions using these values when loading.
  74304. */
  74305. order?: number;
  74306. }
  74307. /**
  74308. * Loader state.
  74309. */
  74310. export enum GLTFLoaderState {
  74311. /**
  74312. * The asset is loading.
  74313. */
  74314. LOADING = 0,
  74315. /**
  74316. * The asset is ready for rendering.
  74317. */
  74318. READY = 1,
  74319. /**
  74320. * The asset is completely loaded.
  74321. */
  74322. COMPLETE = 2
  74323. }
  74324. /** @hidden */
  74325. export interface IImportMeshAsyncOutput {
  74326. meshes: AbstractMesh[];
  74327. particleSystems: IParticleSystem[];
  74328. skeletons: Skeleton[];
  74329. animationGroups: AnimationGroup[];
  74330. lights: Light[];
  74331. transformNodes: TransformNode[];
  74332. }
  74333. /** @hidden */
  74334. export interface IGLTFLoader extends IDisposable {
  74335. readonly state: Nullable<GLTFLoaderState>;
  74336. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74337. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74338. }
  74339. /**
  74340. * File loader for loading glTF files into a scene.
  74341. */
  74342. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74343. /** @hidden */
  74344. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74345. /** @hidden */
  74346. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74347. /**
  74348. * Raised when the asset has been parsed
  74349. */
  74350. onParsedObservable: Observable<IGLTFLoaderData>;
  74351. private _onParsedObserver;
  74352. /**
  74353. * Raised when the asset has been parsed
  74354. */
  74355. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74356. /**
  74357. * 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.
  74358. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74359. * Defaults to true.
  74360. * @hidden
  74361. */
  74362. static IncrementalLoading: boolean;
  74363. /**
  74364. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74365. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74366. * @hidden
  74367. */
  74368. static HomogeneousCoordinates: boolean;
  74369. /**
  74370. * The coordinate system mode. Defaults to AUTO.
  74371. */
  74372. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74373. /**
  74374. * The animation start mode. Defaults to FIRST.
  74375. */
  74376. animationStartMode: GLTFLoaderAnimationStartMode;
  74377. /**
  74378. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74379. */
  74380. compileMaterials: boolean;
  74381. /**
  74382. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74383. */
  74384. useClipPlane: boolean;
  74385. /**
  74386. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74387. */
  74388. compileShadowGenerators: boolean;
  74389. /**
  74390. * Defines if the Alpha blended materials are only applied as coverage.
  74391. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74392. * If true, no extra effects are applied to transparent pixels.
  74393. */
  74394. transparencyAsCoverage: boolean;
  74395. /**
  74396. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74397. * Enabling will disable offline support and glTF validator.
  74398. * Defaults to false.
  74399. */
  74400. useRangeRequests: boolean;
  74401. /**
  74402. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74403. */
  74404. createInstances: boolean;
  74405. /**
  74406. * Function called before loading a url referenced by the asset.
  74407. */
  74408. preprocessUrlAsync: (url: string) => Promise<string>;
  74409. /**
  74410. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74411. */
  74412. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74413. private _onMeshLoadedObserver;
  74414. /**
  74415. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74416. */
  74417. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74418. /**
  74419. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74420. */
  74421. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74422. private _onTextureLoadedObserver;
  74423. /**
  74424. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74425. */
  74426. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74427. /**
  74428. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74429. */
  74430. readonly onMaterialLoadedObservable: Observable<Material>;
  74431. private _onMaterialLoadedObserver;
  74432. /**
  74433. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74434. */
  74435. set onMaterialLoaded(callback: (material: Material) => void);
  74436. /**
  74437. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74438. */
  74439. readonly onCameraLoadedObservable: Observable<Camera>;
  74440. private _onCameraLoadedObserver;
  74441. /**
  74442. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74443. */
  74444. set onCameraLoaded(callback: (camera: Camera) => void);
  74445. /**
  74446. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74447. * For assets with LODs, raised when all of the LODs are complete.
  74448. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74449. */
  74450. readonly onCompleteObservable: Observable<void>;
  74451. private _onCompleteObserver;
  74452. /**
  74453. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74454. * For assets with LODs, raised when all of the LODs are complete.
  74455. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74456. */
  74457. set onComplete(callback: () => void);
  74458. /**
  74459. * Observable raised when an error occurs.
  74460. */
  74461. readonly onErrorObservable: Observable<any>;
  74462. private _onErrorObserver;
  74463. /**
  74464. * Callback raised when an error occurs.
  74465. */
  74466. set onError(callback: (reason: any) => void);
  74467. /**
  74468. * Observable raised after the loader is disposed.
  74469. */
  74470. readonly onDisposeObservable: Observable<void>;
  74471. private _onDisposeObserver;
  74472. /**
  74473. * Callback raised after the loader is disposed.
  74474. */
  74475. set onDispose(callback: () => void);
  74476. /**
  74477. * Observable raised after a loader extension is created.
  74478. * Set additional options for a loader extension in this event.
  74479. */
  74480. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74481. private _onExtensionLoadedObserver;
  74482. /**
  74483. * Callback raised after a loader extension is created.
  74484. */
  74485. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74486. /**
  74487. * Defines if the loader logging is enabled.
  74488. */
  74489. get loggingEnabled(): boolean;
  74490. set loggingEnabled(value: boolean);
  74491. /**
  74492. * Defines if the loader should capture performance counters.
  74493. */
  74494. get capturePerformanceCounters(): boolean;
  74495. set capturePerformanceCounters(value: boolean);
  74496. /**
  74497. * Defines if the loader should validate the asset.
  74498. */
  74499. validate: boolean;
  74500. /**
  74501. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74502. */
  74503. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74504. private _onValidatedObserver;
  74505. /**
  74506. * Callback raised after a loader extension is created.
  74507. */
  74508. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74509. private _loader;
  74510. /**
  74511. * Name of the loader ("gltf")
  74512. */
  74513. name: string;
  74514. /** @hidden */
  74515. extensions: ISceneLoaderPluginExtensions;
  74516. /**
  74517. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74518. */
  74519. dispose(): void;
  74520. /** @hidden */
  74521. _clear(): void;
  74522. /** @hidden */
  74523. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74524. /** @hidden */
  74525. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74526. /** @hidden */
  74527. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74528. meshes: AbstractMesh[];
  74529. particleSystems: IParticleSystem[];
  74530. skeletons: Skeleton[];
  74531. animationGroups: AnimationGroup[];
  74532. }>;
  74533. /** @hidden */
  74534. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74535. /** @hidden */
  74536. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74537. /** @hidden */
  74538. canDirectLoad(data: string): boolean;
  74539. /** @hidden */
  74540. directLoad(scene: Scene, data: string): any;
  74541. /**
  74542. * The callback that allows custom handling of the root url based on the response url.
  74543. * @param rootUrl the original root url
  74544. * @param responseURL the response url if available
  74545. * @returns the new root url
  74546. */
  74547. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74548. /** @hidden */
  74549. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74550. /**
  74551. * The loader state or null if the loader is not active.
  74552. */
  74553. get loaderState(): Nullable<GLTFLoaderState>;
  74554. /**
  74555. * Returns a promise that resolves when the asset is completely loaded.
  74556. * @returns a promise that resolves when the asset is completely loaded.
  74557. */
  74558. whenCompleteAsync(): Promise<void>;
  74559. private _validate;
  74560. private _getLoader;
  74561. private _parseJson;
  74562. private _unpackBinaryAsync;
  74563. private _unpackBinaryV1Async;
  74564. private _unpackBinaryV2Async;
  74565. private static _parseVersion;
  74566. private static _compareVersion;
  74567. private static readonly _logSpaces;
  74568. private _logIndentLevel;
  74569. private _loggingEnabled;
  74570. /** @hidden */
  74571. _log: (message: string) => void;
  74572. /** @hidden */
  74573. _logOpen(message: string): void;
  74574. /** @hidden */
  74575. _logClose(): void;
  74576. private _logEnabled;
  74577. private _logDisabled;
  74578. private _capturePerformanceCounters;
  74579. /** @hidden */
  74580. _startPerformanceCounter: (counterName: string) => void;
  74581. /** @hidden */
  74582. _endPerformanceCounter: (counterName: string) => void;
  74583. private _startPerformanceCounterEnabled;
  74584. private _startPerformanceCounterDisabled;
  74585. private _endPerformanceCounterEnabled;
  74586. private _endPerformanceCounterDisabled;
  74587. }
  74588. }
  74589. declare module BABYLON.GLTF1 {
  74590. /**
  74591. * Enums
  74592. * @hidden
  74593. */
  74594. export enum EComponentType {
  74595. BYTE = 5120,
  74596. UNSIGNED_BYTE = 5121,
  74597. SHORT = 5122,
  74598. UNSIGNED_SHORT = 5123,
  74599. FLOAT = 5126
  74600. }
  74601. /** @hidden */
  74602. export enum EShaderType {
  74603. FRAGMENT = 35632,
  74604. VERTEX = 35633
  74605. }
  74606. /** @hidden */
  74607. export enum EParameterType {
  74608. BYTE = 5120,
  74609. UNSIGNED_BYTE = 5121,
  74610. SHORT = 5122,
  74611. UNSIGNED_SHORT = 5123,
  74612. INT = 5124,
  74613. UNSIGNED_INT = 5125,
  74614. FLOAT = 5126,
  74615. FLOAT_VEC2 = 35664,
  74616. FLOAT_VEC3 = 35665,
  74617. FLOAT_VEC4 = 35666,
  74618. INT_VEC2 = 35667,
  74619. INT_VEC3 = 35668,
  74620. INT_VEC4 = 35669,
  74621. BOOL = 35670,
  74622. BOOL_VEC2 = 35671,
  74623. BOOL_VEC3 = 35672,
  74624. BOOL_VEC4 = 35673,
  74625. FLOAT_MAT2 = 35674,
  74626. FLOAT_MAT3 = 35675,
  74627. FLOAT_MAT4 = 35676,
  74628. SAMPLER_2D = 35678
  74629. }
  74630. /** @hidden */
  74631. export enum ETextureWrapMode {
  74632. CLAMP_TO_EDGE = 33071,
  74633. MIRRORED_REPEAT = 33648,
  74634. REPEAT = 10497
  74635. }
  74636. /** @hidden */
  74637. export enum ETextureFilterType {
  74638. NEAREST = 9728,
  74639. LINEAR = 9728,
  74640. NEAREST_MIPMAP_NEAREST = 9984,
  74641. LINEAR_MIPMAP_NEAREST = 9985,
  74642. NEAREST_MIPMAP_LINEAR = 9986,
  74643. LINEAR_MIPMAP_LINEAR = 9987
  74644. }
  74645. /** @hidden */
  74646. export enum ETextureFormat {
  74647. ALPHA = 6406,
  74648. RGB = 6407,
  74649. RGBA = 6408,
  74650. LUMINANCE = 6409,
  74651. LUMINANCE_ALPHA = 6410
  74652. }
  74653. /** @hidden */
  74654. export enum ECullingType {
  74655. FRONT = 1028,
  74656. BACK = 1029,
  74657. FRONT_AND_BACK = 1032
  74658. }
  74659. /** @hidden */
  74660. export enum EBlendingFunction {
  74661. ZERO = 0,
  74662. ONE = 1,
  74663. SRC_COLOR = 768,
  74664. ONE_MINUS_SRC_COLOR = 769,
  74665. DST_COLOR = 774,
  74666. ONE_MINUS_DST_COLOR = 775,
  74667. SRC_ALPHA = 770,
  74668. ONE_MINUS_SRC_ALPHA = 771,
  74669. DST_ALPHA = 772,
  74670. ONE_MINUS_DST_ALPHA = 773,
  74671. CONSTANT_COLOR = 32769,
  74672. ONE_MINUS_CONSTANT_COLOR = 32770,
  74673. CONSTANT_ALPHA = 32771,
  74674. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74675. SRC_ALPHA_SATURATE = 776
  74676. }
  74677. /** @hidden */
  74678. export interface IGLTFProperty {
  74679. extensions?: {
  74680. [key: string]: any;
  74681. };
  74682. extras?: Object;
  74683. }
  74684. /** @hidden */
  74685. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74686. name?: string;
  74687. }
  74688. /** @hidden */
  74689. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74690. bufferView: string;
  74691. byteOffset: number;
  74692. byteStride: number;
  74693. count: number;
  74694. type: string;
  74695. componentType: EComponentType;
  74696. max?: number[];
  74697. min?: number[];
  74698. name?: string;
  74699. }
  74700. /** @hidden */
  74701. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74702. buffer: string;
  74703. byteOffset: number;
  74704. byteLength: number;
  74705. byteStride: number;
  74706. target?: number;
  74707. }
  74708. /** @hidden */
  74709. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74710. uri: string;
  74711. byteLength?: number;
  74712. type?: string;
  74713. }
  74714. /** @hidden */
  74715. export interface IGLTFShader extends IGLTFChildRootProperty {
  74716. uri: string;
  74717. type: EShaderType;
  74718. }
  74719. /** @hidden */
  74720. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74721. attributes: string[];
  74722. fragmentShader: string;
  74723. vertexShader: string;
  74724. }
  74725. /** @hidden */
  74726. export interface IGLTFTechniqueParameter {
  74727. type: number;
  74728. count?: number;
  74729. semantic?: string;
  74730. node?: string;
  74731. value?: number | boolean | string | Array<any>;
  74732. source?: string;
  74733. babylonValue?: any;
  74734. }
  74735. /** @hidden */
  74736. export interface IGLTFTechniqueCommonProfile {
  74737. lightingModel: string;
  74738. texcoordBindings: Object;
  74739. parameters?: Array<any>;
  74740. }
  74741. /** @hidden */
  74742. export interface IGLTFTechniqueStatesFunctions {
  74743. blendColor?: number[];
  74744. blendEquationSeparate?: number[];
  74745. blendFuncSeparate?: number[];
  74746. colorMask: boolean[];
  74747. cullFace: number[];
  74748. }
  74749. /** @hidden */
  74750. export interface IGLTFTechniqueStates {
  74751. enable: number[];
  74752. functions: IGLTFTechniqueStatesFunctions;
  74753. }
  74754. /** @hidden */
  74755. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74756. parameters: {
  74757. [key: string]: IGLTFTechniqueParameter;
  74758. };
  74759. program: string;
  74760. attributes: {
  74761. [key: string]: string;
  74762. };
  74763. uniforms: {
  74764. [key: string]: string;
  74765. };
  74766. states: IGLTFTechniqueStates;
  74767. }
  74768. /** @hidden */
  74769. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74770. technique?: string;
  74771. values: string[];
  74772. }
  74773. /** @hidden */
  74774. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74775. attributes: {
  74776. [key: string]: string;
  74777. };
  74778. indices: string;
  74779. material: string;
  74780. mode?: number;
  74781. }
  74782. /** @hidden */
  74783. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74784. primitives: IGLTFMeshPrimitive[];
  74785. }
  74786. /** @hidden */
  74787. export interface IGLTFImage extends IGLTFChildRootProperty {
  74788. uri: string;
  74789. }
  74790. /** @hidden */
  74791. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74792. magFilter?: number;
  74793. minFilter?: number;
  74794. wrapS?: number;
  74795. wrapT?: number;
  74796. }
  74797. /** @hidden */
  74798. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74799. sampler: string;
  74800. source: string;
  74801. format?: ETextureFormat;
  74802. internalFormat?: ETextureFormat;
  74803. target?: number;
  74804. type?: number;
  74805. babylonTexture?: Texture;
  74806. }
  74807. /** @hidden */
  74808. export interface IGLTFAmbienLight {
  74809. color?: number[];
  74810. }
  74811. /** @hidden */
  74812. export interface IGLTFDirectionalLight {
  74813. color?: number[];
  74814. }
  74815. /** @hidden */
  74816. export interface IGLTFPointLight {
  74817. color?: number[];
  74818. constantAttenuation?: number;
  74819. linearAttenuation?: number;
  74820. quadraticAttenuation?: number;
  74821. }
  74822. /** @hidden */
  74823. export interface IGLTFSpotLight {
  74824. color?: number[];
  74825. constantAttenuation?: number;
  74826. fallOfAngle?: number;
  74827. fallOffExponent?: number;
  74828. linearAttenuation?: number;
  74829. quadraticAttenuation?: number;
  74830. }
  74831. /** @hidden */
  74832. export interface IGLTFLight extends IGLTFChildRootProperty {
  74833. type: string;
  74834. }
  74835. /** @hidden */
  74836. export interface IGLTFCameraOrthographic {
  74837. xmag: number;
  74838. ymag: number;
  74839. zfar: number;
  74840. znear: number;
  74841. }
  74842. /** @hidden */
  74843. export interface IGLTFCameraPerspective {
  74844. aspectRatio: number;
  74845. yfov: number;
  74846. zfar: number;
  74847. znear: number;
  74848. }
  74849. /** @hidden */
  74850. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74851. type: string;
  74852. }
  74853. /** @hidden */
  74854. export interface IGLTFAnimationChannelTarget {
  74855. id: string;
  74856. path: string;
  74857. }
  74858. /** @hidden */
  74859. export interface IGLTFAnimationChannel {
  74860. sampler: string;
  74861. target: IGLTFAnimationChannelTarget;
  74862. }
  74863. /** @hidden */
  74864. export interface IGLTFAnimationSampler {
  74865. input: string;
  74866. output: string;
  74867. interpolation?: string;
  74868. }
  74869. /** @hidden */
  74870. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74871. channels?: IGLTFAnimationChannel[];
  74872. parameters?: {
  74873. [key: string]: string;
  74874. };
  74875. samplers?: {
  74876. [key: string]: IGLTFAnimationSampler;
  74877. };
  74878. }
  74879. /** @hidden */
  74880. export interface IGLTFNodeInstanceSkin {
  74881. skeletons: string[];
  74882. skin: string;
  74883. meshes: string[];
  74884. }
  74885. /** @hidden */
  74886. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74887. bindShapeMatrix: number[];
  74888. inverseBindMatrices: string;
  74889. jointNames: string[];
  74890. babylonSkeleton?: Skeleton;
  74891. }
  74892. /** @hidden */
  74893. export interface IGLTFNode extends IGLTFChildRootProperty {
  74894. camera?: string;
  74895. children: string[];
  74896. skin?: string;
  74897. jointName?: string;
  74898. light?: string;
  74899. matrix: number[];
  74900. mesh?: string;
  74901. meshes?: string[];
  74902. rotation?: number[];
  74903. scale?: number[];
  74904. translation?: number[];
  74905. babylonNode?: Node;
  74906. }
  74907. /** @hidden */
  74908. export interface IGLTFScene extends IGLTFChildRootProperty {
  74909. nodes: string[];
  74910. }
  74911. /** @hidden */
  74912. export interface IGLTFRuntime {
  74913. extensions: {
  74914. [key: string]: any;
  74915. };
  74916. accessors: {
  74917. [key: string]: IGLTFAccessor;
  74918. };
  74919. buffers: {
  74920. [key: string]: IGLTFBuffer;
  74921. };
  74922. bufferViews: {
  74923. [key: string]: IGLTFBufferView;
  74924. };
  74925. meshes: {
  74926. [key: string]: IGLTFMesh;
  74927. };
  74928. lights: {
  74929. [key: string]: IGLTFLight;
  74930. };
  74931. cameras: {
  74932. [key: string]: IGLTFCamera;
  74933. };
  74934. nodes: {
  74935. [key: string]: IGLTFNode;
  74936. };
  74937. images: {
  74938. [key: string]: IGLTFImage;
  74939. };
  74940. textures: {
  74941. [key: string]: IGLTFTexture;
  74942. };
  74943. shaders: {
  74944. [key: string]: IGLTFShader;
  74945. };
  74946. programs: {
  74947. [key: string]: IGLTFProgram;
  74948. };
  74949. samplers: {
  74950. [key: string]: IGLTFSampler;
  74951. };
  74952. techniques: {
  74953. [key: string]: IGLTFTechnique;
  74954. };
  74955. materials: {
  74956. [key: string]: IGLTFMaterial;
  74957. };
  74958. animations: {
  74959. [key: string]: IGLTFAnimation;
  74960. };
  74961. skins: {
  74962. [key: string]: IGLTFSkins;
  74963. };
  74964. currentScene?: Object;
  74965. scenes: {
  74966. [key: string]: IGLTFScene;
  74967. };
  74968. extensionsUsed: string[];
  74969. extensionsRequired?: string[];
  74970. buffersCount: number;
  74971. shaderscount: number;
  74972. scene: Scene;
  74973. rootUrl: string;
  74974. loadedBufferCount: number;
  74975. loadedBufferViews: {
  74976. [name: string]: ArrayBufferView;
  74977. };
  74978. loadedShaderCount: number;
  74979. importOnlyMeshes: boolean;
  74980. importMeshesNames?: string[];
  74981. dummyNodes: Node[];
  74982. forAssetContainer: boolean;
  74983. }
  74984. /** @hidden */
  74985. export interface INodeToRoot {
  74986. bone: Bone;
  74987. node: IGLTFNode;
  74988. id: string;
  74989. }
  74990. /** @hidden */
  74991. export interface IJointNode {
  74992. node: IGLTFNode;
  74993. id: string;
  74994. }
  74995. }
  74996. declare module BABYLON.GLTF1 {
  74997. /**
  74998. * Utils functions for GLTF
  74999. * @hidden
  75000. */
  75001. export class GLTFUtils {
  75002. /**
  75003. * Sets the given "parameter" matrix
  75004. * @param scene: the Scene object
  75005. * @param source: the source node where to pick the matrix
  75006. * @param parameter: the GLTF technique parameter
  75007. * @param uniformName: the name of the shader's uniform
  75008. * @param shaderMaterial: the shader material
  75009. */
  75010. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75011. /**
  75012. * Sets the given "parameter" matrix
  75013. * @param shaderMaterial: the shader material
  75014. * @param uniform: the name of the shader's uniform
  75015. * @param value: the value of the uniform
  75016. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75017. */
  75018. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75019. /**
  75020. * Returns the wrap mode of the texture
  75021. * @param mode: the mode value
  75022. */
  75023. static GetWrapMode(mode: number): number;
  75024. /**
  75025. * Returns the byte stride giving an accessor
  75026. * @param accessor: the GLTF accessor objet
  75027. */
  75028. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75029. /**
  75030. * Returns the texture filter mode giving a mode value
  75031. * @param mode: the filter mode value
  75032. */
  75033. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75034. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75035. /**
  75036. * Returns a buffer from its accessor
  75037. * @param gltfRuntime: the GLTF runtime
  75038. * @param accessor: the GLTF accessor
  75039. */
  75040. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75041. /**
  75042. * Decodes a buffer view into a string
  75043. * @param view: the buffer view
  75044. */
  75045. static DecodeBufferToText(view: ArrayBufferView): string;
  75046. /**
  75047. * Returns the default material of gltf. Related to
  75048. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75049. * @param scene: the Babylon.js scene
  75050. */
  75051. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75052. private static _DefaultMaterial;
  75053. }
  75054. }
  75055. declare module BABYLON.GLTF1 {
  75056. /**
  75057. * Implementation of the base glTF spec
  75058. * @hidden
  75059. */
  75060. export class GLTFLoaderBase {
  75061. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75062. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75063. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75064. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75065. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75066. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75067. }
  75068. /**
  75069. * glTF V1 Loader
  75070. * @hidden
  75071. */
  75072. export class GLTFLoader implements IGLTFLoader {
  75073. static Extensions: {
  75074. [name: string]: GLTFLoaderExtension;
  75075. };
  75076. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75077. state: Nullable<GLTFLoaderState>;
  75078. dispose(): void;
  75079. private _importMeshAsync;
  75080. /**
  75081. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75082. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75083. * @param scene the scene the meshes should be added to
  75084. * @param forAssetContainer defines if the entities must be stored in the scene
  75085. * @param data gltf data containing information of the meshes in a loaded file
  75086. * @param rootUrl root url to load from
  75087. * @param onProgress event that fires when loading progress has occured
  75088. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75089. */
  75090. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75091. private _loadAsync;
  75092. /**
  75093. * Imports all objects from a loaded gltf file and adds them to the scene
  75094. * @param scene the scene the objects should be added to
  75095. * @param data gltf data containing information of the meshes in a loaded file
  75096. * @param rootUrl root url to load from
  75097. * @param onProgress event that fires when loading progress has occured
  75098. * @returns a promise which completes when objects have been loaded to the scene
  75099. */
  75100. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75101. private _loadShadersAsync;
  75102. private _loadBuffersAsync;
  75103. private _createNodes;
  75104. }
  75105. /** @hidden */
  75106. export abstract class GLTFLoaderExtension {
  75107. private _name;
  75108. constructor(name: string);
  75109. get name(): string;
  75110. /**
  75111. * Defines an override for loading the runtime
  75112. * Return true to stop further extensions from loading the runtime
  75113. */
  75114. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75115. /**
  75116. * Defines an onverride for creating gltf runtime
  75117. * Return true to stop further extensions from creating the runtime
  75118. */
  75119. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75120. /**
  75121. * Defines an override for loading buffers
  75122. * Return true to stop further extensions from loading this buffer
  75123. */
  75124. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75125. /**
  75126. * Defines an override for loading texture buffers
  75127. * Return true to stop further extensions from loading this texture data
  75128. */
  75129. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75130. /**
  75131. * Defines an override for creating textures
  75132. * Return true to stop further extensions from loading this texture
  75133. */
  75134. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75135. /**
  75136. * Defines an override for loading shader strings
  75137. * Return true to stop further extensions from loading this shader data
  75138. */
  75139. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75140. /**
  75141. * Defines an override for loading materials
  75142. * Return true to stop further extensions from loading this material
  75143. */
  75144. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75145. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75146. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75147. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75148. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75149. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75150. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75151. private static LoadTextureBufferAsync;
  75152. private static CreateTextureAsync;
  75153. private static ApplyExtensions;
  75154. }
  75155. }
  75156. declare module BABYLON.GLTF1 {
  75157. /** @hidden */
  75158. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75159. private _bin;
  75160. constructor();
  75161. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75162. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75163. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75164. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75165. }
  75166. }
  75167. declare module BABYLON.GLTF1 {
  75168. /** @hidden */
  75169. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75170. constructor();
  75171. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75172. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75173. private _loadTexture;
  75174. }
  75175. }
  75176. declare module BABYLON.GLTF2.Loader {
  75177. /**
  75178. * Loader interface with an index field.
  75179. */
  75180. export interface IArrayItem {
  75181. /**
  75182. * The index of this item in the array.
  75183. */
  75184. index: number;
  75185. }
  75186. /**
  75187. * Loader interface with additional members.
  75188. */
  75189. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75190. /** @hidden */
  75191. _data?: Promise<ArrayBufferView>;
  75192. /** @hidden */
  75193. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75194. }
  75195. /**
  75196. * Loader interface with additional members.
  75197. */
  75198. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75199. }
  75200. /** @hidden */
  75201. export interface _IAnimationSamplerData {
  75202. input: Float32Array;
  75203. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75204. output: Float32Array;
  75205. }
  75206. /**
  75207. * Loader interface with additional members.
  75208. */
  75209. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75210. /** @hidden */
  75211. _data?: Promise<_IAnimationSamplerData>;
  75212. }
  75213. /**
  75214. * Loader interface with additional members.
  75215. */
  75216. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75217. channels: IAnimationChannel[];
  75218. samplers: IAnimationSampler[];
  75219. /** @hidden */
  75220. _babylonAnimationGroup?: AnimationGroup;
  75221. }
  75222. /**
  75223. * Loader interface with additional members.
  75224. */
  75225. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75226. /** @hidden */
  75227. _data?: Promise<ArrayBufferView>;
  75228. }
  75229. /**
  75230. * Loader interface with additional members.
  75231. */
  75232. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75233. /** @hidden */
  75234. _data?: Promise<ArrayBufferView>;
  75235. /** @hidden */
  75236. _babylonBuffer?: Promise<Buffer>;
  75237. }
  75238. /**
  75239. * Loader interface with additional members.
  75240. */
  75241. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75242. }
  75243. /**
  75244. * Loader interface with additional members.
  75245. */
  75246. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75247. /** @hidden */
  75248. _data?: Promise<ArrayBufferView>;
  75249. }
  75250. /**
  75251. * Loader interface with additional members.
  75252. */
  75253. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75254. }
  75255. /**
  75256. * Loader interface with additional members.
  75257. */
  75258. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75259. }
  75260. /**
  75261. * Loader interface with additional members.
  75262. */
  75263. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75264. baseColorTexture?: ITextureInfo;
  75265. metallicRoughnessTexture?: ITextureInfo;
  75266. }
  75267. /**
  75268. * Loader interface with additional members.
  75269. */
  75270. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75271. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75272. normalTexture?: IMaterialNormalTextureInfo;
  75273. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75274. emissiveTexture?: ITextureInfo;
  75275. /** @hidden */
  75276. _data?: {
  75277. [babylonDrawMode: number]: {
  75278. babylonMaterial: Material;
  75279. babylonMeshes: AbstractMesh[];
  75280. promise: Promise<void>;
  75281. };
  75282. };
  75283. }
  75284. /**
  75285. * Loader interface with additional members.
  75286. */
  75287. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75288. primitives: IMeshPrimitive[];
  75289. }
  75290. /**
  75291. * Loader interface with additional members.
  75292. */
  75293. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75294. /** @hidden */
  75295. _instanceData?: {
  75296. babylonSourceMesh: Mesh;
  75297. promise: Promise<any>;
  75298. };
  75299. }
  75300. /**
  75301. * Loader interface with additional members.
  75302. */
  75303. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75304. /**
  75305. * The parent glTF node.
  75306. */
  75307. parent?: INode;
  75308. /** @hidden */
  75309. _babylonTransformNode?: TransformNode;
  75310. /** @hidden */
  75311. _primitiveBabylonMeshes?: AbstractMesh[];
  75312. /** @hidden */
  75313. _babylonBones?: Bone[];
  75314. /** @hidden */
  75315. _numMorphTargets?: number;
  75316. }
  75317. /** @hidden */
  75318. export interface _ISamplerData {
  75319. noMipMaps: boolean;
  75320. samplingMode: number;
  75321. wrapU: number;
  75322. wrapV: number;
  75323. }
  75324. /**
  75325. * Loader interface with additional members.
  75326. */
  75327. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75328. /** @hidden */
  75329. _data?: _ISamplerData;
  75330. }
  75331. /**
  75332. * Loader interface with additional members.
  75333. */
  75334. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75335. }
  75336. /**
  75337. * Loader interface with additional members.
  75338. */
  75339. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75340. /** @hidden */
  75341. _data?: {
  75342. babylonSkeleton: Skeleton;
  75343. promise: Promise<void>;
  75344. };
  75345. }
  75346. /**
  75347. * Loader interface with additional members.
  75348. */
  75349. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75350. }
  75351. /**
  75352. * Loader interface with additional members.
  75353. */
  75354. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75355. }
  75356. /**
  75357. * Loader interface with additional members.
  75358. */
  75359. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75360. accessors?: IAccessor[];
  75361. animations?: IAnimation[];
  75362. buffers?: IBuffer[];
  75363. bufferViews?: IBufferView[];
  75364. cameras?: ICamera[];
  75365. images?: IImage[];
  75366. materials?: IMaterial[];
  75367. meshes?: IMesh[];
  75368. nodes?: INode[];
  75369. samplers?: ISampler[];
  75370. scenes?: IScene[];
  75371. skins?: ISkin[];
  75372. textures?: ITexture[];
  75373. }
  75374. }
  75375. declare module BABYLON.GLTF2 {
  75376. /**
  75377. * Interface for a glTF loader extension.
  75378. */
  75379. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75380. /**
  75381. * Called after the loader state changes to LOADING.
  75382. */
  75383. onLoading?(): void;
  75384. /**
  75385. * Called after the loader state changes to READY.
  75386. */
  75387. onReady?(): void;
  75388. /**
  75389. * Define this method to modify the default behavior when loading scenes.
  75390. * @param context The context when loading the asset
  75391. * @param scene The glTF scene property
  75392. * @returns A promise that resolves when the load is complete or null if not handled
  75393. */
  75394. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75395. /**
  75396. * Define this method to modify the default behavior when loading nodes.
  75397. * @param context The context when loading the asset
  75398. * @param node The glTF node property
  75399. * @param assign A function called synchronously after parsing the glTF properties
  75400. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75401. */
  75402. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75403. /**
  75404. * Define this method to modify the default behavior when loading cameras.
  75405. * @param context The context when loading the asset
  75406. * @param camera The glTF camera property
  75407. * @param assign A function called synchronously after parsing the glTF properties
  75408. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75409. */
  75410. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75411. /**
  75412. * @hidden
  75413. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75414. * @param context The context when loading the asset
  75415. * @param primitive The glTF mesh primitive property
  75416. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75417. */
  75418. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75419. /**
  75420. * @hidden
  75421. * Define this method to modify the default behavior when loading data for mesh primitives.
  75422. * @param context The context when loading the asset
  75423. * @param name The mesh name when loading the asset
  75424. * @param node The glTF node when loading the asset
  75425. * @param mesh The glTF mesh when loading the asset
  75426. * @param primitive The glTF mesh primitive property
  75427. * @param assign A function called synchronously after parsing the glTF properties
  75428. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75429. */
  75430. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75431. /**
  75432. * @hidden
  75433. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75434. * @param context The context when loading the asset
  75435. * @param material The glTF material property
  75436. * @param assign A function called synchronously after parsing the glTF properties
  75437. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75438. */
  75439. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75440. /**
  75441. * Define this method to modify the default behavior when creating materials.
  75442. * @param context The context when loading the asset
  75443. * @param material The glTF material property
  75444. * @param babylonDrawMode The draw mode for the Babylon material
  75445. * @returns The Babylon material or null if not handled
  75446. */
  75447. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75448. /**
  75449. * Define this method to modify the default behavior when loading material properties.
  75450. * @param context The context when loading the asset
  75451. * @param material The glTF material property
  75452. * @param babylonMaterial The Babylon material
  75453. * @returns A promise that resolves when the load is complete or null if not handled
  75454. */
  75455. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75456. /**
  75457. * Define this method to modify the default behavior when loading texture infos.
  75458. * @param context The context when loading the asset
  75459. * @param textureInfo The glTF texture info property
  75460. * @param assign A function called synchronously after parsing the glTF properties
  75461. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75462. */
  75463. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75464. /**
  75465. * @hidden
  75466. * Define this method to modify the default behavior when loading textures.
  75467. * @param context The context when loading the asset
  75468. * @param texture The glTF texture property
  75469. * @param assign A function called synchronously after parsing the glTF properties
  75470. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75471. */
  75472. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75473. /**
  75474. * Define this method to modify the default behavior when loading animations.
  75475. * @param context The context when loading the asset
  75476. * @param animation The glTF animation property
  75477. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75478. */
  75479. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75480. /**
  75481. * @hidden
  75482. * Define this method to modify the default behavior when loading skins.
  75483. * @param context The context when loading the asset
  75484. * @param node The glTF node property
  75485. * @param skin The glTF skin property
  75486. * @returns A promise that resolves when the load is complete or null if not handled
  75487. */
  75488. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75489. /**
  75490. * @hidden
  75491. * Define this method to modify the default behavior when loading uris.
  75492. * @param context The context when loading the asset
  75493. * @param property The glTF property associated with the uri
  75494. * @param uri The uri to load
  75495. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75496. */
  75497. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75498. /**
  75499. * Define this method to modify the default behavior when loading buffer views.
  75500. * @param context The context when loading the asset
  75501. * @param bufferView The glTF buffer view property
  75502. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75503. */
  75504. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75505. /**
  75506. * Define this method to modify the default behavior when loading buffers.
  75507. * @param context The context when loading the asset
  75508. * @param buffer The glTF buffer property
  75509. * @param byteOffset The byte offset to load
  75510. * @param byteLength The byte length to load
  75511. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75512. */
  75513. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75514. }
  75515. }
  75516. declare module BABYLON.GLTF2 {
  75517. /**
  75518. * Helper class for working with arrays when loading the glTF asset
  75519. */
  75520. export class ArrayItem {
  75521. /**
  75522. * Gets an item from the given array.
  75523. * @param context The context when loading the asset
  75524. * @param array The array to get the item from
  75525. * @param index The index to the array
  75526. * @returns The array item
  75527. */
  75528. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75529. /**
  75530. * Assign an `index` field to each item of the given array.
  75531. * @param array The array of items
  75532. */
  75533. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75534. }
  75535. /**
  75536. * The glTF 2.0 loader
  75537. */
  75538. export class GLTFLoader implements IGLTFLoader {
  75539. /** @hidden */
  75540. _completePromises: Promise<any>[];
  75541. /** @hidden */
  75542. _forAssetContainer: boolean;
  75543. /** Storage */
  75544. _babylonLights: Light[];
  75545. private _disposed;
  75546. private _parent;
  75547. private _state;
  75548. private _extensions;
  75549. private _rootUrl;
  75550. private _fileName;
  75551. private _uniqueRootUrl;
  75552. private _gltf;
  75553. private _bin;
  75554. private _babylonScene;
  75555. private _rootBabylonMesh;
  75556. private _defaultBabylonMaterialData;
  75557. private _progressCallback?;
  75558. private _requests;
  75559. private static _RegisteredExtensions;
  75560. /**
  75561. * The default glTF sampler.
  75562. */
  75563. static readonly DefaultSampler: ISampler;
  75564. /**
  75565. * Registers a loader extension.
  75566. * @param name The name of the loader extension.
  75567. * @param factory The factory function that creates the loader extension.
  75568. */
  75569. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75570. /**
  75571. * Unregisters a loader extension.
  75572. * @param name The name of the loader extension.
  75573. * @returns A boolean indicating whether the extension has been unregistered
  75574. */
  75575. static UnregisterExtension(name: string): boolean;
  75576. /**
  75577. * The loader state.
  75578. */
  75579. get state(): Nullable<GLTFLoaderState>;
  75580. /**
  75581. * The object that represents the glTF JSON.
  75582. */
  75583. get gltf(): IGLTF;
  75584. /**
  75585. * The BIN chunk of a binary glTF.
  75586. */
  75587. get bin(): Nullable<IDataBuffer>;
  75588. /**
  75589. * The parent file loader.
  75590. */
  75591. get parent(): GLTFFileLoader;
  75592. /**
  75593. * The Babylon scene when loading the asset.
  75594. */
  75595. get babylonScene(): Scene;
  75596. /**
  75597. * The root Babylon mesh when loading the asset.
  75598. */
  75599. get rootBabylonMesh(): Mesh;
  75600. /** @hidden */
  75601. constructor(parent: GLTFFileLoader);
  75602. /** @hidden */
  75603. dispose(): void;
  75604. /** @hidden */
  75605. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75606. /** @hidden */
  75607. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75608. private _loadAsync;
  75609. private _loadData;
  75610. private _setupData;
  75611. private _loadExtensions;
  75612. private _checkExtensions;
  75613. private _setState;
  75614. private _createRootNode;
  75615. /**
  75616. * Loads a glTF scene.
  75617. * @param context The context when loading the asset
  75618. * @param scene The glTF scene property
  75619. * @returns A promise that resolves when the load is complete
  75620. */
  75621. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75622. private _forEachPrimitive;
  75623. private _getMeshes;
  75624. private _getTransformNodes;
  75625. private _getSkeletons;
  75626. private _getAnimationGroups;
  75627. private _startAnimations;
  75628. /**
  75629. * Loads a glTF node.
  75630. * @param context The context when loading the asset
  75631. * @param node The glTF node property
  75632. * @param assign A function called synchronously after parsing the glTF properties
  75633. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75634. */
  75635. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75636. private _loadMeshAsync;
  75637. /**
  75638. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75639. * @param context The context when loading the asset
  75640. * @param name The mesh name when loading the asset
  75641. * @param node The glTF node when loading the asset
  75642. * @param mesh The glTF mesh when loading the asset
  75643. * @param primitive The glTF mesh primitive property
  75644. * @param assign A function called synchronously after parsing the glTF properties
  75645. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75646. */
  75647. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75648. private _loadVertexDataAsync;
  75649. private _createMorphTargets;
  75650. private _loadMorphTargetsAsync;
  75651. private _loadMorphTargetVertexDataAsync;
  75652. private static _LoadTransform;
  75653. private _loadSkinAsync;
  75654. private _loadBones;
  75655. private _loadBone;
  75656. private _loadSkinInverseBindMatricesDataAsync;
  75657. private _updateBoneMatrices;
  75658. private _getNodeMatrix;
  75659. /**
  75660. * Loads a glTF camera.
  75661. * @param context The context when loading the asset
  75662. * @param camera The glTF camera property
  75663. * @param assign A function called synchronously after parsing the glTF properties
  75664. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75665. */
  75666. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75667. private _loadAnimationsAsync;
  75668. /**
  75669. * Loads a glTF animation.
  75670. * @param context The context when loading the asset
  75671. * @param animation The glTF animation property
  75672. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75673. */
  75674. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75675. /**
  75676. * @hidden Loads a glTF animation channel.
  75677. * @param context The context when loading the asset
  75678. * @param animationContext The context of the animation when loading the asset
  75679. * @param animation The glTF animation property
  75680. * @param channel The glTF animation channel property
  75681. * @param babylonAnimationGroup The babylon animation group property
  75682. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75683. * @returns A void promise when the channel load is complete
  75684. */
  75685. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75686. private _loadAnimationSamplerAsync;
  75687. private _loadBufferAsync;
  75688. /**
  75689. * Loads a glTF buffer view.
  75690. * @param context The context when loading the asset
  75691. * @param bufferView The glTF buffer view property
  75692. * @returns A promise that resolves with the loaded data when the load is complete
  75693. */
  75694. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75695. private _loadAccessorAsync;
  75696. private _loadFloatAccessorAsync;
  75697. private _loadIndicesAccessorAsync;
  75698. private _loadVertexBufferViewAsync;
  75699. private _loadVertexAccessorAsync;
  75700. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75701. /** @hidden */
  75702. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75703. private _createDefaultMaterial;
  75704. /**
  75705. * Creates a Babylon material from a glTF material.
  75706. * @param context The context when loading the asset
  75707. * @param material The glTF material property
  75708. * @param babylonDrawMode The draw mode for the Babylon material
  75709. * @returns The Babylon material
  75710. */
  75711. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75712. /**
  75713. * Loads properties from a glTF material into a Babylon material.
  75714. * @param context The context when loading the asset
  75715. * @param material The glTF material property
  75716. * @param babylonMaterial The Babylon material
  75717. * @returns A promise that resolves when the load is complete
  75718. */
  75719. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75720. /**
  75721. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75722. * @param context The context when loading the asset
  75723. * @param material The glTF material property
  75724. * @param babylonMaterial The Babylon material
  75725. * @returns A promise that resolves when the load is complete
  75726. */
  75727. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75728. /**
  75729. * Loads the alpha properties from a glTF material into a Babylon material.
  75730. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75731. * @param context The context when loading the asset
  75732. * @param material The glTF material property
  75733. * @param babylonMaterial The Babylon material
  75734. */
  75735. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75736. /**
  75737. * Loads a glTF texture info.
  75738. * @param context The context when loading the asset
  75739. * @param textureInfo The glTF texture info property
  75740. * @param assign A function called synchronously after parsing the glTF properties
  75741. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75742. */
  75743. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75744. /** @hidden */
  75745. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75746. /** @hidden */
  75747. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75748. private _loadSampler;
  75749. /**
  75750. * Loads a glTF image.
  75751. * @param context The context when loading the asset
  75752. * @param image The glTF image property
  75753. * @returns A promise that resolves with the loaded data when the load is complete
  75754. */
  75755. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75756. /**
  75757. * Loads a glTF uri.
  75758. * @param context The context when loading the asset
  75759. * @param property The glTF property associated with the uri
  75760. * @param uri The base64 or relative uri
  75761. * @returns A promise that resolves with the loaded data when the load is complete
  75762. */
  75763. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75764. private _onProgress;
  75765. /**
  75766. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75767. * @param babylonObject the Babylon object with metadata
  75768. * @param pointer the JSON pointer
  75769. */
  75770. static AddPointerMetadata(babylonObject: {
  75771. metadata: any;
  75772. }, pointer: string): void;
  75773. private static _GetTextureWrapMode;
  75774. private static _GetTextureSamplingMode;
  75775. private static _GetTypedArrayConstructor;
  75776. private static _GetTypedArray;
  75777. private static _GetNumComponents;
  75778. private static _ValidateUri;
  75779. private static _GetDrawMode;
  75780. private _compileMaterialsAsync;
  75781. private _compileShadowGeneratorsAsync;
  75782. private _forEachExtensions;
  75783. private _applyExtensions;
  75784. private _extensionsOnLoading;
  75785. private _extensionsOnReady;
  75786. private _extensionsLoadSceneAsync;
  75787. private _extensionsLoadNodeAsync;
  75788. private _extensionsLoadCameraAsync;
  75789. private _extensionsLoadVertexDataAsync;
  75790. private _extensionsLoadMeshPrimitiveAsync;
  75791. private _extensionsLoadMaterialAsync;
  75792. private _extensionsCreateMaterial;
  75793. private _extensionsLoadMaterialPropertiesAsync;
  75794. private _extensionsLoadTextureInfoAsync;
  75795. private _extensionsLoadTextureAsync;
  75796. private _extensionsLoadAnimationAsync;
  75797. private _extensionsLoadSkinAsync;
  75798. private _extensionsLoadUriAsync;
  75799. private _extensionsLoadBufferViewAsync;
  75800. private _extensionsLoadBufferAsync;
  75801. /**
  75802. * Helper method called by a loader extension to load an glTF extension.
  75803. * @param context The context when loading the asset
  75804. * @param property The glTF property to load the extension from
  75805. * @param extensionName The name of the extension to load
  75806. * @param actionAsync The action to run
  75807. * @returns The promise returned by actionAsync or null if the extension does not exist
  75808. */
  75809. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75810. /**
  75811. * Helper method called by a loader extension to load a glTF extra.
  75812. * @param context The context when loading the asset
  75813. * @param property The glTF property to load the extra from
  75814. * @param extensionName The name of the extension to load
  75815. * @param actionAsync The action to run
  75816. * @returns The promise returned by actionAsync or null if the extra does not exist
  75817. */
  75818. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75819. /**
  75820. * Checks for presence of an extension.
  75821. * @param name The name of the extension to check
  75822. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75823. */
  75824. isExtensionUsed(name: string): boolean;
  75825. /**
  75826. * Increments the indentation level and logs a message.
  75827. * @param message The message to log
  75828. */
  75829. logOpen(message: string): void;
  75830. /**
  75831. * Decrements the indentation level.
  75832. */
  75833. logClose(): void;
  75834. /**
  75835. * Logs a message
  75836. * @param message The message to log
  75837. */
  75838. log(message: string): void;
  75839. /**
  75840. * Starts a performance counter.
  75841. * @param counterName The name of the performance counter
  75842. */
  75843. startPerformanceCounter(counterName: string): void;
  75844. /**
  75845. * Ends a performance counter.
  75846. * @param counterName The name of the performance counter
  75847. */
  75848. endPerformanceCounter(counterName: string): void;
  75849. }
  75850. }
  75851. declare module BABYLON.GLTF2.Loader.Extensions {
  75852. /**
  75853. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75854. */
  75855. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75856. /**
  75857. * The name of this extension.
  75858. */
  75859. readonly name: string;
  75860. /**
  75861. * Defines whether this extension is enabled.
  75862. */
  75863. enabled: boolean;
  75864. private _loader;
  75865. private _lights?;
  75866. /** @hidden */
  75867. constructor(loader: GLTFLoader);
  75868. /** @hidden */
  75869. dispose(): void;
  75870. /** @hidden */
  75871. onLoading(): void;
  75872. /** @hidden */
  75873. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75874. private _loadLightAsync;
  75875. }
  75876. }
  75877. declare module BABYLON.GLTF2.Loader.Extensions {
  75878. /**
  75879. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75880. */
  75881. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75882. /**
  75883. * The name of this extension.
  75884. */
  75885. readonly name: string;
  75886. /**
  75887. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75888. */
  75889. dracoCompression?: DracoCompression;
  75890. /**
  75891. * Defines whether this extension is enabled.
  75892. */
  75893. enabled: boolean;
  75894. private _loader;
  75895. /** @hidden */
  75896. constructor(loader: GLTFLoader);
  75897. /** @hidden */
  75898. dispose(): void;
  75899. /** @hidden */
  75900. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75901. }
  75902. }
  75903. declare module BABYLON.GLTF2.Loader.Extensions {
  75904. /**
  75905. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  75906. */
  75907. export class KHR_lights implements IGLTFLoaderExtension {
  75908. /**
  75909. * The name of this extension.
  75910. */
  75911. readonly name: string;
  75912. /**
  75913. * Defines whether this extension is enabled.
  75914. */
  75915. enabled: boolean;
  75916. private _loader;
  75917. private _lights?;
  75918. /** @hidden */
  75919. constructor(loader: GLTFLoader);
  75920. /** @hidden */
  75921. dispose(): void;
  75922. /** @hidden */
  75923. onLoading(): void;
  75924. /** @hidden */
  75925. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75926. }
  75927. }
  75928. declare module BABYLON.GLTF2.Loader.Extensions {
  75929. /**
  75930. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75931. */
  75932. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75933. /**
  75934. * The name of this extension.
  75935. */
  75936. readonly name: string;
  75937. /**
  75938. * Defines whether this extension is enabled.
  75939. */
  75940. enabled: boolean;
  75941. /**
  75942. * Defines a number that determines the order the extensions are applied.
  75943. */
  75944. order: number;
  75945. private _loader;
  75946. /** @hidden */
  75947. constructor(loader: GLTFLoader);
  75948. /** @hidden */
  75949. dispose(): void;
  75950. /** @hidden */
  75951. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75952. private _loadSpecularGlossinessPropertiesAsync;
  75953. }
  75954. }
  75955. declare module BABYLON.GLTF2.Loader.Extensions {
  75956. /**
  75957. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75958. */
  75959. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75960. /**
  75961. * The name of this extension.
  75962. */
  75963. readonly name: string;
  75964. /**
  75965. * Defines whether this extension is enabled.
  75966. */
  75967. enabled: boolean;
  75968. /**
  75969. * Defines a number that determines the order the extensions are applied.
  75970. */
  75971. order: number;
  75972. private _loader;
  75973. /** @hidden */
  75974. constructor(loader: GLTFLoader);
  75975. /** @hidden */
  75976. dispose(): void;
  75977. /** @hidden */
  75978. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75979. private _loadUnlitPropertiesAsync;
  75980. }
  75981. }
  75982. declare module BABYLON.GLTF2.Loader.Extensions {
  75983. /**
  75984. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75985. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75986. * !!! Experimental Extension Subject to Changes !!!
  75987. */
  75988. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75989. /**
  75990. * The name of this extension.
  75991. */
  75992. readonly name: string;
  75993. /**
  75994. * Defines whether this extension is enabled.
  75995. */
  75996. enabled: boolean;
  75997. /**
  75998. * Defines a number that determines the order the extensions are applied.
  75999. */
  76000. order: number;
  76001. private _loader;
  76002. /** @hidden */
  76003. constructor(loader: GLTFLoader);
  76004. /** @hidden */
  76005. dispose(): void;
  76006. /** @hidden */
  76007. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76008. private _loadClearCoatPropertiesAsync;
  76009. }
  76010. }
  76011. declare module BABYLON.GLTF2.Loader.Extensions {
  76012. /**
  76013. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76014. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76015. * !!! Experimental Extension Subject to Changes !!!
  76016. */
  76017. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76018. /**
  76019. * The name of this extension.
  76020. */
  76021. readonly name: string;
  76022. /**
  76023. * Defines whether this extension is enabled.
  76024. */
  76025. enabled: boolean;
  76026. /**
  76027. * Defines a number that determines the order the extensions are applied.
  76028. */
  76029. order: number;
  76030. private _loader;
  76031. /** @hidden */
  76032. constructor(loader: GLTFLoader);
  76033. /** @hidden */
  76034. dispose(): void;
  76035. /** @hidden */
  76036. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76037. private _loadSheenPropertiesAsync;
  76038. }
  76039. }
  76040. declare module BABYLON.GLTF2.Loader.Extensions {
  76041. /**
  76042. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76043. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76044. * !!! Experimental Extension Subject to Changes !!!
  76045. */
  76046. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76047. /**
  76048. * The name of this extension.
  76049. */
  76050. readonly name: string;
  76051. /**
  76052. * Defines whether this extension is enabled.
  76053. */
  76054. enabled: boolean;
  76055. /**
  76056. * Defines a number that determines the order the extensions are applied.
  76057. */
  76058. order: number;
  76059. private _loader;
  76060. /** @hidden */
  76061. constructor(loader: GLTFLoader);
  76062. /** @hidden */
  76063. dispose(): void;
  76064. /** @hidden */
  76065. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76066. private _loadSpecularPropertiesAsync;
  76067. }
  76068. }
  76069. declare module BABYLON.GLTF2.Loader.Extensions {
  76070. /**
  76071. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76072. */
  76073. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76074. /**
  76075. * The name of this extension.
  76076. */
  76077. readonly name: string;
  76078. /**
  76079. * Defines whether this extension is enabled.
  76080. */
  76081. enabled: boolean;
  76082. /** @hidden */
  76083. constructor(loader: GLTFLoader);
  76084. /** @hidden */
  76085. dispose(): void;
  76086. }
  76087. }
  76088. declare module BABYLON.GLTF2.Loader.Extensions {
  76089. /**
  76090. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76091. * !!! Experimental Extension Subject to Changes !!!
  76092. */
  76093. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76094. /** The name of this extension. */
  76095. readonly name: string;
  76096. /** Defines whether this extension is enabled. */
  76097. enabled: boolean;
  76098. private _loader;
  76099. /** @hidden */
  76100. constructor(loader: GLTFLoader);
  76101. /** @hidden */
  76102. dispose(): void;
  76103. /** @hidden */
  76104. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76105. }
  76106. }
  76107. declare module BABYLON.GLTF2.Loader.Extensions {
  76108. /**
  76109. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76110. */
  76111. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76112. /**
  76113. * The name of this extension.
  76114. */
  76115. readonly name: string;
  76116. /**
  76117. * Defines whether this extension is enabled.
  76118. */
  76119. enabled: boolean;
  76120. private _loader;
  76121. /** @hidden */
  76122. constructor(loader: GLTFLoader);
  76123. /** @hidden */
  76124. dispose(): void;
  76125. /** @hidden */
  76126. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76127. }
  76128. }
  76129. declare module BABYLON.GLTF2.Loader.Extensions {
  76130. /**
  76131. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76132. */
  76133. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76134. /**
  76135. * The name of this extension.
  76136. */
  76137. readonly name: string;
  76138. /**
  76139. * Defines whether this extension is enabled.
  76140. */
  76141. enabled: boolean;
  76142. private _loader;
  76143. private _clips;
  76144. private _emitters;
  76145. /** @hidden */
  76146. constructor(loader: GLTFLoader);
  76147. /** @hidden */
  76148. dispose(): void;
  76149. /** @hidden */
  76150. onLoading(): void;
  76151. /** @hidden */
  76152. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76153. /** @hidden */
  76154. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76155. /** @hidden */
  76156. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76157. private _loadClipAsync;
  76158. private _loadEmitterAsync;
  76159. private _getEventAction;
  76160. private _loadAnimationEventAsync;
  76161. }
  76162. }
  76163. declare module BABYLON.GLTF2.Loader.Extensions {
  76164. /**
  76165. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76166. */
  76167. export class MSFT_lod implements IGLTFLoaderExtension {
  76168. /**
  76169. * The name of this extension.
  76170. */
  76171. readonly name: string;
  76172. /**
  76173. * Defines whether this extension is enabled.
  76174. */
  76175. enabled: boolean;
  76176. /**
  76177. * Defines a number that determines the order the extensions are applied.
  76178. */
  76179. order: number;
  76180. /**
  76181. * Maximum number of LODs to load, starting from the lowest LOD.
  76182. */
  76183. maxLODsToLoad: number;
  76184. /**
  76185. * Observable raised when all node LODs of one level are loaded.
  76186. * The event data is the index of the loaded LOD starting from zero.
  76187. * Dispose the loader to cancel the loading of the next level of LODs.
  76188. */
  76189. onNodeLODsLoadedObservable: Observable<number>;
  76190. /**
  76191. * Observable raised when all material LODs of one level are loaded.
  76192. * The event data is the index of the loaded LOD starting from zero.
  76193. * Dispose the loader to cancel the loading of the next level of LODs.
  76194. */
  76195. onMaterialLODsLoadedObservable: Observable<number>;
  76196. private _loader;
  76197. private _nodeIndexLOD;
  76198. private _nodeSignalLODs;
  76199. private _nodePromiseLODs;
  76200. private _materialIndexLOD;
  76201. private _materialSignalLODs;
  76202. private _materialPromiseLODs;
  76203. private _indexLOD;
  76204. private _bufferLODs;
  76205. /** @hidden */
  76206. constructor(loader: GLTFLoader);
  76207. /** @hidden */
  76208. dispose(): void;
  76209. /** @hidden */
  76210. onReady(): void;
  76211. /** @hidden */
  76212. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76213. /** @hidden */
  76214. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76215. /** @hidden */
  76216. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76217. /** @hidden */
  76218. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76219. /** @hidden */
  76220. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76221. private _loadBufferLOD;
  76222. /**
  76223. * Gets an array of LOD properties from lowest to highest.
  76224. */
  76225. private _getLODs;
  76226. private _disposeTransformNode;
  76227. private _disposeMaterials;
  76228. }
  76229. }
  76230. declare module BABYLON.GLTF2.Loader.Extensions {
  76231. /** @hidden */
  76232. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76233. readonly name: string;
  76234. enabled: boolean;
  76235. private _loader;
  76236. constructor(loader: GLTFLoader);
  76237. dispose(): void;
  76238. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76239. }
  76240. }
  76241. declare module BABYLON.GLTF2.Loader.Extensions {
  76242. /** @hidden */
  76243. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76244. readonly name: string;
  76245. enabled: boolean;
  76246. private _loader;
  76247. constructor(loader: GLTFLoader);
  76248. dispose(): void;
  76249. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76250. }
  76251. }
  76252. declare module BABYLON.GLTF2.Loader.Extensions {
  76253. /**
  76254. * Store glTF extras (if present) in BJS objects' metadata
  76255. */
  76256. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76257. /**
  76258. * The name of this extension.
  76259. */
  76260. readonly name: string;
  76261. /**
  76262. * Defines whether this extension is enabled.
  76263. */
  76264. enabled: boolean;
  76265. private _loader;
  76266. private _assignExtras;
  76267. /** @hidden */
  76268. constructor(loader: GLTFLoader);
  76269. /** @hidden */
  76270. dispose(): void;
  76271. /** @hidden */
  76272. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76273. /** @hidden */
  76274. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76275. /** @hidden */
  76276. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76277. }
  76278. }
  76279. declare module BABYLON {
  76280. /**
  76281. * Class reading and parsing the MTL file bundled with the obj file.
  76282. */
  76283. export class MTLFileLoader {
  76284. /**
  76285. * Invert Y-Axis of referenced textures on load
  76286. */
  76287. static INVERT_TEXTURE_Y: boolean;
  76288. /**
  76289. * All material loaded from the mtl will be set here
  76290. */
  76291. materials: StandardMaterial[];
  76292. /**
  76293. * This function will read the mtl file and create each material described inside
  76294. * This function could be improve by adding :
  76295. * -some component missing (Ni, Tf...)
  76296. * -including the specific options available
  76297. *
  76298. * @param scene defines the scene the material will be created in
  76299. * @param data defines the mtl data to parse
  76300. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76301. * @param forAssetContainer defines if the material should be registered in the scene
  76302. */
  76303. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76304. /**
  76305. * Gets the texture for the material.
  76306. *
  76307. * If the material is imported from input file,
  76308. * We sanitize the url to ensure it takes the textre from aside the material.
  76309. *
  76310. * @param rootUrl The root url to load from
  76311. * @param value The value stored in the mtl
  76312. * @return The Texture
  76313. */
  76314. private static _getTexture;
  76315. }
  76316. }
  76317. declare module BABYLON {
  76318. /**
  76319. * Options for loading OBJ/MTL files
  76320. */
  76321. type MeshLoadOptions = {
  76322. /**
  76323. * Defines if UVs are optimized by default during load.
  76324. */
  76325. OptimizeWithUV: boolean;
  76326. /**
  76327. * Defines custom scaling of UV coordinates of loaded meshes.
  76328. */
  76329. UVScaling: Vector2;
  76330. /**
  76331. * Invert model on y-axis (does a model scaling inversion)
  76332. */
  76333. InvertY: boolean;
  76334. /**
  76335. * Invert Y-Axis of referenced textures on load
  76336. */
  76337. InvertTextureY: boolean;
  76338. /**
  76339. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76340. */
  76341. ImportVertexColors: boolean;
  76342. /**
  76343. * Compute the normals for the model, even if normals are present in the file.
  76344. */
  76345. ComputeNormals: boolean;
  76346. /**
  76347. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76348. */
  76349. SkipMaterials: boolean;
  76350. /**
  76351. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76352. */
  76353. MaterialLoadingFailsSilently: boolean;
  76354. };
  76355. /**
  76356. * OBJ file type loader.
  76357. * This is a babylon scene loader plugin.
  76358. */
  76359. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76360. /**
  76361. * Defines if UVs are optimized by default during load.
  76362. */
  76363. static OPTIMIZE_WITH_UV: boolean;
  76364. /**
  76365. * Invert model on y-axis (does a model scaling inversion)
  76366. */
  76367. static INVERT_Y: boolean;
  76368. /**
  76369. * Invert Y-Axis of referenced textures on load
  76370. */
  76371. static get INVERT_TEXTURE_Y(): boolean;
  76372. static set INVERT_TEXTURE_Y(value: boolean);
  76373. /**
  76374. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76375. */
  76376. static IMPORT_VERTEX_COLORS: boolean;
  76377. /**
  76378. * Compute the normals for the model, even if normals are present in the file.
  76379. */
  76380. static COMPUTE_NORMALS: boolean;
  76381. /**
  76382. * Defines custom scaling of UV coordinates of loaded meshes.
  76383. */
  76384. static UV_SCALING: Vector2;
  76385. /**
  76386. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76387. */
  76388. static SKIP_MATERIALS: boolean;
  76389. /**
  76390. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76391. *
  76392. * Defaults to true for backwards compatibility.
  76393. */
  76394. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76395. /**
  76396. * Defines the name of the plugin.
  76397. */
  76398. name: string;
  76399. /**
  76400. * Defines the extension the plugin is able to load.
  76401. */
  76402. extensions: string;
  76403. /** @hidden */
  76404. obj: RegExp;
  76405. /** @hidden */
  76406. group: RegExp;
  76407. /** @hidden */
  76408. mtllib: RegExp;
  76409. /** @hidden */
  76410. usemtl: RegExp;
  76411. /** @hidden */
  76412. smooth: RegExp;
  76413. /** @hidden */
  76414. vertexPattern: RegExp;
  76415. /** @hidden */
  76416. normalPattern: RegExp;
  76417. /** @hidden */
  76418. uvPattern: RegExp;
  76419. /** @hidden */
  76420. facePattern1: RegExp;
  76421. /** @hidden */
  76422. facePattern2: RegExp;
  76423. /** @hidden */
  76424. facePattern3: RegExp;
  76425. /** @hidden */
  76426. facePattern4: RegExp;
  76427. /** @hidden */
  76428. facePattern5: RegExp;
  76429. private _forAssetContainer;
  76430. private _meshLoadOptions;
  76431. /**
  76432. * Creates loader for .OBJ files
  76433. *
  76434. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76435. */
  76436. constructor(meshLoadOptions?: MeshLoadOptions);
  76437. private static get currentMeshLoadOptions();
  76438. /**
  76439. * Calls synchronously the MTL file attached to this obj.
  76440. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76441. * Without this function materials are not displayed in the first frame (but displayed after).
  76442. * In consequence it is impossible to get material information in your HTML file
  76443. *
  76444. * @param url The URL of the MTL file
  76445. * @param rootUrl
  76446. * @param onSuccess Callback function to be called when the MTL file is loaded
  76447. * @private
  76448. */
  76449. private _loadMTL;
  76450. /**
  76451. * Instantiates a OBJ file loader plugin.
  76452. * @returns the created plugin
  76453. */
  76454. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76455. /**
  76456. * If the data string can be loaded directly.
  76457. *
  76458. * @param data string containing the file data
  76459. * @returns if the data can be loaded directly
  76460. */
  76461. canDirectLoad(data: string): boolean;
  76462. /**
  76463. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76464. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76465. * @param scene the scene the meshes should be added to
  76466. * @param data the OBJ data to load
  76467. * @param rootUrl root url to load from
  76468. * @param onProgress event that fires when loading progress has occured
  76469. * @param fileName Defines the name of the file to load
  76470. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76471. */
  76472. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76473. meshes: AbstractMesh[];
  76474. particleSystems: IParticleSystem[];
  76475. skeletons: Skeleton[];
  76476. animationGroups: AnimationGroup[];
  76477. }>;
  76478. /**
  76479. * Imports all objects from the loaded OBJ data and adds them to the scene
  76480. * @param scene the scene the objects should be added to
  76481. * @param data the OBJ data to load
  76482. * @param rootUrl root url to load from
  76483. * @param onProgress event that fires when loading progress has occured
  76484. * @param fileName Defines the name of the file to load
  76485. * @returns a promise which completes when objects have been loaded to the scene
  76486. */
  76487. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76488. /**
  76489. * Load into an asset container.
  76490. * @param scene The scene to load into
  76491. * @param data The data to import
  76492. * @param rootUrl The root url for scene and resources
  76493. * @param onProgress The callback when the load progresses
  76494. * @param fileName Defines the name of the file to load
  76495. * @returns The loaded asset container
  76496. */
  76497. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76498. /**
  76499. * Read the OBJ file and create an Array of meshes.
  76500. * Each mesh contains all information given by the OBJ and the MTL file.
  76501. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76502. *
  76503. * @param meshesNames
  76504. * @param scene Scene The scene where are displayed the data
  76505. * @param data String The content of the obj file
  76506. * @param rootUrl String The path to the folder
  76507. * @returns Array<AbstractMesh>
  76508. * @private
  76509. */
  76510. private _parseSolid;
  76511. }
  76512. }
  76513. declare module BABYLON {
  76514. /**
  76515. * STL file type loader.
  76516. * This is a babylon scene loader plugin.
  76517. */
  76518. export class STLFileLoader implements ISceneLoaderPlugin {
  76519. /** @hidden */
  76520. solidPattern: RegExp;
  76521. /** @hidden */
  76522. facetsPattern: RegExp;
  76523. /** @hidden */
  76524. normalPattern: RegExp;
  76525. /** @hidden */
  76526. vertexPattern: RegExp;
  76527. /**
  76528. * Defines the name of the plugin.
  76529. */
  76530. name: string;
  76531. /**
  76532. * Defines the extensions the stl loader is able to load.
  76533. * force data to come in as an ArrayBuffer
  76534. * we'll convert to string if it looks like it's an ASCII .stl
  76535. */
  76536. extensions: ISceneLoaderPluginExtensions;
  76537. /**
  76538. * Import meshes into a scene.
  76539. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76540. * @param scene The scene to import into
  76541. * @param data The data to import
  76542. * @param rootUrl The root url for scene and resources
  76543. * @param meshes The meshes array to import into
  76544. * @param particleSystems The particle systems array to import into
  76545. * @param skeletons The skeletons array to import into
  76546. * @param onError The callback when import fails
  76547. * @returns True if successful or false otherwise
  76548. */
  76549. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76550. /**
  76551. * Load into a scene.
  76552. * @param scene The scene to load into
  76553. * @param data The data to import
  76554. * @param rootUrl The root url for scene and resources
  76555. * @param onError The callback when import fails
  76556. * @returns true if successful or false otherwise
  76557. */
  76558. load(scene: Scene, data: any, rootUrl: string): boolean;
  76559. /**
  76560. * Load into an asset container.
  76561. * @param scene The scene to load into
  76562. * @param data The data to import
  76563. * @param rootUrl The root url for scene and resources
  76564. * @param onError The callback when import fails
  76565. * @returns The loaded asset container
  76566. */
  76567. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76568. private _isBinary;
  76569. private _parseBinary;
  76570. private _parseASCII;
  76571. }
  76572. }
  76573. declare module BABYLON {
  76574. /**
  76575. * Class for generating OBJ data from a Babylon scene.
  76576. */
  76577. export class OBJExport {
  76578. /**
  76579. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76580. * @param mesh defines the list of meshes to serialize
  76581. * @param materials defines if materials should be exported
  76582. * @param matlibname defines the name of the associated mtl file
  76583. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76584. * @returns the OBJ content
  76585. */
  76586. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76587. /**
  76588. * Exports the material(s) of a mesh in .MTL file format (text)
  76589. * @param mesh defines the mesh to extract the material from
  76590. * @returns the mtl content
  76591. */
  76592. static MTL(mesh: Mesh): string;
  76593. }
  76594. }
  76595. declare module BABYLON {
  76596. /** @hidden */
  76597. export var __IGLTFExporterExtension: number;
  76598. /**
  76599. * Interface for extending the exporter
  76600. * @hidden
  76601. */
  76602. export interface IGLTFExporterExtension {
  76603. /**
  76604. * The name of this extension
  76605. */
  76606. readonly name: string;
  76607. /**
  76608. * Defines whether this extension is enabled
  76609. */
  76610. enabled: boolean;
  76611. /**
  76612. * Defines whether this extension is required
  76613. */
  76614. required: boolean;
  76615. }
  76616. }
  76617. declare module BABYLON.GLTF2.Exporter {
  76618. /** @hidden */
  76619. export var __IGLTFExporterExtensionV2: number;
  76620. /**
  76621. * Interface for a glTF exporter extension
  76622. * @hidden
  76623. */
  76624. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76625. /**
  76626. * Define this method to modify the default behavior before exporting a texture
  76627. * @param context The context when loading the asset
  76628. * @param babylonTexture The Babylon.js texture
  76629. * @param mimeType The mime-type of the generated image
  76630. * @returns A promise that resolves with the exported texture
  76631. */
  76632. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  76633. /**
  76634. * Define this method to get notified when a texture info is created
  76635. * @param context The context when loading the asset
  76636. * @param textureInfo The glTF texture info
  76637. * @param babylonTexture The Babylon.js texture
  76638. */
  76639. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76640. /**
  76641. * Define this method to modify the default behavior when exporting texture info
  76642. * @param context The context when loading the asset
  76643. * @param meshPrimitive glTF mesh primitive
  76644. * @param babylonSubMesh Babylon submesh
  76645. * @param binaryWriter glTF serializer binary writer instance
  76646. * @returns nullable IMeshPrimitive promise
  76647. */
  76648. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76649. /**
  76650. * Define this method to modify the default behavior when exporting a node
  76651. * @param context The context when exporting the node
  76652. * @param node glTF node
  76653. * @param babylonNode BabylonJS node
  76654. * @returns nullable INode promise
  76655. */
  76656. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  76657. [key: number]: number;
  76658. }): Promise<Nullable<INode>>;
  76659. /**
  76660. * Define this method to modify the default behavior when exporting a material
  76661. * @param material glTF material
  76662. * @param babylonMaterial BabylonJS material
  76663. * @returns nullable IMaterial promise
  76664. */
  76665. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  76666. /**
  76667. * Define this method to return additional textures to export from a material
  76668. * @param material glTF material
  76669. * @param babylonMaterial BabylonJS material
  76670. * @returns List of textures
  76671. */
  76672. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76673. /** Gets a boolean indicating that this extension was used */
  76674. wasUsed: boolean;
  76675. /** Gets a boolean indicating that this extension is required for the file to work */
  76676. required: boolean;
  76677. /**
  76678. * Called after the exporter state changes to EXPORTING
  76679. */
  76680. onExporting?(): void;
  76681. }
  76682. }
  76683. declare module BABYLON.GLTF2.Exporter {
  76684. /**
  76685. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76686. * @hidden
  76687. */
  76688. export class _GLTFMaterialExporter {
  76689. /**
  76690. * Represents the dielectric specular values for R, G and B
  76691. */
  76692. private static readonly _DielectricSpecular;
  76693. /**
  76694. * Allows the maximum specular power to be defined for material calculations
  76695. */
  76696. private static readonly _MaxSpecularPower;
  76697. /**
  76698. * Mapping to store textures
  76699. */
  76700. private _textureMap;
  76701. /**
  76702. * Numeric tolerance value
  76703. */
  76704. private static readonly _Epsilon;
  76705. /**
  76706. * Reference to the glTF Exporter
  76707. */
  76708. private _exporter;
  76709. constructor(exporter: _Exporter);
  76710. /**
  76711. * Specifies if two colors are approximately equal in value
  76712. * @param color1 first color to compare to
  76713. * @param color2 second color to compare to
  76714. * @param epsilon threshold value
  76715. */
  76716. private static FuzzyEquals;
  76717. /**
  76718. * Gets the materials from a Babylon scene and converts them to glTF materials
  76719. * @param scene babylonjs scene
  76720. * @param mimeType texture mime type
  76721. * @param images array of images
  76722. * @param textures array of textures
  76723. * @param materials array of materials
  76724. * @param imageData mapping of texture names to base64 textures
  76725. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76726. */
  76727. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76728. /**
  76729. * Makes a copy of the glTF material without the texture parameters
  76730. * @param originalMaterial original glTF material
  76731. * @returns glTF material without texture parameters
  76732. */
  76733. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76734. /**
  76735. * Specifies if the material has any texture parameters present
  76736. * @param material glTF Material
  76737. * @returns boolean specifying if texture parameters are present
  76738. */
  76739. _hasTexturesPresent(material: IMaterial): boolean;
  76740. /**
  76741. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76742. * @param babylonStandardMaterial
  76743. * @returns glTF Metallic Roughness Material representation
  76744. */
  76745. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76746. /**
  76747. * Computes the metallic factor
  76748. * @param diffuse diffused value
  76749. * @param specular specular value
  76750. * @param oneMinusSpecularStrength one minus the specular strength
  76751. * @returns metallic value
  76752. */
  76753. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76754. /**
  76755. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76756. * @param glTFMaterial glTF material
  76757. * @param babylonMaterial Babylon material
  76758. */
  76759. private static _SetAlphaMode;
  76760. /**
  76761. * Converts a Babylon Standard Material to a glTF Material
  76762. * @param babylonStandardMaterial BJS Standard Material
  76763. * @param mimeType mime type to use for the textures
  76764. * @param images array of glTF image interfaces
  76765. * @param textures array of glTF texture interfaces
  76766. * @param materials array of glTF material interfaces
  76767. * @param imageData map of image file name to data
  76768. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76769. */
  76770. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76771. private _finishMaterial;
  76772. /**
  76773. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76774. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76775. * @param mimeType mime type to use for the textures
  76776. * @param images array of glTF image interfaces
  76777. * @param textures array of glTF texture interfaces
  76778. * @param materials array of glTF material interfaces
  76779. * @param imageData map of image file name to data
  76780. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76781. */
  76782. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76783. /**
  76784. * Converts an image typed array buffer to a base64 image
  76785. * @param buffer typed array buffer
  76786. * @param width width of the image
  76787. * @param height height of the image
  76788. * @param mimeType mimetype of the image
  76789. * @returns base64 image string
  76790. */
  76791. private _createBase64FromCanvasAsync;
  76792. /**
  76793. * Generates a white texture based on the specified width and height
  76794. * @param width width of the texture in pixels
  76795. * @param height height of the texture in pixels
  76796. * @param scene babylonjs scene
  76797. * @returns white texture
  76798. */
  76799. private _createWhiteTexture;
  76800. /**
  76801. * 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
  76802. * @param texture1 first texture to resize
  76803. * @param texture2 second texture to resize
  76804. * @param scene babylonjs scene
  76805. * @returns resized textures or null
  76806. */
  76807. private _resizeTexturesToSameDimensions;
  76808. /**
  76809. * Converts an array of pixels to a Float32Array
  76810. * Throws an error if the pixel format is not supported
  76811. * @param pixels - array buffer containing pixel values
  76812. * @returns Float32 of pixels
  76813. */
  76814. private _convertPixelArrayToFloat32;
  76815. /**
  76816. * Convert Specular Glossiness Textures to Metallic Roughness
  76817. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76818. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76819. * @param diffuseTexture texture used to store diffuse information
  76820. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76821. * @param factors specular glossiness material factors
  76822. * @param mimeType the mime type to use for the texture
  76823. * @returns pbr metallic roughness interface or null
  76824. */
  76825. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76826. /**
  76827. * Converts specular glossiness material properties to metallic roughness
  76828. * @param specularGlossiness interface with specular glossiness material properties
  76829. * @returns interface with metallic roughness material properties
  76830. */
  76831. private _convertSpecularGlossinessToMetallicRoughness;
  76832. /**
  76833. * Calculates the surface reflectance, independent of lighting conditions
  76834. * @param color Color source to calculate brightness from
  76835. * @returns number representing the perceived brightness, or zero if color is undefined
  76836. */
  76837. private _getPerceivedBrightness;
  76838. /**
  76839. * Returns the maximum color component value
  76840. * @param color
  76841. * @returns maximum color component value, or zero if color is null or undefined
  76842. */
  76843. private _getMaxComponent;
  76844. /**
  76845. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76846. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76847. * @param mimeType mime type to use for the textures
  76848. * @param images array of glTF image interfaces
  76849. * @param textures array of glTF texture interfaces
  76850. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76851. * @param imageData map of image file name to data
  76852. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76853. * @returns glTF PBR Metallic Roughness factors
  76854. */
  76855. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76856. private _getGLTFTextureSampler;
  76857. private _getGLTFTextureWrapMode;
  76858. private _getGLTFTextureWrapModesSampler;
  76859. /**
  76860. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76861. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76862. * @param mimeType mime type to use for the textures
  76863. * @param images array of glTF image interfaces
  76864. * @param textures array of glTF texture interfaces
  76865. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76866. * @param imageData map of image file name to data
  76867. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76868. * @returns glTF PBR Metallic Roughness factors
  76869. */
  76870. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76871. /**
  76872. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76873. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76874. * @param mimeType mime type to use for the textures
  76875. * @param images array of glTF image interfaces
  76876. * @param textures array of glTF texture interfaces
  76877. * @param materials array of glTF material interfaces
  76878. * @param imageData map of image file name to data
  76879. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76880. */
  76881. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76882. private setMetallicRoughnessPbrMaterial;
  76883. private getPixelsFromTexture;
  76884. /**
  76885. * Extracts a texture from a Babylon texture into file data and glTF data
  76886. * @param babylonTexture Babylon texture to extract
  76887. * @param mimeType Mime Type of the babylonTexture
  76888. * @return glTF texture info, or null if the texture format is not supported
  76889. */
  76890. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76891. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76892. /**
  76893. * Builds a texture from base64 string
  76894. * @param base64Texture base64 texture string
  76895. * @param baseTextureName Name to use for the texture
  76896. * @param mimeType image mime type for the texture
  76897. * @param images array of images
  76898. * @param textures array of textures
  76899. * @param imageData map of image data
  76900. * @returns glTF texture info, or null if the texture format is not supported
  76901. */
  76902. private _getTextureInfoFromBase64;
  76903. }
  76904. }
  76905. declare module BABYLON {
  76906. /**
  76907. * Class for holding and downloading glTF file data
  76908. */
  76909. export class GLTFData {
  76910. /**
  76911. * Object which contains the file name as the key and its data as the value
  76912. */
  76913. glTFFiles: {
  76914. [fileName: string]: string | Blob;
  76915. };
  76916. /**
  76917. * Initializes the glTF file object
  76918. */
  76919. constructor();
  76920. /**
  76921. * Downloads the glTF data as files based on their names and data
  76922. */
  76923. downloadFiles(): void;
  76924. }
  76925. }
  76926. declare module BABYLON {
  76927. /**
  76928. * Holds a collection of exporter options and parameters
  76929. */
  76930. export interface IExportOptions {
  76931. /**
  76932. * Function which indicates whether a babylon node should be exported or not
  76933. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76934. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76935. */
  76936. shouldExportNode?(node: Node): boolean;
  76937. /**
  76938. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76939. * @param metadata source metadata to read from
  76940. * @returns the data to store to glTF node extras
  76941. */
  76942. metadataSelector?(metadata: any): any;
  76943. /**
  76944. * The sample rate to bake animation curves
  76945. */
  76946. animationSampleRate?: number;
  76947. /**
  76948. * Begin serialization without waiting for the scene to be ready
  76949. */
  76950. exportWithoutWaitingForScene?: boolean;
  76951. /**
  76952. * Indicates if coordinate system swapping root nodes should be included in export
  76953. */
  76954. includeCoordinateSystemConversionNodes?: boolean;
  76955. }
  76956. /**
  76957. * Class for generating glTF data from a Babylon scene.
  76958. */
  76959. export class GLTF2Export {
  76960. /**
  76961. * Exports the geometry of the scene to .gltf file format asynchronously
  76962. * @param scene Babylon scene with scene hierarchy information
  76963. * @param filePrefix File prefix to use when generating the glTF file
  76964. * @param options Exporter options
  76965. * @returns Returns an object with a .gltf file and associates texture names
  76966. * as keys and their data and paths as values
  76967. */
  76968. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76969. private static _PreExportAsync;
  76970. private static _PostExportAsync;
  76971. /**
  76972. * Exports the geometry of the scene to .glb file format asychronously
  76973. * @param scene Babylon scene with scene hierarchy information
  76974. * @param filePrefix File prefix to use when generating glb file
  76975. * @param options Exporter options
  76976. * @returns Returns an object with a .glb filename as key and data as value
  76977. */
  76978. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76979. }
  76980. }
  76981. declare module BABYLON.GLTF2.Exporter {
  76982. /**
  76983. * @hidden
  76984. */
  76985. export class _GLTFUtilities {
  76986. /**
  76987. * Creates a buffer view based on the supplied arguments
  76988. * @param bufferIndex index value of the specified buffer
  76989. * @param byteOffset byte offset value
  76990. * @param byteLength byte length of the bufferView
  76991. * @param byteStride byte distance between conequential elements
  76992. * @param name name of the buffer view
  76993. * @returns bufferView for glTF
  76994. */
  76995. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76996. /**
  76997. * Creates an accessor based on the supplied arguments
  76998. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76999. * @param name The name of the accessor
  77000. * @param type The type of the accessor
  77001. * @param componentType The datatype of components in the attribute
  77002. * @param count The number of attributes referenced by this accessor
  77003. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77004. * @param min Minimum value of each component in this attribute
  77005. * @param max Maximum value of each component in this attribute
  77006. * @returns accessor for glTF
  77007. */
  77008. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77009. /**
  77010. * Calculates the minimum and maximum values of an array of position floats
  77011. * @param positions Positions array of a mesh
  77012. * @param vertexStart Starting vertex offset to calculate min and max values
  77013. * @param vertexCount Number of vertices to check for min and max values
  77014. * @returns min number array and max number array
  77015. */
  77016. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77017. min: number[];
  77018. max: number[];
  77019. };
  77020. /**
  77021. * Converts a new right-handed Vector3
  77022. * @param vector vector3 array
  77023. * @returns right-handed Vector3
  77024. */
  77025. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77026. /**
  77027. * Converts a Vector3 to right-handed
  77028. * @param vector Vector3 to convert to right-handed
  77029. */
  77030. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77031. /**
  77032. * Converts a three element number array to right-handed
  77033. * @param vector number array to convert to right-handed
  77034. */
  77035. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77036. /**
  77037. * Converts a new right-handed Vector3
  77038. * @param vector vector3 array
  77039. * @returns right-handed Vector3
  77040. */
  77041. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77042. /**
  77043. * Converts a Vector3 to right-handed
  77044. * @param vector Vector3 to convert to right-handed
  77045. */
  77046. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77047. /**
  77048. * Converts a three element number array to right-handed
  77049. * @param vector number array to convert to right-handed
  77050. */
  77051. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77052. /**
  77053. * Converts a Vector4 to right-handed
  77054. * @param vector Vector4 to convert to right-handed
  77055. */
  77056. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77057. /**
  77058. * Converts a Vector4 to right-handed
  77059. * @param vector Vector4 to convert to right-handed
  77060. */
  77061. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77062. /**
  77063. * Converts a Quaternion to right-handed
  77064. * @param quaternion Source quaternion to convert to right-handed
  77065. */
  77066. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77067. /**
  77068. * Converts a Quaternion to right-handed
  77069. * @param quaternion Source quaternion to convert to right-handed
  77070. */
  77071. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77072. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77073. }
  77074. }
  77075. declare module BABYLON.GLTF2.Exporter {
  77076. /**
  77077. * Converts Babylon Scene into glTF 2.0.
  77078. * @hidden
  77079. */
  77080. export class _Exporter {
  77081. /**
  77082. * Stores the glTF to export
  77083. */
  77084. _glTF: IGLTF;
  77085. /**
  77086. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77087. */
  77088. _bufferViews: IBufferView[];
  77089. /**
  77090. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77091. */
  77092. _accessors: IAccessor[];
  77093. /**
  77094. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77095. */
  77096. _nodes: INode[];
  77097. /**
  77098. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77099. */
  77100. private _scenes;
  77101. /**
  77102. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77103. */
  77104. private _meshes;
  77105. /**
  77106. * Stores all the generated material information, which represents the appearance of each primitive
  77107. */
  77108. _materials: IMaterial[];
  77109. _materialMap: {
  77110. [materialID: number]: number;
  77111. };
  77112. /**
  77113. * Stores all the generated texture information, which is referenced by glTF materials
  77114. */
  77115. _textures: ITexture[];
  77116. /**
  77117. * Stores all the generated image information, which is referenced by glTF textures
  77118. */
  77119. _images: IImage[];
  77120. /**
  77121. * Stores all the texture samplers
  77122. */
  77123. _samplers: ISampler[];
  77124. /**
  77125. * Stores all the generated animation samplers, which is referenced by glTF animations
  77126. */
  77127. /**
  77128. * Stores the animations for glTF models
  77129. */
  77130. private _animations;
  77131. /**
  77132. * Stores the total amount of bytes stored in the glTF buffer
  77133. */
  77134. private _totalByteLength;
  77135. /**
  77136. * Stores a reference to the Babylon scene containing the source geometry and material information
  77137. */
  77138. _babylonScene: Scene;
  77139. /**
  77140. * Stores a map of the image data, where the key is the file name and the value
  77141. * is the image data
  77142. */
  77143. _imageData: {
  77144. [fileName: string]: {
  77145. data: Uint8Array;
  77146. mimeType: ImageMimeType;
  77147. };
  77148. };
  77149. /**
  77150. * Stores a map of the unique id of a node to its index in the node array
  77151. */
  77152. _nodeMap: {
  77153. [key: number]: number;
  77154. };
  77155. /**
  77156. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77157. */
  77158. _convertToRightHandedSystem: boolean;
  77159. /**
  77160. * Specifies if a Babylon node should be converted to right-handed on export
  77161. */
  77162. _convertToRightHandedSystemMap: {
  77163. [nodeId: number]: boolean;
  77164. };
  77165. _includeCoordinateSystemConversionNodes: boolean;
  77166. /**
  77167. * Baked animation sample rate
  77168. */
  77169. private _animationSampleRate;
  77170. private _options;
  77171. private _localEngine;
  77172. _glTFMaterialExporter: _GLTFMaterialExporter;
  77173. private _extensions;
  77174. private static _ExtensionNames;
  77175. private static _ExtensionFactories;
  77176. private _applyExtension;
  77177. private _applyExtensions;
  77178. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77179. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77180. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77181. [key: number]: number;
  77182. }): Promise<Nullable<INode>>;
  77183. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77184. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77185. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77186. private _forEachExtensions;
  77187. private _extensionsOnExporting;
  77188. /**
  77189. * Load glTF serializer extensions
  77190. */
  77191. private _loadExtensions;
  77192. /**
  77193. * Creates a glTF Exporter instance, which can accept optional exporter options
  77194. * @param babylonScene Babylon scene object
  77195. * @param options Options to modify the behavior of the exporter
  77196. */
  77197. constructor(babylonScene: Scene, options?: IExportOptions);
  77198. dispose(): void;
  77199. /**
  77200. * Registers a glTF exporter extension
  77201. * @param name Name of the extension to export
  77202. * @param factory The factory function that creates the exporter extension
  77203. */
  77204. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77205. /**
  77206. * Un-registers an exporter extension
  77207. * @param name The name fo the exporter extension
  77208. * @returns A boolean indicating whether the extension has been un-registered
  77209. */
  77210. static UnregisterExtension(name: string): boolean;
  77211. /**
  77212. * Lazy load a local engine
  77213. */
  77214. _getLocalEngine(): Engine;
  77215. private reorderIndicesBasedOnPrimitiveMode;
  77216. /**
  77217. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77218. * clock-wise during export to glTF
  77219. * @param submesh BabylonJS submesh
  77220. * @param primitiveMode Primitive mode of the mesh
  77221. * @param sideOrientation the winding order of the submesh
  77222. * @param vertexBufferKind The type of vertex attribute
  77223. * @param meshAttributeArray The vertex attribute data
  77224. * @param byteOffset The offset to the binary data
  77225. * @param binaryWriter The binary data for the glTF file
  77226. * @param convertToRightHandedSystem Converts the values to right-handed
  77227. */
  77228. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77229. /**
  77230. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77231. * clock-wise during export to glTF
  77232. * @param submesh BabylonJS submesh
  77233. * @param primitiveMode Primitive mode of the mesh
  77234. * @param sideOrientation the winding order of the submesh
  77235. * @param vertexBufferKind The type of vertex attribute
  77236. * @param meshAttributeArray The vertex attribute data
  77237. * @param byteOffset The offset to the binary data
  77238. * @param binaryWriter The binary data for the glTF file
  77239. * @param convertToRightHandedSystem Converts the values to right-handed
  77240. */
  77241. private reorderTriangleFillMode;
  77242. /**
  77243. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77244. * clock-wise during export to glTF
  77245. * @param submesh BabylonJS submesh
  77246. * @param primitiveMode Primitive mode of the mesh
  77247. * @param sideOrientation the winding order of the submesh
  77248. * @param vertexBufferKind The type of vertex attribute
  77249. * @param meshAttributeArray The vertex attribute data
  77250. * @param byteOffset The offset to the binary data
  77251. * @param binaryWriter The binary data for the glTF file
  77252. * @param convertToRightHandedSystem Converts the values to right-handed
  77253. */
  77254. private reorderTriangleStripDrawMode;
  77255. /**
  77256. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77257. * clock-wise during export to glTF
  77258. * @param submesh BabylonJS submesh
  77259. * @param primitiveMode Primitive mode of the mesh
  77260. * @param sideOrientation the winding order of the submesh
  77261. * @param vertexBufferKind The type of vertex attribute
  77262. * @param meshAttributeArray The vertex attribute data
  77263. * @param byteOffset The offset to the binary data
  77264. * @param binaryWriter The binary data for the glTF file
  77265. * @param convertToRightHandedSystem Converts the values to right-handed
  77266. */
  77267. private reorderTriangleFanMode;
  77268. /**
  77269. * Writes the vertex attribute data to binary
  77270. * @param vertices The vertices to write to the binary writer
  77271. * @param byteOffset The offset into the binary writer to overwrite binary data
  77272. * @param vertexAttributeKind The vertex attribute type
  77273. * @param meshAttributeArray The vertex attribute data
  77274. * @param binaryWriter The writer containing the binary data
  77275. * @param convertToRightHandedSystem Converts the values to right-handed
  77276. */
  77277. private writeVertexAttributeData;
  77278. /**
  77279. * Writes mesh attribute data to a data buffer
  77280. * Returns the bytelength of the data
  77281. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77282. * @param meshAttributeArray Array containing the attribute data
  77283. * @param binaryWriter The buffer to write the binary data to
  77284. * @param indices Used to specify the order of the vertex data
  77285. * @param convertToRightHandedSystem Converts the values to right-handed
  77286. */
  77287. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77288. /**
  77289. * Generates glTF json data
  77290. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77291. * @param glTFPrefix Text to use when prefixing a glTF file
  77292. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77293. * @returns json data as string
  77294. */
  77295. private generateJSON;
  77296. /**
  77297. * Generates data for .gltf and .bin files based on the glTF prefix string
  77298. * @param glTFPrefix Text to use when prefixing a glTF file
  77299. * @param dispose Dispose the exporter
  77300. * @returns GLTFData with glTF file data
  77301. */
  77302. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77303. /**
  77304. * Creates a binary buffer for glTF
  77305. * @returns array buffer for binary data
  77306. */
  77307. private _generateBinaryAsync;
  77308. /**
  77309. * Pads the number to a multiple of 4
  77310. * @param num number to pad
  77311. * @returns padded number
  77312. */
  77313. private _getPadding;
  77314. /**
  77315. * @hidden
  77316. */
  77317. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77318. /**
  77319. * Sets the TRS for each node
  77320. * @param node glTF Node for storing the transformation data
  77321. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77322. * @param convertToRightHandedSystem Converts the values to right-handed
  77323. */
  77324. private setNodeTransformation;
  77325. private getVertexBufferFromMesh;
  77326. /**
  77327. * Creates a bufferview based on the vertices type for the Babylon mesh
  77328. * @param kind Indicates the type of vertices data
  77329. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77330. * @param binaryWriter The buffer to write the bufferview data to
  77331. * @param convertToRightHandedSystem Converts the values to right-handed
  77332. */
  77333. private createBufferViewKind;
  77334. /**
  77335. * The primitive mode of the Babylon mesh
  77336. * @param babylonMesh The BabylonJS mesh
  77337. */
  77338. private getMeshPrimitiveMode;
  77339. /**
  77340. * Sets the primitive mode of the glTF mesh primitive
  77341. * @param meshPrimitive glTF mesh primitive
  77342. * @param primitiveMode The primitive mode
  77343. */
  77344. private setPrimitiveMode;
  77345. /**
  77346. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77347. * @param meshPrimitive glTF mesh primitive
  77348. * @param attributeKind vertex attribute
  77349. * @returns boolean specifying if uv coordinates are present
  77350. */
  77351. private setAttributeKind;
  77352. /**
  77353. * Sets data for the primitive attributes of each submesh
  77354. * @param mesh glTF Mesh object to store the primitive attribute information
  77355. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77356. * @param binaryWriter Buffer to write the attribute data to
  77357. * @param convertToRightHandedSystem Converts the values to right-handed
  77358. */
  77359. private setPrimitiveAttributesAsync;
  77360. /**
  77361. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77362. * @param node The node to check
  77363. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77364. */
  77365. private isBabylonCoordinateSystemConvertingNode;
  77366. /**
  77367. * Creates a glTF scene based on the array of meshes
  77368. * Returns the the total byte offset
  77369. * @param babylonScene Babylon scene to get the mesh data from
  77370. * @param binaryWriter Buffer to write binary data to
  77371. */
  77372. private createSceneAsync;
  77373. /**
  77374. * Creates a mapping of Node unique id to node index and handles animations
  77375. * @param babylonScene Babylon Scene
  77376. * @param nodes Babylon transform nodes
  77377. * @param binaryWriter Buffer to write binary data to
  77378. * @returns Node mapping of unique id to index
  77379. */
  77380. private createNodeMapAndAnimationsAsync;
  77381. /**
  77382. * Creates a glTF node from a Babylon mesh
  77383. * @param babylonMesh Source Babylon mesh
  77384. * @param binaryWriter Buffer for storing geometry data
  77385. * @param convertToRightHandedSystem Converts the values to right-handed
  77386. * @param nodeMap Node mapping of unique id to glTF node index
  77387. * @returns glTF node
  77388. */
  77389. private createNodeAsync;
  77390. }
  77391. /**
  77392. * @hidden
  77393. *
  77394. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77395. */
  77396. export class _BinaryWriter {
  77397. /**
  77398. * Array buffer which stores all binary data
  77399. */
  77400. private _arrayBuffer;
  77401. /**
  77402. * View of the array buffer
  77403. */
  77404. private _dataView;
  77405. /**
  77406. * byte offset of data in array buffer
  77407. */
  77408. private _byteOffset;
  77409. /**
  77410. * Initialize binary writer with an initial byte length
  77411. * @param byteLength Initial byte length of the array buffer
  77412. */
  77413. constructor(byteLength: number);
  77414. /**
  77415. * Resize the array buffer to the specified byte length
  77416. * @param byteLength
  77417. */
  77418. private resizeBuffer;
  77419. /**
  77420. * Get an array buffer with the length of the byte offset
  77421. * @returns ArrayBuffer resized to the byte offset
  77422. */
  77423. getArrayBuffer(): ArrayBuffer;
  77424. /**
  77425. * Get the byte offset of the array buffer
  77426. * @returns byte offset
  77427. */
  77428. getByteOffset(): number;
  77429. /**
  77430. * Stores an UInt8 in the array buffer
  77431. * @param entry
  77432. * @param byteOffset If defined, specifies where to set the value as an offset.
  77433. */
  77434. setUInt8(entry: number, byteOffset?: number): void;
  77435. /**
  77436. * Gets an UInt32 in the array buffer
  77437. * @param entry
  77438. * @param byteOffset If defined, specifies where to set the value as an offset.
  77439. */
  77440. getUInt32(byteOffset: number): number;
  77441. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77442. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77443. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77444. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77445. /**
  77446. * Stores a Float32 in the array buffer
  77447. * @param entry
  77448. */
  77449. setFloat32(entry: number, byteOffset?: number): void;
  77450. /**
  77451. * Stores an UInt32 in the array buffer
  77452. * @param entry
  77453. * @param byteOffset If defined, specifies where to set the value as an offset.
  77454. */
  77455. setUInt32(entry: number, byteOffset?: number): void;
  77456. }
  77457. }
  77458. declare module BABYLON.GLTF2.Exporter {
  77459. /**
  77460. * @hidden
  77461. * Interface to store animation data.
  77462. */
  77463. export interface _IAnimationData {
  77464. /**
  77465. * Keyframe data.
  77466. */
  77467. inputs: number[];
  77468. /**
  77469. * Value data.
  77470. */
  77471. outputs: number[][];
  77472. /**
  77473. * Animation interpolation data.
  77474. */
  77475. samplerInterpolation: AnimationSamplerInterpolation;
  77476. /**
  77477. * Minimum keyframe value.
  77478. */
  77479. inputsMin: number;
  77480. /**
  77481. * Maximum keyframe value.
  77482. */
  77483. inputsMax: number;
  77484. }
  77485. /**
  77486. * @hidden
  77487. */
  77488. export interface _IAnimationInfo {
  77489. /**
  77490. * The target channel for the animation
  77491. */
  77492. animationChannelTargetPath: AnimationChannelTargetPath;
  77493. /**
  77494. * The glTF accessor type for the data.
  77495. */
  77496. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77497. /**
  77498. * Specifies if quaternions should be used.
  77499. */
  77500. useQuaternion: boolean;
  77501. }
  77502. /**
  77503. * @hidden
  77504. * Utility class for generating glTF animation data from BabylonJS.
  77505. */
  77506. export class _GLTFAnimation {
  77507. /**
  77508. * @ignore
  77509. *
  77510. * Creates glTF channel animation from BabylonJS animation.
  77511. * @param babylonTransformNode - BabylonJS mesh.
  77512. * @param animation - animation.
  77513. * @param animationChannelTargetPath - The target animation channel.
  77514. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77515. * @param useQuaternion - Specifies if quaternions are used.
  77516. * @returns nullable IAnimationData
  77517. */
  77518. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77519. private static _DeduceAnimationInfo;
  77520. /**
  77521. * @ignore
  77522. * Create node animations from the transform node animations
  77523. * @param babylonNode
  77524. * @param runtimeGLTFAnimation
  77525. * @param idleGLTFAnimations
  77526. * @param nodeMap
  77527. * @param nodes
  77528. * @param binaryWriter
  77529. * @param bufferViews
  77530. * @param accessors
  77531. * @param convertToRightHandedSystem
  77532. * @param animationSampleRate
  77533. */
  77534. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77535. [key: number]: number;
  77536. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77537. /**
  77538. * @ignore
  77539. * Create node animations from the animation groups
  77540. * @param babylonScene
  77541. * @param glTFAnimations
  77542. * @param nodeMap
  77543. * @param nodes
  77544. * @param binaryWriter
  77545. * @param bufferViews
  77546. * @param accessors
  77547. * @param convertToRightHandedSystemMap
  77548. * @param animationSampleRate
  77549. */
  77550. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77551. [key: number]: number;
  77552. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  77553. [nodeId: number]: boolean;
  77554. }, animationSampleRate: number): void;
  77555. private static AddAnimation;
  77556. /**
  77557. * Create a baked animation
  77558. * @param babylonTransformNode BabylonJS mesh
  77559. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77560. * @param animationChannelTargetPath animation target channel
  77561. * @param minFrame minimum animation frame
  77562. * @param maxFrame maximum animation frame
  77563. * @param fps frames per second of the animation
  77564. * @param inputs input key frames of the animation
  77565. * @param outputs output key frame data of the animation
  77566. * @param convertToRightHandedSystem converts the values to right-handed
  77567. * @param useQuaternion specifies if quaternions should be used
  77568. */
  77569. private static _CreateBakedAnimation;
  77570. private static _ConvertFactorToVector3OrQuaternion;
  77571. private static _SetInterpolatedValue;
  77572. /**
  77573. * Creates linear animation from the animation key frames
  77574. * @param babylonTransformNode BabylonJS mesh
  77575. * @param animation BabylonJS animation
  77576. * @param animationChannelTargetPath The target animation channel
  77577. * @param frameDelta The difference between the last and first frame of the animation
  77578. * @param inputs Array to store the key frame times
  77579. * @param outputs Array to store the key frame data
  77580. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77581. * @param useQuaternion Specifies if quaternions are used in the animation
  77582. */
  77583. private static _CreateLinearOrStepAnimation;
  77584. /**
  77585. * Creates cubic spline animation from the animation key frames
  77586. * @param babylonTransformNode BabylonJS mesh
  77587. * @param animation BabylonJS animation
  77588. * @param animationChannelTargetPath The target animation channel
  77589. * @param frameDelta The difference between the last and first frame of the animation
  77590. * @param inputs Array to store the key frame times
  77591. * @param outputs Array to store the key frame data
  77592. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77593. * @param useQuaternion Specifies if quaternions are used in the animation
  77594. */
  77595. private static _CreateCubicSplineAnimation;
  77596. private static _GetBasePositionRotationOrScale;
  77597. /**
  77598. * Adds a key frame value
  77599. * @param keyFrame
  77600. * @param animation
  77601. * @param outputs
  77602. * @param animationChannelTargetPath
  77603. * @param basePositionRotationOrScale
  77604. * @param convertToRightHandedSystem
  77605. * @param useQuaternion
  77606. */
  77607. private static _AddKeyframeValue;
  77608. /**
  77609. * Determine the interpolation based on the key frames
  77610. * @param keyFrames
  77611. * @param animationChannelTargetPath
  77612. * @param useQuaternion
  77613. */
  77614. private static _DeduceInterpolation;
  77615. /**
  77616. * Adds an input tangent or output tangent to the output data
  77617. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77618. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77619. * @param outputs The animation data by keyframe
  77620. * @param animationChannelTargetPath The target animation channel
  77621. * @param interpolation The interpolation type
  77622. * @param keyFrame The key frame with the animation data
  77623. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77624. * @param useQuaternion Specifies if quaternions are used
  77625. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77626. */
  77627. private static AddSplineTangent;
  77628. /**
  77629. * Get the minimum and maximum key frames' frame values
  77630. * @param keyFrames animation key frames
  77631. * @returns the minimum and maximum key frame value
  77632. */
  77633. private static calculateMinMaxKeyFrames;
  77634. }
  77635. }
  77636. declare module BABYLON.GLTF2.Exporter {
  77637. /** @hidden */
  77638. export var textureTransformPixelShader: {
  77639. name: string;
  77640. shader: string;
  77641. };
  77642. }
  77643. declare module BABYLON.GLTF2.Exporter.Extensions {
  77644. /**
  77645. * @hidden
  77646. */
  77647. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77648. private _recordedTextures;
  77649. /** Name of this extension */
  77650. readonly name: string;
  77651. /** Defines whether this extension is enabled */
  77652. enabled: boolean;
  77653. /** Defines whether this extension is required */
  77654. required: boolean;
  77655. /** Reference to the glTF exporter */
  77656. private _wasUsed;
  77657. constructor(exporter: _Exporter);
  77658. dispose(): void;
  77659. /** @hidden */
  77660. get wasUsed(): boolean;
  77661. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77662. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77663. /**
  77664. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77665. * @param babylonTexture
  77666. * @param offset
  77667. * @param rotation
  77668. * @param scale
  77669. * @param scene
  77670. */
  77671. private _textureTransformTextureAsync;
  77672. }
  77673. }
  77674. declare module BABYLON.GLTF2.Exporter.Extensions {
  77675. /**
  77676. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77677. */
  77678. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77679. /** The name of this extension. */
  77680. readonly name: string;
  77681. /** Defines whether this extension is enabled. */
  77682. enabled: boolean;
  77683. /** Defines whether this extension is required */
  77684. required: boolean;
  77685. /** Reference to the glTF exporter */
  77686. private _exporter;
  77687. private _lights;
  77688. /** @hidden */
  77689. constructor(exporter: _Exporter);
  77690. /** @hidden */
  77691. dispose(): void;
  77692. /** @hidden */
  77693. get wasUsed(): boolean;
  77694. /** @hidden */
  77695. onExporting(): void;
  77696. /**
  77697. * Define this method to modify the default behavior when exporting a node
  77698. * @param context The context when exporting the node
  77699. * @param node glTF node
  77700. * @param babylonNode BabylonJS node
  77701. * @param nodeMap Node mapping of unique id to glTF node index
  77702. * @returns nullable INode promise
  77703. */
  77704. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77705. [key: number]: number;
  77706. }): Promise<Nullable<INode>>;
  77707. }
  77708. }
  77709. declare module BABYLON.GLTF2.Exporter.Extensions {
  77710. /**
  77711. * @hidden
  77712. */
  77713. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77714. /** Name of this extension */
  77715. readonly name: string;
  77716. /** Defines whether this extension is enabled */
  77717. enabled: boolean;
  77718. /** Defines whether this extension is required */
  77719. required: boolean;
  77720. /** Reference to the glTF exporter */
  77721. private _textureInfos;
  77722. private _exportedTextures;
  77723. private _wasUsed;
  77724. constructor(exporter: _Exporter);
  77725. dispose(): void;
  77726. /** @hidden */
  77727. get wasUsed(): boolean;
  77728. private _getTextureIndex;
  77729. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77730. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77731. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77732. }
  77733. }
  77734. declare module BABYLON {
  77735. /**
  77736. * Class for generating STL data from a Babylon scene.
  77737. */
  77738. export class STLExport {
  77739. /**
  77740. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77741. * @param meshes list defines the mesh to serialize
  77742. * @param download triggers the automatic download of the file.
  77743. * @param fileName changes the downloads fileName.
  77744. * @param binary changes the STL to a binary type.
  77745. * @param isLittleEndian toggle for binary type exporter.
  77746. * @returns the STL as UTF8 string
  77747. */
  77748. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77749. }
  77750. }
  77751. declare module "babylonjs-gltf2interface" {
  77752. export = BABYLON.GLTF2;
  77753. }
  77754. /**
  77755. * Module for glTF 2.0 Interface
  77756. */
  77757. declare module BABYLON.GLTF2 {
  77758. /**
  77759. * The datatype of the components in the attribute
  77760. */
  77761. const enum AccessorComponentType {
  77762. /**
  77763. * Byte
  77764. */
  77765. BYTE = 5120,
  77766. /**
  77767. * Unsigned Byte
  77768. */
  77769. UNSIGNED_BYTE = 5121,
  77770. /**
  77771. * Short
  77772. */
  77773. SHORT = 5122,
  77774. /**
  77775. * Unsigned Short
  77776. */
  77777. UNSIGNED_SHORT = 5123,
  77778. /**
  77779. * Unsigned Int
  77780. */
  77781. UNSIGNED_INT = 5125,
  77782. /**
  77783. * Float
  77784. */
  77785. FLOAT = 5126,
  77786. }
  77787. /**
  77788. * Specifies if the attirbute is a scalar, vector, or matrix
  77789. */
  77790. const enum AccessorType {
  77791. /**
  77792. * Scalar
  77793. */
  77794. SCALAR = "SCALAR",
  77795. /**
  77796. * Vector2
  77797. */
  77798. VEC2 = "VEC2",
  77799. /**
  77800. * Vector3
  77801. */
  77802. VEC3 = "VEC3",
  77803. /**
  77804. * Vector4
  77805. */
  77806. VEC4 = "VEC4",
  77807. /**
  77808. * Matrix2x2
  77809. */
  77810. MAT2 = "MAT2",
  77811. /**
  77812. * Matrix3x3
  77813. */
  77814. MAT3 = "MAT3",
  77815. /**
  77816. * Matrix4x4
  77817. */
  77818. MAT4 = "MAT4",
  77819. }
  77820. /**
  77821. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77822. */
  77823. const enum AnimationChannelTargetPath {
  77824. /**
  77825. * Translation
  77826. */
  77827. TRANSLATION = "translation",
  77828. /**
  77829. * Rotation
  77830. */
  77831. ROTATION = "rotation",
  77832. /**
  77833. * Scale
  77834. */
  77835. SCALE = "scale",
  77836. /**
  77837. * Weights
  77838. */
  77839. WEIGHTS = "weights",
  77840. }
  77841. /**
  77842. * Interpolation algorithm
  77843. */
  77844. const enum AnimationSamplerInterpolation {
  77845. /**
  77846. * The animated values are linearly interpolated between keyframes
  77847. */
  77848. LINEAR = "LINEAR",
  77849. /**
  77850. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77851. */
  77852. STEP = "STEP",
  77853. /**
  77854. * The animation's interpolation is computed using a cubic spline with specified tangents
  77855. */
  77856. CUBICSPLINE = "CUBICSPLINE",
  77857. }
  77858. /**
  77859. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77860. */
  77861. const enum CameraType {
  77862. /**
  77863. * A perspective camera containing properties to create a perspective projection matrix
  77864. */
  77865. PERSPECTIVE = "perspective",
  77866. /**
  77867. * An orthographic camera containing properties to create an orthographic projection matrix
  77868. */
  77869. ORTHOGRAPHIC = "orthographic",
  77870. }
  77871. /**
  77872. * The mime-type of the image
  77873. */
  77874. const enum ImageMimeType {
  77875. /**
  77876. * JPEG Mime-type
  77877. */
  77878. JPEG = "image/jpeg",
  77879. /**
  77880. * PNG Mime-type
  77881. */
  77882. PNG = "image/png",
  77883. }
  77884. /**
  77885. * The alpha rendering mode of the material
  77886. */
  77887. const enum MaterialAlphaMode {
  77888. /**
  77889. * The alpha value is ignored and the rendered output is fully opaque
  77890. */
  77891. OPAQUE = "OPAQUE",
  77892. /**
  77893. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77894. */
  77895. MASK = "MASK",
  77896. /**
  77897. * 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)
  77898. */
  77899. BLEND = "BLEND",
  77900. }
  77901. /**
  77902. * The type of the primitives to render
  77903. */
  77904. const enum MeshPrimitiveMode {
  77905. /**
  77906. * Points
  77907. */
  77908. POINTS = 0,
  77909. /**
  77910. * Lines
  77911. */
  77912. LINES = 1,
  77913. /**
  77914. * Line Loop
  77915. */
  77916. LINE_LOOP = 2,
  77917. /**
  77918. * Line Strip
  77919. */
  77920. LINE_STRIP = 3,
  77921. /**
  77922. * Triangles
  77923. */
  77924. TRIANGLES = 4,
  77925. /**
  77926. * Triangle Strip
  77927. */
  77928. TRIANGLE_STRIP = 5,
  77929. /**
  77930. * Triangle Fan
  77931. */
  77932. TRIANGLE_FAN = 6,
  77933. }
  77934. /**
  77935. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77936. */
  77937. const enum TextureMagFilter {
  77938. /**
  77939. * Nearest
  77940. */
  77941. NEAREST = 9728,
  77942. /**
  77943. * Linear
  77944. */
  77945. LINEAR = 9729,
  77946. }
  77947. /**
  77948. * Minification filter. All valid values correspond to WebGL enums
  77949. */
  77950. const enum TextureMinFilter {
  77951. /**
  77952. * Nearest
  77953. */
  77954. NEAREST = 9728,
  77955. /**
  77956. * Linear
  77957. */
  77958. LINEAR = 9729,
  77959. /**
  77960. * Nearest Mip-Map Nearest
  77961. */
  77962. NEAREST_MIPMAP_NEAREST = 9984,
  77963. /**
  77964. * Linear Mipmap Nearest
  77965. */
  77966. LINEAR_MIPMAP_NEAREST = 9985,
  77967. /**
  77968. * Nearest Mipmap Linear
  77969. */
  77970. NEAREST_MIPMAP_LINEAR = 9986,
  77971. /**
  77972. * Linear Mipmap Linear
  77973. */
  77974. LINEAR_MIPMAP_LINEAR = 9987,
  77975. }
  77976. /**
  77977. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77978. */
  77979. const enum TextureWrapMode {
  77980. /**
  77981. * Clamp to Edge
  77982. */
  77983. CLAMP_TO_EDGE = 33071,
  77984. /**
  77985. * Mirrored Repeat
  77986. */
  77987. MIRRORED_REPEAT = 33648,
  77988. /**
  77989. * Repeat
  77990. */
  77991. REPEAT = 10497,
  77992. }
  77993. /**
  77994. * glTF Property
  77995. */
  77996. interface IProperty {
  77997. /**
  77998. * Dictionary object with extension-specific objects
  77999. */
  78000. extensions?: {
  78001. [key: string]: any;
  78002. };
  78003. /**
  78004. * Application-Specific data
  78005. */
  78006. extras?: any;
  78007. }
  78008. /**
  78009. * glTF Child of Root Property
  78010. */
  78011. interface IChildRootProperty extends IProperty {
  78012. /**
  78013. * The user-defined name of this object
  78014. */
  78015. name?: string;
  78016. }
  78017. /**
  78018. * Indices of those attributes that deviate from their initialization value
  78019. */
  78020. interface IAccessorSparseIndices extends IProperty {
  78021. /**
  78022. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78023. */
  78024. bufferView: number;
  78025. /**
  78026. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78027. */
  78028. byteOffset?: number;
  78029. /**
  78030. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78031. */
  78032. componentType: AccessorComponentType;
  78033. }
  78034. /**
  78035. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78036. */
  78037. interface IAccessorSparseValues extends IProperty {
  78038. /**
  78039. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78040. */
  78041. bufferView: number;
  78042. /**
  78043. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78044. */
  78045. byteOffset?: number;
  78046. }
  78047. /**
  78048. * Sparse storage of attributes that deviate from their initialization value
  78049. */
  78050. interface IAccessorSparse extends IProperty {
  78051. /**
  78052. * The number of attributes encoded in this sparse accessor
  78053. */
  78054. count: number;
  78055. /**
  78056. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78057. */
  78058. indices: IAccessorSparseIndices;
  78059. /**
  78060. * 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
  78061. */
  78062. values: IAccessorSparseValues;
  78063. }
  78064. /**
  78065. * 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
  78066. */
  78067. interface IAccessor extends IChildRootProperty {
  78068. /**
  78069. * The index of the bufferview
  78070. */
  78071. bufferView?: number;
  78072. /**
  78073. * The offset relative to the start of the bufferView in bytes
  78074. */
  78075. byteOffset?: number;
  78076. /**
  78077. * The datatype of components in the attribute
  78078. */
  78079. componentType: AccessorComponentType;
  78080. /**
  78081. * Specifies whether integer data values should be normalized
  78082. */
  78083. normalized?: boolean;
  78084. /**
  78085. * The number of attributes referenced by this accessor
  78086. */
  78087. count: number;
  78088. /**
  78089. * Specifies if the attribute is a scalar, vector, or matrix
  78090. */
  78091. type: AccessorType;
  78092. /**
  78093. * Maximum value of each component in this attribute
  78094. */
  78095. max?: number[];
  78096. /**
  78097. * Minimum value of each component in this attribute
  78098. */
  78099. min?: number[];
  78100. /**
  78101. * Sparse storage of attributes that deviate from their initialization value
  78102. */
  78103. sparse?: IAccessorSparse;
  78104. }
  78105. /**
  78106. * Targets an animation's sampler at a node's property
  78107. */
  78108. interface IAnimationChannel extends IProperty {
  78109. /**
  78110. * The index of a sampler in this animation used to compute the value for the target
  78111. */
  78112. sampler: number;
  78113. /**
  78114. * The index of the node and TRS property to target
  78115. */
  78116. target: IAnimationChannelTarget;
  78117. }
  78118. /**
  78119. * The index of the node and TRS property that an animation channel targets
  78120. */
  78121. interface IAnimationChannelTarget extends IProperty {
  78122. /**
  78123. * The index of the node to target
  78124. */
  78125. node: number;
  78126. /**
  78127. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78128. */
  78129. path: AnimationChannelTargetPath;
  78130. }
  78131. /**
  78132. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78133. */
  78134. interface IAnimationSampler extends IProperty {
  78135. /**
  78136. * The index of an accessor containing keyframe input values, e.g., time
  78137. */
  78138. input: number;
  78139. /**
  78140. * Interpolation algorithm
  78141. */
  78142. interpolation?: AnimationSamplerInterpolation;
  78143. /**
  78144. * The index of an accessor, containing keyframe output values
  78145. */
  78146. output: number;
  78147. }
  78148. /**
  78149. * A keyframe animation
  78150. */
  78151. interface IAnimation extends IChildRootProperty {
  78152. /**
  78153. * An array of channels, each of which targets an animation's sampler at a node's property
  78154. */
  78155. channels: IAnimationChannel[];
  78156. /**
  78157. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78158. */
  78159. samplers: IAnimationSampler[];
  78160. }
  78161. /**
  78162. * Metadata about the glTF asset
  78163. */
  78164. interface IAsset extends IChildRootProperty {
  78165. /**
  78166. * A copyright message suitable for display to credit the content creator
  78167. */
  78168. copyright?: string;
  78169. /**
  78170. * Tool that generated this glTF model. Useful for debugging
  78171. */
  78172. generator?: string;
  78173. /**
  78174. * The glTF version that this asset targets
  78175. */
  78176. version: string;
  78177. /**
  78178. * The minimum glTF version that this asset targets
  78179. */
  78180. minVersion?: string;
  78181. }
  78182. /**
  78183. * A buffer points to binary geometry, animation, or skins
  78184. */
  78185. interface IBuffer extends IChildRootProperty {
  78186. /**
  78187. * 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
  78188. */
  78189. uri?: string;
  78190. /**
  78191. * The length of the buffer in bytes
  78192. */
  78193. byteLength: number;
  78194. }
  78195. /**
  78196. * A view into a buffer generally representing a subset of the buffer
  78197. */
  78198. interface IBufferView extends IChildRootProperty {
  78199. /**
  78200. * The index of the buffer
  78201. */
  78202. buffer: number;
  78203. /**
  78204. * The offset into the buffer in bytes
  78205. */
  78206. byteOffset?: number;
  78207. /**
  78208. * The lenth of the bufferView in bytes
  78209. */
  78210. byteLength: number;
  78211. /**
  78212. * The stride, in bytes
  78213. */
  78214. byteStride?: number;
  78215. }
  78216. /**
  78217. * An orthographic camera containing properties to create an orthographic projection matrix
  78218. */
  78219. interface ICameraOrthographic extends IProperty {
  78220. /**
  78221. * The floating-point horizontal magnification of the view. Must not be zero
  78222. */
  78223. xmag: number;
  78224. /**
  78225. * The floating-point vertical magnification of the view. Must not be zero
  78226. */
  78227. ymag: number;
  78228. /**
  78229. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78230. */
  78231. zfar: number;
  78232. /**
  78233. * The floating-point distance to the near clipping plane
  78234. */
  78235. znear: number;
  78236. }
  78237. /**
  78238. * A perspective camera containing properties to create a perspective projection matrix
  78239. */
  78240. interface ICameraPerspective extends IProperty {
  78241. /**
  78242. * The floating-point aspect ratio of the field of view
  78243. */
  78244. aspectRatio?: number;
  78245. /**
  78246. * The floating-point vertical field of view in radians
  78247. */
  78248. yfov: number;
  78249. /**
  78250. * The floating-point distance to the far clipping plane
  78251. */
  78252. zfar?: number;
  78253. /**
  78254. * The floating-point distance to the near clipping plane
  78255. */
  78256. znear: number;
  78257. }
  78258. /**
  78259. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78260. */
  78261. interface ICamera extends IChildRootProperty {
  78262. /**
  78263. * An orthographic camera containing properties to create an orthographic projection matrix
  78264. */
  78265. orthographic?: ICameraOrthographic;
  78266. /**
  78267. * A perspective camera containing properties to create a perspective projection matrix
  78268. */
  78269. perspective?: ICameraPerspective;
  78270. /**
  78271. * Specifies if the camera uses a perspective or orthographic projection
  78272. */
  78273. type: CameraType;
  78274. }
  78275. /**
  78276. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78277. */
  78278. interface IImage extends IChildRootProperty {
  78279. /**
  78280. * 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
  78281. */
  78282. uri?: string;
  78283. /**
  78284. * The image's MIME type
  78285. */
  78286. mimeType?: ImageMimeType;
  78287. /**
  78288. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78289. */
  78290. bufferView?: number;
  78291. }
  78292. /**
  78293. * Material Normal Texture Info
  78294. */
  78295. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78296. /**
  78297. * The scalar multiplier applied to each normal vector of the normal texture
  78298. */
  78299. scale?: number;
  78300. }
  78301. /**
  78302. * Material Occlusion Texture Info
  78303. */
  78304. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78305. /**
  78306. * A scalar multiplier controlling the amount of occlusion applied
  78307. */
  78308. strength?: number;
  78309. }
  78310. /**
  78311. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78312. */
  78313. interface IMaterialPbrMetallicRoughness {
  78314. /**
  78315. * The material's base color factor
  78316. */
  78317. baseColorFactor?: number[];
  78318. /**
  78319. * The base color texture
  78320. */
  78321. baseColorTexture?: ITextureInfo;
  78322. /**
  78323. * The metalness of the material
  78324. */
  78325. metallicFactor?: number;
  78326. /**
  78327. * The roughness of the material
  78328. */
  78329. roughnessFactor?: number;
  78330. /**
  78331. * The metallic-roughness texture
  78332. */
  78333. metallicRoughnessTexture?: ITextureInfo;
  78334. }
  78335. /**
  78336. * The material appearance of a primitive
  78337. */
  78338. interface IMaterial extends IChildRootProperty {
  78339. /**
  78340. * 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
  78341. */
  78342. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78343. /**
  78344. * The normal map texture
  78345. */
  78346. normalTexture?: IMaterialNormalTextureInfo;
  78347. /**
  78348. * The occlusion map texture
  78349. */
  78350. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78351. /**
  78352. * The emissive map texture
  78353. */
  78354. emissiveTexture?: ITextureInfo;
  78355. /**
  78356. * 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
  78357. */
  78358. emissiveFactor?: number[];
  78359. /**
  78360. * The alpha rendering mode of the material
  78361. */
  78362. alphaMode?: MaterialAlphaMode;
  78363. /**
  78364. * The alpha cutoff value of the material
  78365. */
  78366. alphaCutoff?: number;
  78367. /**
  78368. * Specifies whether the material is double sided
  78369. */
  78370. doubleSided?: boolean;
  78371. }
  78372. /**
  78373. * Geometry to be rendered with the given material
  78374. */
  78375. interface IMeshPrimitive extends IProperty {
  78376. /**
  78377. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78378. */
  78379. attributes: {
  78380. [name: string]: number;
  78381. };
  78382. /**
  78383. * The index of the accessor that contains the indices
  78384. */
  78385. indices?: number;
  78386. /**
  78387. * The index of the material to apply to this primitive when rendering
  78388. */
  78389. material?: number;
  78390. /**
  78391. * The type of primitives to render. All valid values correspond to WebGL enums
  78392. */
  78393. mode?: MeshPrimitiveMode;
  78394. /**
  78395. * 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
  78396. */
  78397. targets?: {
  78398. [name: string]: number;
  78399. }[];
  78400. }
  78401. /**
  78402. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78403. */
  78404. interface IMesh extends IChildRootProperty {
  78405. /**
  78406. * An array of primitives, each defining geometry to be rendered with a material
  78407. */
  78408. primitives: IMeshPrimitive[];
  78409. /**
  78410. * Array of weights to be applied to the Morph Targets
  78411. */
  78412. weights?: number[];
  78413. }
  78414. /**
  78415. * A node in the node hierarchy
  78416. */
  78417. interface INode extends IChildRootProperty {
  78418. /**
  78419. * The index of the camera referenced by this node
  78420. */
  78421. camera?: number;
  78422. /**
  78423. * The indices of this node's children
  78424. */
  78425. children?: number[];
  78426. /**
  78427. * The index of the skin referenced by this node
  78428. */
  78429. skin?: number;
  78430. /**
  78431. * A floating-point 4x4 transformation matrix stored in column-major order
  78432. */
  78433. matrix?: number[];
  78434. /**
  78435. * The index of the mesh in this node
  78436. */
  78437. mesh?: number;
  78438. /**
  78439. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78440. */
  78441. rotation?: number[];
  78442. /**
  78443. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78444. */
  78445. scale?: number[];
  78446. /**
  78447. * The node's translation along the x, y, and z axes
  78448. */
  78449. translation?: number[];
  78450. /**
  78451. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78452. */
  78453. weights?: number[];
  78454. }
  78455. /**
  78456. * Texture sampler properties for filtering and wrapping modes
  78457. */
  78458. interface ISampler extends IChildRootProperty {
  78459. /**
  78460. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78461. */
  78462. magFilter?: TextureMagFilter;
  78463. /**
  78464. * Minification filter. All valid values correspond to WebGL enums
  78465. */
  78466. minFilter?: TextureMinFilter;
  78467. /**
  78468. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78469. */
  78470. wrapS?: TextureWrapMode;
  78471. /**
  78472. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78473. */
  78474. wrapT?: TextureWrapMode;
  78475. }
  78476. /**
  78477. * The root nodes of a scene
  78478. */
  78479. interface IScene extends IChildRootProperty {
  78480. /**
  78481. * The indices of each root node
  78482. */
  78483. nodes: number[];
  78484. }
  78485. /**
  78486. * Joints and matrices defining a skin
  78487. */
  78488. interface ISkin extends IChildRootProperty {
  78489. /**
  78490. * 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
  78491. */
  78492. inverseBindMatrices?: number;
  78493. /**
  78494. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78495. */
  78496. skeleton?: number;
  78497. /**
  78498. * 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)
  78499. */
  78500. joints: number[];
  78501. }
  78502. /**
  78503. * A texture and its sampler
  78504. */
  78505. interface ITexture extends IChildRootProperty {
  78506. /**
  78507. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78508. */
  78509. sampler?: number;
  78510. /**
  78511. * The index of the image used by this texture
  78512. */
  78513. source: number;
  78514. }
  78515. /**
  78516. * Reference to a texture
  78517. */
  78518. interface ITextureInfo extends IProperty {
  78519. /**
  78520. * The index of the texture
  78521. */
  78522. index: number;
  78523. /**
  78524. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78525. */
  78526. texCoord?: number;
  78527. }
  78528. /**
  78529. * The root object for a glTF asset
  78530. */
  78531. interface IGLTF extends IProperty {
  78532. /**
  78533. * An array of accessors. An accessor is a typed view into a bufferView
  78534. */
  78535. accessors?: IAccessor[];
  78536. /**
  78537. * An array of keyframe animations
  78538. */
  78539. animations?: IAnimation[];
  78540. /**
  78541. * Metadata about the glTF asset
  78542. */
  78543. asset: IAsset;
  78544. /**
  78545. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78546. */
  78547. buffers?: IBuffer[];
  78548. /**
  78549. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78550. */
  78551. bufferViews?: IBufferView[];
  78552. /**
  78553. * An array of cameras
  78554. */
  78555. cameras?: ICamera[];
  78556. /**
  78557. * Names of glTF extensions used somewhere in this asset
  78558. */
  78559. extensionsUsed?: string[];
  78560. /**
  78561. * Names of glTF extensions required to properly load this asset
  78562. */
  78563. extensionsRequired?: string[];
  78564. /**
  78565. * An array of images. An image defines data used to create a texture
  78566. */
  78567. images?: IImage[];
  78568. /**
  78569. * An array of materials. A material defines the appearance of a primitive
  78570. */
  78571. materials?: IMaterial[];
  78572. /**
  78573. * An array of meshes. A mesh is a set of primitives to be rendered
  78574. */
  78575. meshes?: IMesh[];
  78576. /**
  78577. * An array of nodes
  78578. */
  78579. nodes?: INode[];
  78580. /**
  78581. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78582. */
  78583. samplers?: ISampler[];
  78584. /**
  78585. * The index of the default scene
  78586. */
  78587. scene?: number;
  78588. /**
  78589. * An array of scenes
  78590. */
  78591. scenes?: IScene[];
  78592. /**
  78593. * An array of skins. A skin is defined by joints and matrices
  78594. */
  78595. skins?: ISkin[];
  78596. /**
  78597. * An array of textures
  78598. */
  78599. textures?: ITexture[];
  78600. }
  78601. /**
  78602. * The glTF validation results
  78603. * @ignore
  78604. */
  78605. interface IGLTFValidationResults {
  78606. info: {
  78607. generator: string;
  78608. hasAnimations: boolean;
  78609. hasDefaultScene: boolean;
  78610. hasMaterials: boolean;
  78611. hasMorphTargets: boolean;
  78612. hasSkins: boolean;
  78613. hasTextures: boolean;
  78614. maxAttributesUsed: number;
  78615. primitivesCount: number
  78616. };
  78617. issues: {
  78618. messages: Array<string>;
  78619. numErrors: number;
  78620. numHints: number;
  78621. numInfos: number;
  78622. numWarnings: number;
  78623. truncated: boolean
  78624. };
  78625. mimeType: string;
  78626. uri: string;
  78627. validatedAt: string;
  78628. validatorVersion: string;
  78629. }
  78630. /**
  78631. * The glTF validation options
  78632. */
  78633. interface IGLTFValidationOptions {
  78634. /** Uri to use */
  78635. uri?: string;
  78636. /** Function used to load external resources */
  78637. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78638. /** Boolean indicating that we need to validate accessor data */
  78639. validateAccessorData?: boolean;
  78640. /** max number of issues allowed */
  78641. maxIssues?: number;
  78642. /** Ignored issues */
  78643. ignoredIssues?: Array<string>;
  78644. /** Value to override severy settings */
  78645. severityOverrides?: Object;
  78646. }
  78647. /**
  78648. * The glTF validator object
  78649. * @ignore
  78650. */
  78651. interface IGLTFValidator {
  78652. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78653. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78654. }
  78655. }
  78656. declare module BABYLON {
  78657. /** @hidden */
  78658. export var cellPixelShader: {
  78659. name: string;
  78660. shader: string;
  78661. };
  78662. }
  78663. declare module BABYLON {
  78664. /** @hidden */
  78665. export var cellVertexShader: {
  78666. name: string;
  78667. shader: string;
  78668. };
  78669. }
  78670. declare module BABYLON {
  78671. export class CellMaterial extends BABYLON.PushMaterial {
  78672. private _diffuseTexture;
  78673. diffuseTexture: BABYLON.BaseTexture;
  78674. diffuseColor: BABYLON.Color3;
  78675. _computeHighLevel: boolean;
  78676. computeHighLevel: boolean;
  78677. private _disableLighting;
  78678. disableLighting: boolean;
  78679. private _maxSimultaneousLights;
  78680. maxSimultaneousLights: number;
  78681. private _renderId;
  78682. constructor(name: string, scene: BABYLON.Scene);
  78683. needAlphaBlending(): boolean;
  78684. needAlphaTesting(): boolean;
  78685. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78686. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78687. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78688. getAnimatables(): BABYLON.IAnimatable[];
  78689. getActiveTextures(): BABYLON.BaseTexture[];
  78690. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78691. dispose(forceDisposeEffect?: boolean): void;
  78692. getClassName(): string;
  78693. clone(name: string): CellMaterial;
  78694. serialize(): any;
  78695. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78696. }
  78697. }
  78698. declare module BABYLON {
  78699. export class CustomShaderStructure {
  78700. FragmentStore: string;
  78701. VertexStore: string;
  78702. constructor();
  78703. }
  78704. export class ShaderSpecialParts {
  78705. constructor();
  78706. Fragment_Begin: string;
  78707. Fragment_Definitions: string;
  78708. Fragment_MainBegin: string;
  78709. Fragment_Custom_Diffuse: string;
  78710. Fragment_Before_Lights: string;
  78711. Fragment_Before_Fog: string;
  78712. Fragment_Custom_Alpha: string;
  78713. Fragment_Before_FragColor: string;
  78714. Vertex_Begin: string;
  78715. Vertex_Definitions: string;
  78716. Vertex_MainBegin: string;
  78717. Vertex_Before_PositionUpdated: string;
  78718. Vertex_Before_NormalUpdated: string;
  78719. Vertex_MainEnd: string;
  78720. }
  78721. export class CustomMaterial extends BABYLON.StandardMaterial {
  78722. static ShaderIndexer: number;
  78723. CustomParts: ShaderSpecialParts;
  78724. _isCreatedShader: boolean;
  78725. _createdShaderName: string;
  78726. _customUniform: string[];
  78727. _newUniforms: string[];
  78728. _newUniformInstances: any[];
  78729. _newSamplerInstances: BABYLON.Texture[];
  78730. FragmentShader: string;
  78731. VertexShader: string;
  78732. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78733. ReviewUniform(name: string, arr: string[]): string[];
  78734. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78735. constructor(name: string, scene: BABYLON.Scene);
  78736. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78737. Fragment_Begin(shaderPart: string): CustomMaterial;
  78738. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78739. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78740. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78741. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78742. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78743. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78744. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78745. Vertex_Begin(shaderPart: string): CustomMaterial;
  78746. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78747. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78748. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78749. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78750. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78751. }
  78752. }
  78753. declare module BABYLON {
  78754. export class ShaderAlebdoParts {
  78755. constructor();
  78756. Fragment_Begin: string;
  78757. Fragment_Definitions: string;
  78758. Fragment_MainBegin: string;
  78759. Fragment_Custom_Albedo: string;
  78760. Fragment_Before_Lights: string;
  78761. Fragment_Custom_MetallicRoughness: string;
  78762. Fragment_Custom_MicroSurface: string;
  78763. Fragment_Before_Fog: string;
  78764. Fragment_Custom_Alpha: string;
  78765. Fragment_Before_FragColor: string;
  78766. Vertex_Begin: string;
  78767. Vertex_Definitions: string;
  78768. Vertex_MainBegin: string;
  78769. Vertex_Before_PositionUpdated: string;
  78770. Vertex_Before_NormalUpdated: string;
  78771. Vertex_MainEnd: string;
  78772. }
  78773. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78774. static ShaderIndexer: number;
  78775. CustomParts: ShaderAlebdoParts;
  78776. _isCreatedShader: boolean;
  78777. _createdShaderName: string;
  78778. _customUniform: string[];
  78779. _newUniforms: string[];
  78780. _newUniformInstances: any[];
  78781. _newSamplerInstances: BABYLON.Texture[];
  78782. FragmentShader: string;
  78783. VertexShader: string;
  78784. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78785. ReviewUniform(name: string, arr: string[]): string[];
  78786. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78787. constructor(name: string, scene: BABYLON.Scene);
  78788. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78789. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78790. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78791. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78792. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78793. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78794. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78795. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78796. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78797. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78798. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78799. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78800. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78801. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78802. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78803. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78804. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78805. }
  78806. }
  78807. declare module BABYLON {
  78808. /** @hidden */
  78809. export var firePixelShader: {
  78810. name: string;
  78811. shader: string;
  78812. };
  78813. }
  78814. declare module BABYLON {
  78815. /** @hidden */
  78816. export var fireVertexShader: {
  78817. name: string;
  78818. shader: string;
  78819. };
  78820. }
  78821. declare module BABYLON {
  78822. export class FireMaterial extends BABYLON.PushMaterial {
  78823. private _diffuseTexture;
  78824. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78825. private _distortionTexture;
  78826. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78827. private _opacityTexture;
  78828. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78829. diffuseColor: BABYLON.Color3;
  78830. speed: number;
  78831. private _scaledDiffuse;
  78832. private _renderId;
  78833. private _lastTime;
  78834. constructor(name: string, scene: BABYLON.Scene);
  78835. needAlphaBlending(): boolean;
  78836. needAlphaTesting(): boolean;
  78837. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78838. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78839. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78840. getAnimatables(): BABYLON.IAnimatable[];
  78841. getActiveTextures(): BABYLON.BaseTexture[];
  78842. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78843. getClassName(): string;
  78844. dispose(forceDisposeEffect?: boolean): void;
  78845. clone(name: string): FireMaterial;
  78846. serialize(): any;
  78847. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78848. }
  78849. }
  78850. declare module BABYLON {
  78851. /** @hidden */
  78852. export var furPixelShader: {
  78853. name: string;
  78854. shader: string;
  78855. };
  78856. }
  78857. declare module BABYLON {
  78858. /** @hidden */
  78859. export var furVertexShader: {
  78860. name: string;
  78861. shader: string;
  78862. };
  78863. }
  78864. declare module BABYLON {
  78865. export class FurMaterial extends BABYLON.PushMaterial {
  78866. private _diffuseTexture;
  78867. diffuseTexture: BABYLON.BaseTexture;
  78868. private _heightTexture;
  78869. heightTexture: BABYLON.BaseTexture;
  78870. diffuseColor: BABYLON.Color3;
  78871. furLength: number;
  78872. furAngle: number;
  78873. furColor: BABYLON.Color3;
  78874. furOffset: number;
  78875. furSpacing: number;
  78876. furGravity: BABYLON.Vector3;
  78877. furSpeed: number;
  78878. furDensity: number;
  78879. furOcclusion: number;
  78880. furTexture: BABYLON.DynamicTexture;
  78881. private _disableLighting;
  78882. disableLighting: boolean;
  78883. private _maxSimultaneousLights;
  78884. maxSimultaneousLights: number;
  78885. highLevelFur: boolean;
  78886. _meshes: BABYLON.AbstractMesh[];
  78887. private _renderId;
  78888. private _furTime;
  78889. constructor(name: string, scene: BABYLON.Scene);
  78890. get furTime(): number;
  78891. set furTime(furTime: number);
  78892. needAlphaBlending(): boolean;
  78893. needAlphaTesting(): boolean;
  78894. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78895. updateFur(): void;
  78896. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78897. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78898. getAnimatables(): BABYLON.IAnimatable[];
  78899. getActiveTextures(): BABYLON.BaseTexture[];
  78900. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78901. dispose(forceDisposeEffect?: boolean): void;
  78902. clone(name: string): FurMaterial;
  78903. serialize(): any;
  78904. getClassName(): string;
  78905. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78906. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78907. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78908. }
  78909. }
  78910. declare module BABYLON {
  78911. /** @hidden */
  78912. export var gradientPixelShader: {
  78913. name: string;
  78914. shader: string;
  78915. };
  78916. }
  78917. declare module BABYLON {
  78918. /** @hidden */
  78919. export var gradientVertexShader: {
  78920. name: string;
  78921. shader: string;
  78922. };
  78923. }
  78924. declare module BABYLON {
  78925. export class GradientMaterial extends BABYLON.PushMaterial {
  78926. private _maxSimultaneousLights;
  78927. maxSimultaneousLights: number;
  78928. topColor: BABYLON.Color3;
  78929. topColorAlpha: number;
  78930. bottomColor: BABYLON.Color3;
  78931. bottomColorAlpha: number;
  78932. offset: number;
  78933. scale: number;
  78934. smoothness: number;
  78935. private _disableLighting;
  78936. disableLighting: boolean;
  78937. private _renderId;
  78938. constructor(name: string, scene: BABYLON.Scene);
  78939. needAlphaBlending(): boolean;
  78940. needAlphaTesting(): boolean;
  78941. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78942. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78943. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78944. getAnimatables(): BABYLON.IAnimatable[];
  78945. dispose(forceDisposeEffect?: boolean): void;
  78946. clone(name: string): GradientMaterial;
  78947. serialize(): any;
  78948. getClassName(): string;
  78949. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78950. }
  78951. }
  78952. declare module BABYLON {
  78953. /** @hidden */
  78954. export var gridPixelShader: {
  78955. name: string;
  78956. shader: string;
  78957. };
  78958. }
  78959. declare module BABYLON {
  78960. /** @hidden */
  78961. export var gridVertexShader: {
  78962. name: string;
  78963. shader: string;
  78964. };
  78965. }
  78966. declare module BABYLON {
  78967. /**
  78968. * The grid materials allows you to wrap any shape with a grid.
  78969. * Colors are customizable.
  78970. */
  78971. export class GridMaterial extends BABYLON.PushMaterial {
  78972. /**
  78973. * Main color of the grid (e.g. between lines)
  78974. */
  78975. mainColor: BABYLON.Color3;
  78976. /**
  78977. * Color of the grid lines.
  78978. */
  78979. lineColor: BABYLON.Color3;
  78980. /**
  78981. * The scale of the grid compared to unit.
  78982. */
  78983. gridRatio: number;
  78984. /**
  78985. * Allows setting an offset for the grid lines.
  78986. */
  78987. gridOffset: BABYLON.Vector3;
  78988. /**
  78989. * The frequency of thicker lines.
  78990. */
  78991. majorUnitFrequency: number;
  78992. /**
  78993. * The visibility of minor units in the grid.
  78994. */
  78995. minorUnitVisibility: number;
  78996. /**
  78997. * The grid opacity outside of the lines.
  78998. */
  78999. opacity: number;
  79000. /**
  79001. * Determine RBG output is premultiplied by alpha value.
  79002. */
  79003. preMultiplyAlpha: boolean;
  79004. private _opacityTexture;
  79005. opacityTexture: BABYLON.BaseTexture;
  79006. private _gridControl;
  79007. private _renderId;
  79008. /**
  79009. * constructor
  79010. * @param name The name given to the material in order to identify it afterwards.
  79011. * @param scene The scene the material is used in.
  79012. */
  79013. constructor(name: string, scene: BABYLON.Scene);
  79014. /**
  79015. * Returns wehter or not the grid requires alpha blending.
  79016. */
  79017. needAlphaBlending(): boolean;
  79018. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79019. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79020. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79021. /**
  79022. * Dispose the material and its associated resources.
  79023. * @param forceDisposeEffect will also dispose the used effect when true
  79024. */
  79025. dispose(forceDisposeEffect?: boolean): void;
  79026. clone(name: string): GridMaterial;
  79027. serialize(): any;
  79028. getClassName(): string;
  79029. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79030. }
  79031. }
  79032. declare module BABYLON {
  79033. /** @hidden */
  79034. export var lavaPixelShader: {
  79035. name: string;
  79036. shader: string;
  79037. };
  79038. }
  79039. declare module BABYLON {
  79040. /** @hidden */
  79041. export var lavaVertexShader: {
  79042. name: string;
  79043. shader: string;
  79044. };
  79045. }
  79046. declare module BABYLON {
  79047. export class LavaMaterial extends BABYLON.PushMaterial {
  79048. private _diffuseTexture;
  79049. diffuseTexture: BABYLON.BaseTexture;
  79050. noiseTexture: BABYLON.BaseTexture;
  79051. fogColor: BABYLON.Color3;
  79052. speed: number;
  79053. movingSpeed: number;
  79054. lowFrequencySpeed: number;
  79055. fogDensity: number;
  79056. private _lastTime;
  79057. diffuseColor: BABYLON.Color3;
  79058. private _disableLighting;
  79059. disableLighting: boolean;
  79060. private _unlit;
  79061. unlit: boolean;
  79062. private _maxSimultaneousLights;
  79063. maxSimultaneousLights: number;
  79064. private _scaledDiffuse;
  79065. private _renderId;
  79066. constructor(name: string, scene: BABYLON.Scene);
  79067. needAlphaBlending(): boolean;
  79068. needAlphaTesting(): boolean;
  79069. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79070. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79071. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79072. getAnimatables(): BABYLON.IAnimatable[];
  79073. getActiveTextures(): BABYLON.BaseTexture[];
  79074. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79075. dispose(forceDisposeEffect?: boolean): void;
  79076. clone(name: string): LavaMaterial;
  79077. serialize(): any;
  79078. getClassName(): string;
  79079. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79080. }
  79081. }
  79082. declare module BABYLON {
  79083. /** @hidden */
  79084. export var mixPixelShader: {
  79085. name: string;
  79086. shader: string;
  79087. };
  79088. }
  79089. declare module BABYLON {
  79090. /** @hidden */
  79091. export var mixVertexShader: {
  79092. name: string;
  79093. shader: string;
  79094. };
  79095. }
  79096. declare module BABYLON {
  79097. export class MixMaterial extends BABYLON.PushMaterial {
  79098. /**
  79099. * Mix textures
  79100. */
  79101. private _mixTexture1;
  79102. mixTexture1: BABYLON.BaseTexture;
  79103. private _mixTexture2;
  79104. mixTexture2: BABYLON.BaseTexture;
  79105. /**
  79106. * Diffuse textures
  79107. */
  79108. private _diffuseTexture1;
  79109. diffuseTexture1: BABYLON.Texture;
  79110. private _diffuseTexture2;
  79111. diffuseTexture2: BABYLON.Texture;
  79112. private _diffuseTexture3;
  79113. diffuseTexture3: BABYLON.Texture;
  79114. private _diffuseTexture4;
  79115. diffuseTexture4: BABYLON.Texture;
  79116. private _diffuseTexture5;
  79117. diffuseTexture5: BABYLON.Texture;
  79118. private _diffuseTexture6;
  79119. diffuseTexture6: BABYLON.Texture;
  79120. private _diffuseTexture7;
  79121. diffuseTexture7: BABYLON.Texture;
  79122. private _diffuseTexture8;
  79123. diffuseTexture8: BABYLON.Texture;
  79124. /**
  79125. * Uniforms
  79126. */
  79127. diffuseColor: BABYLON.Color3;
  79128. specularColor: BABYLON.Color3;
  79129. specularPower: number;
  79130. private _disableLighting;
  79131. disableLighting: boolean;
  79132. private _maxSimultaneousLights;
  79133. maxSimultaneousLights: number;
  79134. private _renderId;
  79135. constructor(name: string, scene: BABYLON.Scene);
  79136. needAlphaBlending(): boolean;
  79137. needAlphaTesting(): boolean;
  79138. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79139. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79140. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79141. getAnimatables(): BABYLON.IAnimatable[];
  79142. getActiveTextures(): BABYLON.BaseTexture[];
  79143. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79144. dispose(forceDisposeEffect?: boolean): void;
  79145. clone(name: string): MixMaterial;
  79146. serialize(): any;
  79147. getClassName(): string;
  79148. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79149. }
  79150. }
  79151. declare module BABYLON {
  79152. /** @hidden */
  79153. export var normalPixelShader: {
  79154. name: string;
  79155. shader: string;
  79156. };
  79157. }
  79158. declare module BABYLON {
  79159. /** @hidden */
  79160. export var normalVertexShader: {
  79161. name: string;
  79162. shader: string;
  79163. };
  79164. }
  79165. declare module BABYLON {
  79166. export class NormalMaterial extends BABYLON.PushMaterial {
  79167. private _diffuseTexture;
  79168. diffuseTexture: BABYLON.BaseTexture;
  79169. diffuseColor: BABYLON.Color3;
  79170. private _disableLighting;
  79171. disableLighting: boolean;
  79172. private _maxSimultaneousLights;
  79173. maxSimultaneousLights: number;
  79174. private _renderId;
  79175. constructor(name: string, scene: BABYLON.Scene);
  79176. needAlphaBlending(): boolean;
  79177. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79178. needAlphaTesting(): boolean;
  79179. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79180. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79181. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79182. getAnimatables(): BABYLON.IAnimatable[];
  79183. getActiveTextures(): BABYLON.BaseTexture[];
  79184. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79185. dispose(forceDisposeEffect?: boolean): void;
  79186. clone(name: string): NormalMaterial;
  79187. serialize(): any;
  79188. getClassName(): string;
  79189. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79190. }
  79191. }
  79192. declare module BABYLON {
  79193. /** @hidden */
  79194. export var shadowOnlyPixelShader: {
  79195. name: string;
  79196. shader: string;
  79197. };
  79198. }
  79199. declare module BABYLON {
  79200. /** @hidden */
  79201. export var shadowOnlyVertexShader: {
  79202. name: string;
  79203. shader: string;
  79204. };
  79205. }
  79206. declare module BABYLON {
  79207. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79208. private _renderId;
  79209. private _activeLight;
  79210. constructor(name: string, scene: BABYLON.Scene);
  79211. shadowColor: BABYLON.Color3;
  79212. needAlphaBlending(): boolean;
  79213. needAlphaTesting(): boolean;
  79214. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79215. get activeLight(): BABYLON.IShadowLight;
  79216. set activeLight(light: BABYLON.IShadowLight);
  79217. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79218. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79219. clone(name: string): ShadowOnlyMaterial;
  79220. serialize(): any;
  79221. getClassName(): string;
  79222. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79223. }
  79224. }
  79225. declare module BABYLON {
  79226. /** @hidden */
  79227. export var simplePixelShader: {
  79228. name: string;
  79229. shader: string;
  79230. };
  79231. }
  79232. declare module BABYLON {
  79233. /** @hidden */
  79234. export var simpleVertexShader: {
  79235. name: string;
  79236. shader: string;
  79237. };
  79238. }
  79239. declare module BABYLON {
  79240. export class SimpleMaterial extends BABYLON.PushMaterial {
  79241. private _diffuseTexture;
  79242. diffuseTexture: BABYLON.BaseTexture;
  79243. diffuseColor: BABYLON.Color3;
  79244. private _disableLighting;
  79245. disableLighting: boolean;
  79246. private _maxSimultaneousLights;
  79247. maxSimultaneousLights: number;
  79248. private _renderId;
  79249. constructor(name: string, scene: BABYLON.Scene);
  79250. needAlphaBlending(): boolean;
  79251. needAlphaTesting(): boolean;
  79252. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79253. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79254. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79255. getAnimatables(): BABYLON.IAnimatable[];
  79256. getActiveTextures(): BABYLON.BaseTexture[];
  79257. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79258. dispose(forceDisposeEffect?: boolean): void;
  79259. clone(name: string): SimpleMaterial;
  79260. serialize(): any;
  79261. getClassName(): string;
  79262. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79263. }
  79264. }
  79265. declare module BABYLON {
  79266. /** @hidden */
  79267. export var skyPixelShader: {
  79268. name: string;
  79269. shader: string;
  79270. };
  79271. }
  79272. declare module BABYLON {
  79273. /** @hidden */
  79274. export var skyVertexShader: {
  79275. name: string;
  79276. shader: string;
  79277. };
  79278. }
  79279. declare module BABYLON {
  79280. /**
  79281. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79282. * @see https://doc.babylonjs.com/extensions/sky
  79283. */
  79284. export class SkyMaterial extends BABYLON.PushMaterial {
  79285. /**
  79286. * Defines the overall luminance of sky in interval ]0, 1[.
  79287. */
  79288. luminance: number;
  79289. /**
  79290. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79291. */
  79292. turbidity: number;
  79293. /**
  79294. * Defines the sky appearance (light intensity).
  79295. */
  79296. rayleigh: number;
  79297. /**
  79298. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79299. */
  79300. mieCoefficient: number;
  79301. /**
  79302. * Defines the amount of haze particles following the Mie scattering theory.
  79303. */
  79304. mieDirectionalG: number;
  79305. /**
  79306. * Defines the distance of the sun according to the active scene camera.
  79307. */
  79308. distance: number;
  79309. /**
  79310. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79311. * "inclined".
  79312. */
  79313. inclination: number;
  79314. /**
  79315. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79316. * an object direction and a reference direction.
  79317. */
  79318. azimuth: number;
  79319. /**
  79320. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79321. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79322. */
  79323. sunPosition: BABYLON.Vector3;
  79324. /**
  79325. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79326. * .sunPosition property.
  79327. */
  79328. useSunPosition: boolean;
  79329. /**
  79330. * Defines an offset vector used to get a horizon offset.
  79331. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79332. */
  79333. cameraOffset: BABYLON.Vector3;
  79334. private _cameraPosition;
  79335. private _renderId;
  79336. /**
  79337. * Instantiates a new sky material.
  79338. * This material allows to create dynamic and texture free
  79339. * effects for skyboxes by taking care of the atmosphere state.
  79340. * @see https://doc.babylonjs.com/extensions/sky
  79341. * @param name Define the name of the material in the scene
  79342. * @param scene Define the scene the material belong to
  79343. */
  79344. constructor(name: string, scene: BABYLON.Scene);
  79345. /**
  79346. * Specifies if the material will require alpha blending
  79347. * @returns a boolean specifying if alpha blending is needed
  79348. */
  79349. needAlphaBlending(): boolean;
  79350. /**
  79351. * Specifies if this material should be rendered in alpha test mode
  79352. * @returns false as the sky material doesn't need alpha testing.
  79353. */
  79354. needAlphaTesting(): boolean;
  79355. /**
  79356. * Get the texture used for alpha test purpose.
  79357. * @returns null as the sky material has no texture.
  79358. */
  79359. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79360. /**
  79361. * Get if the submesh is ready to be used and all its information available.
  79362. * Child classes can use it to update shaders
  79363. * @param mesh defines the mesh to check
  79364. * @param subMesh defines which submesh to check
  79365. * @param useInstances specifies that instances should be used
  79366. * @returns a boolean indicating that the submesh is ready or not
  79367. */
  79368. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79369. /**
  79370. * Binds the submesh to this material by preparing the effect and shader to draw
  79371. * @param world defines the world transformation matrix
  79372. * @param mesh defines the mesh containing the submesh
  79373. * @param subMesh defines the submesh to bind the material to
  79374. */
  79375. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79376. /**
  79377. * Get the list of animatables in the material.
  79378. * @returns the list of animatables object used in the material
  79379. */
  79380. getAnimatables(): BABYLON.IAnimatable[];
  79381. /**
  79382. * Disposes the material
  79383. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79384. */
  79385. dispose(forceDisposeEffect?: boolean): void;
  79386. /**
  79387. * Makes a duplicate of the material, and gives it a new name
  79388. * @param name defines the new name for the duplicated material
  79389. * @returns the cloned material
  79390. */
  79391. clone(name: string): SkyMaterial;
  79392. /**
  79393. * Serializes this material in a JSON representation
  79394. * @returns the serialized material object
  79395. */
  79396. serialize(): any;
  79397. /**
  79398. * Gets the current class name of the material e.g. "SkyMaterial"
  79399. * Mainly use in serialization.
  79400. * @returns the class name
  79401. */
  79402. getClassName(): string;
  79403. /**
  79404. * Creates a sky material from parsed material data
  79405. * @param source defines the JSON representation of the material
  79406. * @param scene defines the hosting scene
  79407. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79408. * @returns a new sky material
  79409. */
  79410. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79411. }
  79412. }
  79413. declare module BABYLON {
  79414. /** @hidden */
  79415. export var terrainPixelShader: {
  79416. name: string;
  79417. shader: string;
  79418. };
  79419. }
  79420. declare module BABYLON {
  79421. /** @hidden */
  79422. export var terrainVertexShader: {
  79423. name: string;
  79424. shader: string;
  79425. };
  79426. }
  79427. declare module BABYLON {
  79428. export class TerrainMaterial extends BABYLON.PushMaterial {
  79429. private _mixTexture;
  79430. mixTexture: BABYLON.BaseTexture;
  79431. private _diffuseTexture1;
  79432. diffuseTexture1: BABYLON.Texture;
  79433. private _diffuseTexture2;
  79434. diffuseTexture2: BABYLON.Texture;
  79435. private _diffuseTexture3;
  79436. diffuseTexture3: BABYLON.Texture;
  79437. private _bumpTexture1;
  79438. bumpTexture1: BABYLON.Texture;
  79439. private _bumpTexture2;
  79440. bumpTexture2: BABYLON.Texture;
  79441. private _bumpTexture3;
  79442. bumpTexture3: BABYLON.Texture;
  79443. diffuseColor: BABYLON.Color3;
  79444. specularColor: BABYLON.Color3;
  79445. specularPower: number;
  79446. private _disableLighting;
  79447. disableLighting: boolean;
  79448. private _maxSimultaneousLights;
  79449. maxSimultaneousLights: number;
  79450. private _renderId;
  79451. constructor(name: string, scene: BABYLON.Scene);
  79452. needAlphaBlending(): boolean;
  79453. needAlphaTesting(): boolean;
  79454. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79455. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79456. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79457. getAnimatables(): BABYLON.IAnimatable[];
  79458. getActiveTextures(): BABYLON.BaseTexture[];
  79459. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79460. dispose(forceDisposeEffect?: boolean): void;
  79461. clone(name: string): TerrainMaterial;
  79462. serialize(): any;
  79463. getClassName(): string;
  79464. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79465. }
  79466. }
  79467. declare module BABYLON {
  79468. /** @hidden */
  79469. export var triplanarPixelShader: {
  79470. name: string;
  79471. shader: string;
  79472. };
  79473. }
  79474. declare module BABYLON {
  79475. /** @hidden */
  79476. export var triplanarVertexShader: {
  79477. name: string;
  79478. shader: string;
  79479. };
  79480. }
  79481. declare module BABYLON {
  79482. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79483. mixTexture: BABYLON.BaseTexture;
  79484. private _diffuseTextureX;
  79485. diffuseTextureX: BABYLON.BaseTexture;
  79486. private _diffuseTextureY;
  79487. diffuseTextureY: BABYLON.BaseTexture;
  79488. private _diffuseTextureZ;
  79489. diffuseTextureZ: BABYLON.BaseTexture;
  79490. private _normalTextureX;
  79491. normalTextureX: BABYLON.BaseTexture;
  79492. private _normalTextureY;
  79493. normalTextureY: BABYLON.BaseTexture;
  79494. private _normalTextureZ;
  79495. normalTextureZ: BABYLON.BaseTexture;
  79496. tileSize: number;
  79497. diffuseColor: BABYLON.Color3;
  79498. specularColor: BABYLON.Color3;
  79499. specularPower: number;
  79500. private _disableLighting;
  79501. disableLighting: boolean;
  79502. private _maxSimultaneousLights;
  79503. maxSimultaneousLights: number;
  79504. private _renderId;
  79505. constructor(name: string, scene: BABYLON.Scene);
  79506. needAlphaBlending(): boolean;
  79507. needAlphaTesting(): boolean;
  79508. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79509. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79510. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79511. getAnimatables(): BABYLON.IAnimatable[];
  79512. getActiveTextures(): BABYLON.BaseTexture[];
  79513. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79514. dispose(forceDisposeEffect?: boolean): void;
  79515. clone(name: string): TriPlanarMaterial;
  79516. serialize(): any;
  79517. getClassName(): string;
  79518. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79519. }
  79520. }
  79521. declare module BABYLON {
  79522. /** @hidden */
  79523. export var waterPixelShader: {
  79524. name: string;
  79525. shader: string;
  79526. };
  79527. }
  79528. declare module BABYLON {
  79529. /** @hidden */
  79530. export var waterVertexShader: {
  79531. name: string;
  79532. shader: string;
  79533. };
  79534. }
  79535. declare module BABYLON {
  79536. export class WaterMaterial extends BABYLON.PushMaterial {
  79537. renderTargetSize: BABYLON.Vector2;
  79538. private _bumpTexture;
  79539. bumpTexture: BABYLON.BaseTexture;
  79540. diffuseColor: BABYLON.Color3;
  79541. specularColor: BABYLON.Color3;
  79542. specularPower: number;
  79543. private _disableLighting;
  79544. disableLighting: boolean;
  79545. private _maxSimultaneousLights;
  79546. maxSimultaneousLights: number;
  79547. /**
  79548. * @param {number}: Represents the wind force
  79549. */
  79550. windForce: number;
  79551. /**
  79552. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79553. */
  79554. windDirection: BABYLON.Vector2;
  79555. /**
  79556. * @param {number}: Wave height, represents the height of the waves
  79557. */
  79558. waveHeight: number;
  79559. /**
  79560. * @param {number}: Bump height, represents the bump height related to the bump map
  79561. */
  79562. bumpHeight: number;
  79563. /**
  79564. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79565. */
  79566. private _bumpSuperimpose;
  79567. bumpSuperimpose: boolean;
  79568. /**
  79569. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79570. */
  79571. private _fresnelSeparate;
  79572. fresnelSeparate: boolean;
  79573. /**
  79574. * @param {boolean}: bump Waves modify the reflection.
  79575. */
  79576. private _bumpAffectsReflection;
  79577. bumpAffectsReflection: boolean;
  79578. /**
  79579. * @param {number}: The water color blended with the refraction (near)
  79580. */
  79581. waterColor: BABYLON.Color3;
  79582. /**
  79583. * @param {number}: The blend factor related to the water color
  79584. */
  79585. colorBlendFactor: number;
  79586. /**
  79587. * @param {number}: The water color blended with the reflection (far)
  79588. */
  79589. waterColor2: BABYLON.Color3;
  79590. /**
  79591. * @param {number}: The blend factor related to the water color (reflection, far)
  79592. */
  79593. colorBlendFactor2: number;
  79594. /**
  79595. * @param {number}: Represents the maximum length of a wave
  79596. */
  79597. waveLength: number;
  79598. /**
  79599. * @param {number}: Defines the waves speed
  79600. */
  79601. waveSpeed: number;
  79602. /**
  79603. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79604. * will avoid calculating useless pixels in the pixel shader of the water material.
  79605. */
  79606. disableClipPlane: boolean;
  79607. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79608. private _mesh;
  79609. private _refractionRTT;
  79610. private _reflectionRTT;
  79611. private _reflectionTransform;
  79612. private _lastTime;
  79613. private _lastDeltaTime;
  79614. private _renderId;
  79615. private _useLogarithmicDepth;
  79616. private _waitingRenderList;
  79617. private _imageProcessingConfiguration;
  79618. private _imageProcessingObserver;
  79619. /**
  79620. * Gets a boolean indicating that current material needs to register RTT
  79621. */
  79622. get hasRenderTargetTextures(): boolean;
  79623. /**
  79624. * Constructor
  79625. */
  79626. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79627. get useLogarithmicDepth(): boolean;
  79628. set useLogarithmicDepth(value: boolean);
  79629. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79630. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79631. addToRenderList(node: any): void;
  79632. enableRenderTargets(enable: boolean): void;
  79633. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79634. get renderTargetsEnabled(): boolean;
  79635. needAlphaBlending(): boolean;
  79636. needAlphaTesting(): boolean;
  79637. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79638. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79639. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79640. private _createRenderTargets;
  79641. getAnimatables(): BABYLON.IAnimatable[];
  79642. getActiveTextures(): BABYLON.BaseTexture[];
  79643. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79644. dispose(forceDisposeEffect?: boolean): void;
  79645. clone(name: string): WaterMaterial;
  79646. serialize(): any;
  79647. getClassName(): string;
  79648. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79649. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79650. }
  79651. }
  79652. declare module BABYLON {
  79653. /** @hidden */
  79654. export var asciiartPixelShader: {
  79655. name: string;
  79656. shader: string;
  79657. };
  79658. }
  79659. declare module BABYLON {
  79660. /**
  79661. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79662. *
  79663. * It basically takes care rendering the font front the given font size to a texture.
  79664. * This is used later on in the postprocess.
  79665. */
  79666. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79667. private _font;
  79668. private _text;
  79669. private _charSize;
  79670. /**
  79671. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79672. */
  79673. get charSize(): number;
  79674. /**
  79675. * Create a new instance of the Ascii Art FontTexture class
  79676. * @param name the name of the texture
  79677. * @param font the font to use, use the W3C CSS notation
  79678. * @param text the caracter set to use in the rendering.
  79679. * @param scene the scene that owns the texture
  79680. */
  79681. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79682. /**
  79683. * Gets the max char width of a font.
  79684. * @param font the font to use, use the W3C CSS notation
  79685. * @return the max char width
  79686. */
  79687. private getFontWidth;
  79688. /**
  79689. * Gets the max char height of a font.
  79690. * @param font the font to use, use the W3C CSS notation
  79691. * @return the max char height
  79692. */
  79693. private getFontHeight;
  79694. /**
  79695. * Clones the current AsciiArtTexture.
  79696. * @return the clone of the texture.
  79697. */
  79698. clone(): AsciiArtFontTexture;
  79699. /**
  79700. * Parses a json object representing the texture and returns an instance of it.
  79701. * @param source the source JSON representation
  79702. * @param scene the scene to create the texture for
  79703. * @return the parsed texture
  79704. */
  79705. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79706. }
  79707. /**
  79708. * Option available in the Ascii Art Post Process.
  79709. */
  79710. export interface IAsciiArtPostProcessOptions {
  79711. /**
  79712. * The font to use following the w3c font definition.
  79713. */
  79714. font?: string;
  79715. /**
  79716. * The character set to use in the postprocess.
  79717. */
  79718. characterSet?: string;
  79719. /**
  79720. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79721. * This number is defined between 0 and 1;
  79722. */
  79723. mixToTile?: number;
  79724. /**
  79725. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79726. * This number is defined between 0 and 1;
  79727. */
  79728. mixToNormal?: number;
  79729. }
  79730. /**
  79731. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79732. *
  79733. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79734. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79735. */
  79736. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79737. /**
  79738. * The font texture used to render the char in the post process.
  79739. */
  79740. private _asciiArtFontTexture;
  79741. /**
  79742. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79743. * This number is defined between 0 and 1;
  79744. */
  79745. mixToTile: number;
  79746. /**
  79747. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79748. * This number is defined between 0 and 1;
  79749. */
  79750. mixToNormal: number;
  79751. /**
  79752. * Instantiates a new Ascii Art Post Process.
  79753. * @param name the name to give to the postprocess
  79754. * @camera the camera to apply the post process to.
  79755. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79756. */
  79757. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79758. }
  79759. }
  79760. declare module BABYLON {
  79761. /** @hidden */
  79762. export var digitalrainPixelShader: {
  79763. name: string;
  79764. shader: string;
  79765. };
  79766. }
  79767. declare module BABYLON {
  79768. /**
  79769. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79770. *
  79771. * It basically takes care rendering the font front the given font size to a texture.
  79772. * This is used later on in the postprocess.
  79773. */
  79774. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79775. private _font;
  79776. private _text;
  79777. private _charSize;
  79778. /**
  79779. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79780. */
  79781. get charSize(): number;
  79782. /**
  79783. * Create a new instance of the Digital Rain FontTexture class
  79784. * @param name the name of the texture
  79785. * @param font the font to use, use the W3C CSS notation
  79786. * @param text the caracter set to use in the rendering.
  79787. * @param scene the scene that owns the texture
  79788. */
  79789. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79790. /**
  79791. * Gets the max char width of a font.
  79792. * @param font the font to use, use the W3C CSS notation
  79793. * @return the max char width
  79794. */
  79795. private getFontWidth;
  79796. /**
  79797. * Gets the max char height of a font.
  79798. * @param font the font to use, use the W3C CSS notation
  79799. * @return the max char height
  79800. */
  79801. private getFontHeight;
  79802. /**
  79803. * Clones the current DigitalRainFontTexture.
  79804. * @return the clone of the texture.
  79805. */
  79806. clone(): DigitalRainFontTexture;
  79807. /**
  79808. * Parses a json object representing the texture and returns an instance of it.
  79809. * @param source the source JSON representation
  79810. * @param scene the scene to create the texture for
  79811. * @return the parsed texture
  79812. */
  79813. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79814. }
  79815. /**
  79816. * Option available in the Digital Rain Post Process.
  79817. */
  79818. export interface IDigitalRainPostProcessOptions {
  79819. /**
  79820. * The font to use following the w3c font definition.
  79821. */
  79822. font?: string;
  79823. /**
  79824. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79825. * This number is defined between 0 and 1;
  79826. */
  79827. mixToTile?: number;
  79828. /**
  79829. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79830. * This number is defined between 0 and 1;
  79831. */
  79832. mixToNormal?: number;
  79833. }
  79834. /**
  79835. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79836. *
  79837. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79838. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79839. */
  79840. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79841. /**
  79842. * The font texture used to render the char in the post process.
  79843. */
  79844. private _digitalRainFontTexture;
  79845. /**
  79846. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79847. * This number is defined between 0 and 1;
  79848. */
  79849. mixToTile: number;
  79850. /**
  79851. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79852. * This number is defined between 0 and 1;
  79853. */
  79854. mixToNormal: number;
  79855. /**
  79856. * Instantiates a new Digital Rain Post Process.
  79857. * @param name the name to give to the postprocess
  79858. * @camera the camera to apply the post process to.
  79859. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79860. */
  79861. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79862. }
  79863. }
  79864. declare module BABYLON {
  79865. /** @hidden */
  79866. export var brickProceduralTexturePixelShader: {
  79867. name: string;
  79868. shader: string;
  79869. };
  79870. }
  79871. declare module BABYLON {
  79872. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79873. private _numberOfBricksHeight;
  79874. private _numberOfBricksWidth;
  79875. private _jointColor;
  79876. private _brickColor;
  79877. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79878. updateShaderUniforms(): void;
  79879. get numberOfBricksHeight(): number;
  79880. set numberOfBricksHeight(value: number);
  79881. get numberOfBricksWidth(): number;
  79882. set numberOfBricksWidth(value: number);
  79883. get jointColor(): BABYLON.Color3;
  79884. set jointColor(value: BABYLON.Color3);
  79885. get brickColor(): BABYLON.Color3;
  79886. set brickColor(value: BABYLON.Color3);
  79887. /**
  79888. * Serializes this brick procedural texture
  79889. * @returns a serialized brick procedural texture object
  79890. */
  79891. serialize(): any;
  79892. /**
  79893. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79894. * @param parsedTexture defines parsed texture data
  79895. * @param scene defines the current scene
  79896. * @param rootUrl defines the root URL containing brick procedural texture information
  79897. * @returns a parsed Brick Procedural BABYLON.Texture
  79898. */
  79899. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79900. }
  79901. }
  79902. declare module BABYLON {
  79903. /** @hidden */
  79904. export var cloudProceduralTexturePixelShader: {
  79905. name: string;
  79906. shader: string;
  79907. };
  79908. }
  79909. declare module BABYLON {
  79910. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79911. private _skyColor;
  79912. private _cloudColor;
  79913. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79914. updateShaderUniforms(): void;
  79915. get skyColor(): BABYLON.Color4;
  79916. set skyColor(value: BABYLON.Color4);
  79917. get cloudColor(): BABYLON.Color4;
  79918. set cloudColor(value: BABYLON.Color4);
  79919. /**
  79920. * Serializes this cloud procedural texture
  79921. * @returns a serialized cloud procedural texture object
  79922. */
  79923. serialize(): any;
  79924. /**
  79925. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79926. * @param parsedTexture defines parsed texture data
  79927. * @param scene defines the current scene
  79928. * @param rootUrl defines the root URL containing cloud procedural texture information
  79929. * @returns a parsed Cloud Procedural BABYLON.Texture
  79930. */
  79931. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79932. }
  79933. }
  79934. declare module BABYLON {
  79935. /** @hidden */
  79936. export var fireProceduralTexturePixelShader: {
  79937. name: string;
  79938. shader: string;
  79939. };
  79940. }
  79941. declare module BABYLON {
  79942. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79943. private _time;
  79944. private _speed;
  79945. private _autoGenerateTime;
  79946. private _fireColors;
  79947. private _alphaThreshold;
  79948. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79949. updateShaderUniforms(): void;
  79950. render(useCameraPostProcess?: boolean): void;
  79951. static get PurpleFireColors(): BABYLON.Color3[];
  79952. static get GreenFireColors(): BABYLON.Color3[];
  79953. static get RedFireColors(): BABYLON.Color3[];
  79954. static get BlueFireColors(): BABYLON.Color3[];
  79955. get autoGenerateTime(): boolean;
  79956. set autoGenerateTime(value: boolean);
  79957. get fireColors(): BABYLON.Color3[];
  79958. set fireColors(value: BABYLON.Color3[]);
  79959. get time(): number;
  79960. set time(value: number);
  79961. get speed(): BABYLON.Vector2;
  79962. set speed(value: BABYLON.Vector2);
  79963. get alphaThreshold(): number;
  79964. set alphaThreshold(value: number);
  79965. /**
  79966. * Serializes this fire procedural texture
  79967. * @returns a serialized fire procedural texture object
  79968. */
  79969. serialize(): any;
  79970. /**
  79971. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79972. * @param parsedTexture defines parsed texture data
  79973. * @param scene defines the current scene
  79974. * @param rootUrl defines the root URL containing fire procedural texture information
  79975. * @returns a parsed Fire Procedural BABYLON.Texture
  79976. */
  79977. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79978. }
  79979. }
  79980. declare module BABYLON {
  79981. /** @hidden */
  79982. export var grassProceduralTexturePixelShader: {
  79983. name: string;
  79984. shader: string;
  79985. };
  79986. }
  79987. declare module BABYLON {
  79988. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79989. private _grassColors;
  79990. private _groundColor;
  79991. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79992. updateShaderUniforms(): void;
  79993. get grassColors(): BABYLON.Color3[];
  79994. set grassColors(value: BABYLON.Color3[]);
  79995. get groundColor(): BABYLON.Color3;
  79996. set groundColor(value: BABYLON.Color3);
  79997. /**
  79998. * Serializes this grass procedural texture
  79999. * @returns a serialized grass procedural texture object
  80000. */
  80001. serialize(): any;
  80002. /**
  80003. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80004. * @param parsedTexture defines parsed texture data
  80005. * @param scene defines the current scene
  80006. * @param rootUrl defines the root URL containing grass procedural texture information
  80007. * @returns a parsed Grass Procedural BABYLON.Texture
  80008. */
  80009. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80010. }
  80011. }
  80012. declare module BABYLON {
  80013. /** @hidden */
  80014. export var marbleProceduralTexturePixelShader: {
  80015. name: string;
  80016. shader: string;
  80017. };
  80018. }
  80019. declare module BABYLON {
  80020. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80021. private _numberOfTilesHeight;
  80022. private _numberOfTilesWidth;
  80023. private _amplitude;
  80024. private _jointColor;
  80025. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80026. updateShaderUniforms(): void;
  80027. get numberOfTilesHeight(): number;
  80028. set numberOfTilesHeight(value: number);
  80029. get amplitude(): number;
  80030. set amplitude(value: number);
  80031. get numberOfTilesWidth(): number;
  80032. set numberOfTilesWidth(value: number);
  80033. get jointColor(): BABYLON.Color3;
  80034. set jointColor(value: BABYLON.Color3);
  80035. /**
  80036. * Serializes this marble procedural texture
  80037. * @returns a serialized marble procedural texture object
  80038. */
  80039. serialize(): any;
  80040. /**
  80041. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80042. * @param parsedTexture defines parsed texture data
  80043. * @param scene defines the current scene
  80044. * @param rootUrl defines the root URL containing marble procedural texture information
  80045. * @returns a parsed Marble Procedural BABYLON.Texture
  80046. */
  80047. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80048. }
  80049. }
  80050. declare module BABYLON {
  80051. /** @hidden */
  80052. export var normalMapProceduralTexturePixelShader: {
  80053. name: string;
  80054. shader: string;
  80055. };
  80056. }
  80057. declare module BABYLON {
  80058. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80059. private _baseTexture;
  80060. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80061. updateShaderUniforms(): void;
  80062. render(useCameraPostProcess?: boolean): void;
  80063. resize(size: any, generateMipMaps: any): void;
  80064. get baseTexture(): BABYLON.Texture;
  80065. set baseTexture(texture: BABYLON.Texture);
  80066. /**
  80067. * Serializes this normal map procedural texture
  80068. * @returns a serialized normal map procedural texture object
  80069. */
  80070. serialize(): any;
  80071. /**
  80072. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80073. * @param parsedTexture defines parsed texture data
  80074. * @param scene defines the current scene
  80075. * @param rootUrl defines the root URL containing normal map procedural texture information
  80076. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80077. */
  80078. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80079. }
  80080. }
  80081. declare module BABYLON {
  80082. /** @hidden */
  80083. export var perlinNoiseProceduralTexturePixelShader: {
  80084. name: string;
  80085. shader: string;
  80086. };
  80087. }
  80088. declare module BABYLON {
  80089. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80090. time: number;
  80091. timeScale: number;
  80092. translationSpeed: number;
  80093. private _currentTranslation;
  80094. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80095. updateShaderUniforms(): void;
  80096. render(useCameraPostProcess?: boolean): void;
  80097. resize(size: any, generateMipMaps: any): void;
  80098. /**
  80099. * Serializes this perlin noise procedural texture
  80100. * @returns a serialized perlin noise procedural texture object
  80101. */
  80102. serialize(): any;
  80103. /**
  80104. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80105. * @param parsedTexture defines parsed texture data
  80106. * @param scene defines the current scene
  80107. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80108. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80109. */
  80110. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80111. }
  80112. }
  80113. declare module BABYLON {
  80114. /** @hidden */
  80115. export var roadProceduralTexturePixelShader: {
  80116. name: string;
  80117. shader: string;
  80118. };
  80119. }
  80120. declare module BABYLON {
  80121. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80122. private _roadColor;
  80123. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80124. updateShaderUniforms(): void;
  80125. get roadColor(): BABYLON.Color3;
  80126. set roadColor(value: BABYLON.Color3);
  80127. /**
  80128. * Serializes this road procedural texture
  80129. * @returns a serialized road procedural texture object
  80130. */
  80131. serialize(): any;
  80132. /**
  80133. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80134. * @param parsedTexture defines parsed texture data
  80135. * @param scene defines the current scene
  80136. * @param rootUrl defines the root URL containing road procedural texture information
  80137. * @returns a parsed Road Procedural BABYLON.Texture
  80138. */
  80139. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80140. }
  80141. }
  80142. declare module BABYLON {
  80143. /** @hidden */
  80144. export var starfieldProceduralTexturePixelShader: {
  80145. name: string;
  80146. shader: string;
  80147. };
  80148. }
  80149. declare module BABYLON {
  80150. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80151. private _time;
  80152. private _alpha;
  80153. private _beta;
  80154. private _zoom;
  80155. private _formuparam;
  80156. private _stepsize;
  80157. private _tile;
  80158. private _brightness;
  80159. private _darkmatter;
  80160. private _distfading;
  80161. private _saturation;
  80162. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80163. updateShaderUniforms(): void;
  80164. get time(): number;
  80165. set time(value: number);
  80166. get alpha(): number;
  80167. set alpha(value: number);
  80168. get beta(): number;
  80169. set beta(value: number);
  80170. get formuparam(): number;
  80171. set formuparam(value: number);
  80172. get stepsize(): number;
  80173. set stepsize(value: number);
  80174. get zoom(): number;
  80175. set zoom(value: number);
  80176. get tile(): number;
  80177. set tile(value: number);
  80178. get brightness(): number;
  80179. set brightness(value: number);
  80180. get darkmatter(): number;
  80181. set darkmatter(value: number);
  80182. get distfading(): number;
  80183. set distfading(value: number);
  80184. get saturation(): number;
  80185. set saturation(value: number);
  80186. /**
  80187. * Serializes this starfield procedural texture
  80188. * @returns a serialized starfield procedural texture object
  80189. */
  80190. serialize(): any;
  80191. /**
  80192. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80193. * @param parsedTexture defines parsed texture data
  80194. * @param scene defines the current scene
  80195. * @param rootUrl defines the root URL containing startfield procedural texture information
  80196. * @returns a parsed Starfield Procedural BABYLON.Texture
  80197. */
  80198. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80199. }
  80200. }
  80201. declare module BABYLON {
  80202. /** @hidden */
  80203. export var woodProceduralTexturePixelShader: {
  80204. name: string;
  80205. shader: string;
  80206. };
  80207. }
  80208. declare module BABYLON {
  80209. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80210. private _ampScale;
  80211. private _woodColor;
  80212. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80213. updateShaderUniforms(): void;
  80214. get ampScale(): number;
  80215. set ampScale(value: number);
  80216. get woodColor(): BABYLON.Color3;
  80217. set woodColor(value: BABYLON.Color3);
  80218. /**
  80219. * Serializes this wood procedural texture
  80220. * @returns a serialized wood procedural texture object
  80221. */
  80222. serialize(): any;
  80223. /**
  80224. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80225. * @param parsedTexture defines parsed texture data
  80226. * @param scene defines the current scene
  80227. * @param rootUrl defines the root URL containing wood procedural texture information
  80228. * @returns a parsed Wood Procedural BABYLON.Texture
  80229. */
  80230. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80231. }
  80232. }